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

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

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