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

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/)
                     11: #
                     12: # Usage:
                     13: #   > python setup.py install
                     14: #
1.16      pearu      15: # In Python `import ginac'. Module `ginac' contains number of extension classes.
                     16: # About their usage, see GiNaC docs (http://www.ginac.de/tutorial/)
                     17: #
1.15      pearu      18: # Note:
1.16      pearu      19: #   Compilation of PyGiNaC requires more than 160MB memory (with gcc
                     20: #   on Intel Linux). However, if you don't need all the GiNaC classes
                     21: #   to be exposed to Python, you can edit the list `wrap_input' below
                     22: #   to indicate your needs, this will decrease also the memory consumption
                     23: #   during the compilation. You don't need to worry about class dependencies
                     24: #   they are solved automatically. After you edit `wrap_input', run
                     25: #  > python setup.py reinstall
1.15      pearu      26: #
                     27: # Pearu Peterson <pearu@cens.ioc.ee>
                     28: # 30 March 2001
1.1       pearu      29: 
                     30: import sys,os,string,time
                     31: 
1.14      pearu      32: #++++++++++++++ Require Python 2.x +++++++++++++
                     33: 
1.1       pearu      34: if eval(sys.version[0])<2:
                     35:     print "You'll need Python 2.0 or higher to build PyGiNaC"
                     36:     sys.exit()
                     37: 
1.16      pearu      38: #++++++++++++++ Rebuild ++++++++++++++++++++++++
                     39: rebuild = 0
                     40: 
                     41: if 'rebuild' in sys.argv:
                     42:     sys.argv[sys.argv.index('rebuild')] = 'build'
                     43:     rebuild = 1
                     44: if 'reinstall' in sys.argv:
                     45:     sys.argv[sys.argv.index('reinstall')] = 'install'
                     46:     rebuild = 1
                     47: 
                     48: wrap_input = ['symbol','numeric','constant','relational',
                     49:               'lst','idx','varidx','power','add','mul',
                     50:               'ncmul','pseries','matrix','function','inifcns',
1.19    ! pearu      51:               'function','flags','exvector']
        !            52: if 0: # optional
        !            53:     wrap_input += ['expair','epvector']
        !            54: 
1.17      pearu      55: wrap_input = ['function','inifcns']
1.19    ! pearu      56: wrap_input = ['mul','symbol']
1.16      pearu      57: 
1.19    ! pearu      58: #+++++++++++++++++ Do not edit ++++++++++++++++++
        !            59: wrap_input.append('tostring')
1.1       pearu      60: #++++++++++++++++++++ boost +++++++++++++++++++++
1.14      pearu      61: 
1.3       pearu      62: boost_dir = '/usr/local/share/boost'
                     63: 
1.14      pearu      64: if not os.path.isdir(boost_dir):
1.15      pearu      65:     print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
                     66:     print 'Get Boost from http://www.boost.org/ and fix its path in setup.py'
1.14      pearu      67:     sys.exit()
                     68: 
                     69: bpl_dir = os.path.join(boost_dir,'libs','python','src')
1.1       pearu      70: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
                     71:               ['classes.cpp','conversions.cpp','extension_class.cpp',
                     72:                'functions.cpp','init_function.cpp','module_builder.cpp',
                     73:                'objects.cpp','types.cpp'])
                     74: 
                     75: #++++++++++++++++++++++++++++++++++++++++++++++++
                     76: from distutils.core import setup, Extension
                     77: 
1.15      pearu      78: #+++HACK: replace linker gcc with g++ +++++++++++
1.1       pearu      79: from distutils import sysconfig
                     80: save_init_posix = sysconfig._init_posix
                     81: def my_init_posix():
                     82:     save_init_posix()
                     83:     g = sysconfig._config_vars
1.3       pearu      84:     if g['LDSHARED'][:3]=='gcc':
                     85:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
                     86:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
                     87:         print 'to',`g['LDSHARED']`
1.1       pearu      88: sysconfig._init_posix = my_init_posix
                     89: 
1.16      pearu      90: #+++++++++++++++++ PyGiNaC version ++++++++++++++
                     91: 
                     92: major_version = 0
                     93: minor_version = 0
                     94: try: execfile(os.path.join('tools','get_revision.py'))
                     95: except: revision_version = 0
                     96: version='%d.%d.%d'%(major_version,minor_version,revision_version)
                     97: 
                     98: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
1.1       pearu      99: 
1.5       pearu     100: ginac_cpp = os.path.join('src','_ginac.cpp')
                    101: 
                    102: cppsrc = [ginac_cpp]
                    103: 
1.16      pearu     104: if rebuild or not os.path.exists(ginac_cpp):
1.5       pearu     105:     execfile(os.path.join('tools','wrappers','build.py'))
                    106:     wrapper_dir = os.path.join('tools','wrappers')
                    107:     build_ginac_cpp(wrap_input,ginac_cpp)
1.4       pearu     108: 
1.15      pearu     109: ginac_ext = Extension('ginac._ginac',
1.6       pearu     110:                       sources=cppsrc+bpl_src,
                    111:                       include_dirs=[boost_dir],
                    112:                       libraries=['ginac','cln'],
                    113:                       library_dirs=[],
1.19    ! pearu     114: #                      define_macros=[('DEBUG_PYGINAC', None)],
1.2       pearu     115:                      )
1.1       pearu     116: 
                    117: #++++++++++++++++++++ setup +++++++++++++++++++++
                    118: 
                    119: setup (name = "PyGiNaC",
1.15      pearu     120:        version = version,
                    121:        description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
1.1       pearu     122:        author = "Pearu Peterson",
                    123:        author_email = "pearu@cens.ioc.ee",
1.16      pearu     124:        maintainer = "Pearu Peterson",
                    125:        maintainer_email = "pearu@cens.ioc.ee",
1.1       pearu     126:        licence = "LGPL",
1.15      pearu     127:        long_description= """
                    128: GiNaC is an open framework for symbolic computation within the C++
                    129: programming language (http://www.ginac.de/).
                    130: PyGiNaC is a Python package that provides a transparent interface
                    131: to GiNaC library. Currently the following GiNaC classes are exposed:
                    132:   ex, symbol, numeric, constant, relational, add, mul, power, ncmul,
                    133:   matrix, pseries, function, idx, varidx,
1.16      pearu     134:   lst, exvector, expair, exlist, epvector, etc.
1.15      pearu     135: In addition, PyGiNaC provides wrappers for various elementary functions,
1.16      pearu     136: such as sin, factorial, etc.
1.15      pearu     137: """,
                    138:        url = "http://cens.ioc.ee/projects/pyginac/",
1.1       pearu     139:        ext_modules = [ ginac_ext ],
1.15      pearu     140:        packages = ['ginac'],
                    141:        package_dir = {'ginac': 'lib'},
1.1       pearu     142:        )
1.15      pearu     143: 
                    144: print "PyGiNaC Version",version

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