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

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

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