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

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.24    ! pearu      72: wrap_input = ['symbol','lst']
        !            73: 
1.20      pearu      74: #++++++++++++++++ Parameters ++++++++++++++++
1.23      pearu      75: nof_lst_params = 10   # max 15 for ginac, max 10 for boost.python, min 1
                     76: nof_ncmul_params = 6  # max 6
                     77: nof_function_params = 9 # max 13 for ginac, max 9 for boost.python, min 1
1.1       pearu      78: #++++++++++++++++++++ boost +++++++++++++++++++++
1.14      pearu      79: 
1.3       pearu      80: boost_dir = '/usr/local/share/boost'
                     81: 
1.14      pearu      82: if not os.path.isdir(boost_dir):
1.15      pearu      83:     print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
                     84:     print 'Get Boost from http://www.boost.org/ and fix its path in setup.py'
1.14      pearu      85:     sys.exit()
                     86: 
                     87: bpl_dir = os.path.join(boost_dir,'libs','python','src')
1.1       pearu      88: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
                     89:               ['classes.cpp','conversions.cpp','extension_class.cpp',
                     90:                'functions.cpp','init_function.cpp','module_builder.cpp',
                     91:                'objects.cpp','types.cpp'])
                     92: 
                     93: #++++++++++++++++++++++++++++++++++++++++++++++++
                     94: from distutils.core import setup, Extension
                     95: 
1.15      pearu      96: #+++HACK: replace linker gcc with g++ +++++++++++
1.1       pearu      97: from distutils import sysconfig
                     98: save_init_posix = sysconfig._init_posix
                     99: def my_init_posix():
                    100:     save_init_posix()
                    101:     g = sysconfig._config_vars
1.3       pearu     102:     if g['LDSHARED'][:3]=='gcc':
                    103:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
                    104:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
                    105:         print 'to',`g['LDSHARED']`
1.20      pearu     106:     if disable_opt and g['OPT'][:6]=='-g -O2':
                    107:         print 'my_init_posix: changing OPT =',`g['OPT']`,
                    108:         g['OPT'] = '-g'+g['OPT'][6:]
                    109:         print 'to',`g['OPT']`
1.1       pearu     110: sysconfig._init_posix = my_init_posix
                    111: 
1.16      pearu     112: #+++++++++++++++++ PyGiNaC version ++++++++++++++
                    113: 
                    114: major_version = 0
1.23      pearu     115: minor_version = 2
1.16      pearu     116: try: execfile(os.path.join('tools','get_revision.py'))
                    117: except: revision_version = 0
                    118: version='%d.%d.%d'%(major_version,minor_version,revision_version)
                    119: 
                    120: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
1.1       pearu     121: 
1.5       pearu     122: ginac_cpp = os.path.join('src','_ginac.cpp')
                    123: 
1.24    ! pearu     124: cppsrc = [os.path.join('wrappers','ginac_enhancements.cpp'),
        !           125:           ginac_cpp]
        !           126: 
1.23      pearu     127: wrapper_dir = 'wrappers'
                    128: if gendoc:
                    129:     execfile(os.path.join(wrapper_dir,'build.py'))
                    130:     build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=1,
                    131:                     vers=version,credits=__credits__)
                    132:     if len(sys.argv)==1:
                    133:         print "PyGiNaC Version",version
                    134:         sys.exit()
1.16      pearu     135: if rebuild or not os.path.exists(ginac_cpp):
1.20      pearu     136:     execfile(os.path.join(wrapper_dir,'build.py'))
1.23      pearu     137:     build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=0,
                    138:                     vers=version,credits=__credits__)
1.4       pearu     139: 
1.15      pearu     140: ginac_ext = Extension('ginac._ginac',
1.6       pearu     141:                       sources=cppsrc+bpl_src,
                    142:                       include_dirs=[boost_dir],
                    143:                       libraries=['ginac','cln'],
                    144:                       library_dirs=[],
1.21      pearu     145:                       define_macros=[
                    146: #    ('DEBUG_PYGINAC', None),
                    147:     ],
                    148:                       )
1.1       pearu     149: 
                    150: #++++++++++++++++++++ setup +++++++++++++++++++++
                    151: 
                    152: setup (name = "PyGiNaC",
1.15      pearu     153:        version = version,
                    154:        description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
1.1       pearu     155:        author = "Pearu Peterson",
                    156:        author_email = "pearu@cens.ioc.ee",
1.16      pearu     157:        maintainer = "Pearu Peterson",
                    158:        maintainer_email = "pearu@cens.ioc.ee",
1.1       pearu     159:        licence = "LGPL",
1.15      pearu     160:        long_description= """
                    161: GiNaC is an open framework for symbolic computation within the C++
                    162: programming language (http://www.ginac.de/).
                    163: PyGiNaC is a Python package that provides a transparent interface
                    164: to GiNaC library. Currently the following GiNaC classes are exposed:
                    165:   ex, symbol, numeric, constant, relational, add, mul, power, ncmul,
1.22      pearu     166:   matrix, pseries, function, idx, varidx, tensor, indexed,
1.16      pearu     167:   lst, exvector, expair, exlist, epvector, etc.
1.15      pearu     168: In addition, PyGiNaC provides wrappers for various elementary functions,
1.16      pearu     169: such as sin, factorial, etc.
1.15      pearu     170: """,
                    171:        url = "http://cens.ioc.ee/projects/pyginac/",
1.1       pearu     172:        ext_modules = [ ginac_ext ],
1.23      pearu     173:        packages = ['ginac','ginac.doc'],
                    174:        package_dir = {'ginac': 'lib',
                    175:                       'ginac.doc':os.path.join('lib','doc') },
1.1       pearu     176:        )
1.15      pearu     177: 
                    178: print "PyGiNaC Version",version

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