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

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.21    ! pearu      27: # 2. For GiNaC 0.8.0 or earlier uncomment GINAC_VERSION_0_8_0_OR_EARLIER
        !            28: #    line below.
1.15      pearu      29: #
                     30: # Pearu Peterson <pearu@cens.ioc.ee>
                     31: # 30 March 2001
1.1       pearu      32: 
                     33: import sys,os,string,time
                     34: 
1.14      pearu      35: #++++++++++++++ Require Python 2.x +++++++++++++
                     36: 
1.1       pearu      37: if eval(sys.version[0])<2:
                     38:     print "You'll need Python 2.0 or higher to build PyGiNaC"
                     39:     sys.exit()
                     40: 
1.16      pearu      41: #++++++++++++++ Rebuild ++++++++++++++++++++++++
                     42: rebuild = 0
1.20      pearu      43: disable_opt = 1 # for final compilation set 0
1.16      pearu      44: 
                     45: if 'rebuild' in sys.argv:
                     46:     sys.argv[sys.argv.index('rebuild')] = 'build'
                     47:     rebuild = 1
                     48: if 'reinstall' in sys.argv:
                     49:     sys.argv[sys.argv.index('reinstall')] = 'install'
                     50:     rebuild = 1
                     51: 
                     52: wrap_input = ['symbol','numeric','constant','relational',
                     53:               'lst','idx','varidx','power','add','mul',
                     54:               'ncmul','pseries','matrix','function','inifcns',
1.20      pearu      55:               'function','flags','exvector',
1.21    ! pearu      56:               'indexed','color','clifford','tensor']
1.19      pearu      57: if 0: # optional
                     58:     wrap_input += ['expair','epvector']
                     59: 
1.17      pearu      60: wrap_input = ['function','inifcns']
1.20      pearu      61: wrap_input = ['add','mul','power','lst','pseries','relational','matrix','numeric','constant','symbol','varidx']
1.21    ! pearu      62: wrap_input = ['symbol','function','inifcns']
1.20      pearu      63: 
                     64: #++++++++++++++++ Parameters ++++++++++++++++
                     65: nof_lst_params = 0    # max 15 for ginac, max 10 for boost.python, min 1
1.21    ! pearu      66: nof_ncmul_params = 3  # max 6
        !            67: nof_function_params = 2 # max 15 for ginac, max 10 for boost.python, min 1
1.1       pearu      68: #++++++++++++++++++++ boost +++++++++++++++++++++
1.14      pearu      69: 
1.3       pearu      70: boost_dir = '/usr/local/share/boost'
                     71: 
1.14      pearu      72: if not os.path.isdir(boost_dir):
1.15      pearu      73:     print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
                     74:     print 'Get Boost from http://www.boost.org/ and fix its path in setup.py'
1.14      pearu      75:     sys.exit()
                     76: 
                     77: bpl_dir = os.path.join(boost_dir,'libs','python','src')
1.1       pearu      78: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
                     79:               ['classes.cpp','conversions.cpp','extension_class.cpp',
                     80:                'functions.cpp','init_function.cpp','module_builder.cpp',
                     81:                'objects.cpp','types.cpp'])
                     82: 
                     83: #++++++++++++++++++++++++++++++++++++++++++++++++
                     84: from distutils.core import setup, Extension
                     85: 
1.15      pearu      86: #+++HACK: replace linker gcc with g++ +++++++++++
1.1       pearu      87: from distutils import sysconfig
                     88: save_init_posix = sysconfig._init_posix
                     89: def my_init_posix():
                     90:     save_init_posix()
                     91:     g = sysconfig._config_vars
1.3       pearu      92:     if g['LDSHARED'][:3]=='gcc':
                     93:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
                     94:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
                     95:         print 'to',`g['LDSHARED']`
1.20      pearu      96:     if disable_opt and g['OPT'][:6]=='-g -O2':
                     97:         print 'my_init_posix: changing OPT =',`g['OPT']`,
                     98:         g['OPT'] = '-g'+g['OPT'][6:]
                     99:         print 'to',`g['OPT']`
1.1       pearu     100: sysconfig._init_posix = my_init_posix
                    101: 
1.16      pearu     102: #+++++++++++++++++ PyGiNaC version ++++++++++++++
                    103: 
                    104: major_version = 0
1.20      pearu     105: minor_version = 1
1.16      pearu     106: try: execfile(os.path.join('tools','get_revision.py'))
                    107: except: revision_version = 0
                    108: version='%d.%d.%d'%(major_version,minor_version,revision_version)
                    109: 
                    110: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
1.1       pearu     111: 
1.5       pearu     112: ginac_cpp = os.path.join('src','_ginac.cpp')
                    113: 
                    114: cppsrc = [ginac_cpp]
                    115: 
1.16      pearu     116: if rebuild or not os.path.exists(ginac_cpp):
1.20      pearu     117:     wrapper_dir = 'wrappers'
                    118:     execfile(os.path.join(wrapper_dir,'build.py'))
                    119:     build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir)
1.4       pearu     120: 
1.15      pearu     121: ginac_ext = Extension('ginac._ginac',
1.6       pearu     122:                       sources=cppsrc+bpl_src,
                    123:                       include_dirs=[boost_dir],
                    124:                       libraries=['ginac','cln'],
                    125:                       library_dirs=[],
1.21    ! pearu     126:                       define_macros=[
        !           127: #    ('GINAC_VERSION_0_8_0_OR_EARLIER',None),
        !           128: #    ('DEBUG_PYGINAC', None),
        !           129:     ],
        !           130:                       )
1.1       pearu     131: 
                    132: #++++++++++++++++++++ setup +++++++++++++++++++++
                    133: 
                    134: setup (name = "PyGiNaC",
1.15      pearu     135:        version = version,
                    136:        description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
1.1       pearu     137:        author = "Pearu Peterson",
                    138:        author_email = "pearu@cens.ioc.ee",
1.16      pearu     139:        maintainer = "Pearu Peterson",
                    140:        maintainer_email = "pearu@cens.ioc.ee",
1.1       pearu     141:        licence = "LGPL",
1.15      pearu     142:        long_description= """
                    143: GiNaC is an open framework for symbolic computation within the C++
                    144: programming language (http://www.ginac.de/).
                    145: PyGiNaC is a Python package that provides a transparent interface
                    146: to GiNaC library. Currently the following GiNaC classes are exposed:
                    147:   ex, symbol, numeric, constant, relational, add, mul, power, ncmul,
                    148:   matrix, pseries, function, idx, varidx,
1.16      pearu     149:   lst, exvector, expair, exlist, epvector, etc.
1.15      pearu     150: In addition, PyGiNaC provides wrappers for various elementary functions,
1.16      pearu     151: such as sin, factorial, etc.
1.15      pearu     152: """,
                    153:        url = "http://cens.ioc.ee/projects/pyginac/",
1.1       pearu     154:        ext_modules = [ ginac_ext ],
1.15      pearu     155:        packages = ['ginac'],
                    156:        package_dir = {'ginac': 'lib'},
1.1       pearu     157:        )
1.15      pearu     158: 
                    159: print "PyGiNaC Version",version

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