Annotation of python/pyGiNaC/setup.py, revision 1.23

1.1       pearu       1: #!/usr/bin/env python
1.15      pearu       2: #
                      3: #   Setup file for building/installing PyGiNaC
                      4: #
                      5: # Requirements:
                      6: #   Python 2.0 or higher (http://www.python.org/)
                      7: #   GiNaC 0.8.0 or higher (http://www.ginac.de/)
1.16      pearu       8: #     For GiNaC, you'll need CLN 1.1 (http://clisp.cons.org/~haible/packages-cln.html)
                      9: #       Optional, but recommended, CLN can use GMP 3.1.1 (http://www.swox.com/gmp/)
1.15      pearu      10: #   Boost 1.21.1 or higher (http://www.boost.org/)
1.21      pearu      11: #  
1.15      pearu      12: # Usage:
                     13: #   > python setup.py install
                     14: #
1.21      pearu      15: # In Python `import ginac'. Module `ginac' extension classes exposing
                     16: # almost all GiNaC classes to Python.
                     17: # See GiNaC documentation (http://www.ginac.de/tutorial/) for usage.
1.16      pearu      18: #
1.21      pearu      19: # Notes:
                     20: # 1. Compilation of PyGiNaC requires more than 160MB memory (with gcc -O2
1.16      pearu      21: #   on Intel Linux). However, if you don't need all the GiNaC classes
                     22: #   to be exposed to Python, you can edit the list `wrap_input' below
                     23: #   to indicate your needs, this will decrease also the memory consumption
                     24: #   during the compilation. You don't need to worry about class dependencies
                     25: #   they are solved automatically. After you edit `wrap_input', run
                     26: #  > python setup.py reinstall
1.15      pearu      27: #
                     28: # Pearu Peterson <pearu@cens.ioc.ee>
                     29: # 30 March 2001
1.1       pearu      30: 
1.23    ! pearu      31: __credits__ = """\
        !            32: GiNaC people (www.ginac.de), for the GiNaC library.
        !            33: Boost.Python people (www.boost.org), for BPL that considerably
        !            34: simplified the wrapping of GiNaC C++ classes to Python.
        !            35: """
        !            36: 
1.1       pearu      37: import sys,os,string,time
                     38: 
1.14      pearu      39: #++++++++++++++ Require Python 2.x +++++++++++++
                     40: 
1.1       pearu      41: if eval(sys.version[0])<2:
                     42:     print "You'll need Python 2.0 or higher to build PyGiNaC"
                     43:     sys.exit()
                     44: 
1.16      pearu      45: #++++++++++++++ Rebuild ++++++++++++++++++++++++
                     46: rebuild = 0
1.23    ! pearu      47: gendoc = 0
1.22      pearu      48: disable_opt = 1 # set 0 for final compilation
1.16      pearu      49: 
1.23    ! pearu      50: if 'doc' in sys.argv:
        !            51:     del sys.argv[sys.argv.index('doc')]
        !            52:     gendoc = 1
        !            53: 
1.16      pearu      54: if 'rebuild' in sys.argv:
                     55:     sys.argv[sys.argv.index('rebuild')] = 'build'
                     56:     rebuild = 1
                     57: if 'reinstall' in sys.argv:
                     58:     sys.argv[sys.argv.index('reinstall')] = 'install'
                     59:     rebuild = 1
                     60: 
                     61: wrap_input = ['symbol','numeric','constant','relational',
                     62:               'lst','idx','varidx','power','add','mul',
                     63:               'ncmul','pseries','matrix','function','inifcns',
1.20      pearu      64:               'function','flags','exvector',
1.21      pearu      65:               'indexed','color','clifford','tensor']
1.20      pearu      66: 
1.22      pearu      67: #wrap_input = ['function','inifcns']
                     68: #wrap_input = ['add','mul','power','lst','pseries','relational','matrix','numeric','constant','symbol','varidx']
1.23    ! pearu      69: #wrap_input = ['symbol','lst','matrix']
        !            70: #wrap_input = ['symbol','tensor']
        !            71: 
1.20      pearu      72: #++++++++++++++++ Parameters ++++++++++++++++
1.23    ! pearu      73: nof_lst_params = 10   # max 15 for ginac, max 10 for boost.python, min 1
        !            74: nof_ncmul_params = 6  # max 6
        !            75: nof_function_params = 9 # max 13 for ginac, max 9 for boost.python, min 1
1.1       pearu      76: #++++++++++++++++++++ boost +++++++++++++++++++++
1.14      pearu      77: 
1.3       pearu      78: boost_dir = '/usr/local/share/boost'
                     79: 
1.14      pearu      80: if not os.path.isdir(boost_dir):
1.15      pearu      81:     print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
                     82:     print 'Get Boost from http://www.boost.org/ and fix its path in setup.py'
1.14      pearu      83:     sys.exit()
                     84: 
                     85: bpl_dir = os.path.join(boost_dir,'libs','python','src')
1.1       pearu      86: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
                     87:               ['classes.cpp','conversions.cpp','extension_class.cpp',
                     88:                'functions.cpp','init_function.cpp','module_builder.cpp',
                     89:                'objects.cpp','types.cpp'])
                     90: 
                     91: #++++++++++++++++++++++++++++++++++++++++++++++++
                     92: from distutils.core import setup, Extension
                     93: 
1.15      pearu      94: #+++HACK: replace linker gcc with g++ +++++++++++
1.1       pearu      95: from distutils import sysconfig
                     96: save_init_posix = sysconfig._init_posix
                     97: def my_init_posix():
                     98:     save_init_posix()
                     99:     g = sysconfig._config_vars
1.3       pearu     100:     if g['LDSHARED'][:3]=='gcc':
                    101:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
                    102:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
                    103:         print 'to',`g['LDSHARED']`
1.20      pearu     104:     if disable_opt and g['OPT'][:6]=='-g -O2':
                    105:         print 'my_init_posix: changing OPT =',`g['OPT']`,
                    106:         g['OPT'] = '-g'+g['OPT'][6:]
                    107:         print 'to',`g['OPT']`
1.1       pearu     108: sysconfig._init_posix = my_init_posix
                    109: 
1.16      pearu     110: #+++++++++++++++++ PyGiNaC version ++++++++++++++
                    111: 
                    112: major_version = 0
1.23    ! pearu     113: minor_version = 2
1.16      pearu     114: try: execfile(os.path.join('tools','get_revision.py'))
                    115: except: revision_version = 0
                    116: version='%d.%d.%d'%(major_version,minor_version,revision_version)
                    117: 
                    118: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
1.1       pearu     119: 
1.5       pearu     120: ginac_cpp = os.path.join('src','_ginac.cpp')
                    121: 
                    122: cppsrc = [ginac_cpp]
1.23    ! pearu     123: wrapper_dir = 'wrappers'
        !           124: if gendoc:
        !           125:     execfile(os.path.join(wrapper_dir,'build.py'))
        !           126:     build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=1,
        !           127:                     vers=version,credits=__credits__)
        !           128:     if len(sys.argv)==1:
        !           129:         print "PyGiNaC Version",version
        !           130:         sys.exit()
1.16      pearu     131: if rebuild or not os.path.exists(ginac_cpp):
1.20      pearu     132:     execfile(os.path.join(wrapper_dir,'build.py'))
1.23    ! pearu     133:     build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=0,
        !           134:                     vers=version,credits=__credits__)
1.4       pearu     135: 
1.15      pearu     136: ginac_ext = Extension('ginac._ginac',
1.6       pearu     137:                       sources=cppsrc+bpl_src,
                    138:                       include_dirs=[boost_dir],
                    139:                       libraries=['ginac','cln'],
                    140:                       library_dirs=[],
1.21      pearu     141:                       define_macros=[
                    142: #    ('DEBUG_PYGINAC', None),
                    143:     ],
                    144:                       )
1.1       pearu     145: 
                    146: #++++++++++++++++++++ setup +++++++++++++++++++++
                    147: 
                    148: setup (name = "PyGiNaC",
1.15      pearu     149:        version = version,
                    150:        description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
1.1       pearu     151:        author = "Pearu Peterson",
                    152:        author_email = "pearu@cens.ioc.ee",
1.16      pearu     153:        maintainer = "Pearu Peterson",
                    154:        maintainer_email = "pearu@cens.ioc.ee",
1.1       pearu     155:        licence = "LGPL",
1.15      pearu     156:        long_description= """
                    157: GiNaC is an open framework for symbolic computation within the C++
                    158: programming language (http://www.ginac.de/).
                    159: PyGiNaC is a Python package that provides a transparent interface
                    160: to GiNaC library. Currently the following GiNaC classes are exposed:
                    161:   ex, symbol, numeric, constant, relational, add, mul, power, ncmul,
1.22      pearu     162:   matrix, pseries, function, idx, varidx, tensor, indexed,
1.16      pearu     163:   lst, exvector, expair, exlist, epvector, etc.
1.15      pearu     164: In addition, PyGiNaC provides wrappers for various elementary functions,
1.16      pearu     165: such as sin, factorial, etc.
1.15      pearu     166: """,
                    167:        url = "http://cens.ioc.ee/projects/pyginac/",
1.1       pearu     168:        ext_modules = [ ginac_ext ],
1.23    ! pearu     169:        packages = ['ginac','ginac.doc'],
        !           170:        package_dir = {'ginac': 'lib',
        !           171:                       'ginac.doc':os.path.join('lib','doc') },
1.1       pearu     172:        )
1.15      pearu     173: 
                    174: print "PyGiNaC Version",version

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>