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

1.1       pearu       1: #!/usr/bin/env python
1.15      pearu       2: #
                      3: #   Setup file for building/installing PyGiNaC
                      4: #
                      5: # Requirements:
1.28      pearu       6: #   Python 2.1 or higher (http://www.python.org/)
                      7: #   GiNaC 0.8.1 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.28      pearu      13: #   > python setup.py install  # this will build and install ginac
                     14: #   > python setup.py test -v  # this will run doctests.
1.15      pearu      15: #
1.28      pearu      16: # In Python `import ginac'. See doc/ginac.doc.html for examples.
                     17: # See GiNaC documentation (http://www.ginac.de/tutorial/) for
                     18: # capabilities and limitations.
1.15      pearu      19: #
                     20: # Pearu Peterson <pearu@cens.ioc.ee>
1.28      pearu      21: # 26 April 2001
1.23      pearu      22: 
1.28      pearu      23: import sys,os
1.1       pearu      24: 
1.25      pearu      25: gentest = 0
                     26: if 'test' in sys.argv:
                     27:     i = sys.argv.index('test')
                     28:     gentest = 1
                     29:     if len(sys.argv)>i+1 and sys.argv[i+1]=='-v':
                     30:         gentest = 2
                     31:         del sys.argv[i+1]
                     32:     del sys.argv[i]
1.28      pearu      33: 
1.1       pearu      34: #++++++++++++++++++++ boost +++++++++++++++++++++
1.14      pearu      35: 
1.28      pearu      36: boost_dir = 'boost'
1.14      pearu      37: bpl_dir = os.path.join(boost_dir,'libs','python','src')
1.1       pearu      38: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
                     39:               ['classes.cpp','conversions.cpp','extension_class.cpp',
                     40:                'functions.cpp','init_function.cpp','module_builder.cpp',
                     41:                'objects.cpp','types.cpp'])
                     42: 
                     43: #++++++++++++++++++++++++++++++++++++++++++++++++
                     44: from distutils.core import setup, Extension
                     45: 
1.15      pearu      46: #+++HACK: replace linker gcc with g++ +++++++++++
1.28      pearu      47: 
1.1       pearu      48: from distutils import sysconfig
                     49: save_init_posix = sysconfig._init_posix
                     50: def my_init_posix():
                     51:     save_init_posix()
                     52:     g = sysconfig._config_vars
1.3       pearu      53:     if g['LDSHARED'][:3]=='gcc':
                     54:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
                     55:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
                     56:         print 'to',`g['LDSHARED']`
1.1       pearu      57: sysconfig._init_posix = my_init_posix
                     58: 
1.16      pearu      59: #+++++++++++++++++ PyGiNaC version ++++++++++++++
                     60: 
1.28      pearu      61: wrapper_dir = 'wrappers3'
                     62: lib_dir = 'lib3'
                     63: 
1.16      pearu      64: major_version = 0
1.28      pearu      65: minor_version = 4
1.16      pearu      66: try: execfile(os.path.join('tools','get_revision.py'))
                     67: except: revision_version = 0
                     68: version='%d.%d.%d'%(major_version,minor_version,revision_version)
                     69: 
                     70: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
1.1       pearu      71: 
1.28      pearu      72: ex_src = [
                     73:     os.path.join(wrapper_dir,'ginac_enhancements.cpp'),
                     74:     os.path.join(wrapper_dir,'ex_py.cpp'),
                     75:     os.path.join(wrapper_dir,'python_repr.cpp'),
                     76:     os.path.join(wrapper_dir,'python_str.cpp'),
1.29    ! pearu      77:     os.path.join(wrapper_dir,'python_csrc.cpp'),
1.28      pearu      78:     os.path.join(wrapper_dir,'pyfunc.cpp'),
                     79:     os.path.join(wrapper_dir,'slice.c'),
                     80:     ]
1.25      pearu      81: 
                     82: if gentest:
1.28      pearu      83:     fon = os.path.join(lib_dir,'doc','__init__.py')
1.25      pearu      84:     if gentest==2:
1.28      pearu      85:         os.system('%s %s -v'%(sys.executable,fon))
                     86:     elif gentest==1:
                     87:         os.system('%s %s'%(sys.executable,fon))
1.25      pearu      88: 
                     89: if len(sys.argv)==1:
                     90:     print "PyGiNaC Version",version
                     91:     sys.exit()
1.4       pearu      92: 
1.15      pearu      93: ginac_ext = Extension('ginac._ginac',
1.28      pearu      94:                       sources=ex_src+bpl_src,
1.25      pearu      95:                       include_dirs=[boost_dir,wrapper_dir],
1.6       pearu      96:                       libraries=['ginac','cln'],
1.28      pearu      97: # Add here the paths to the location
                     98: # of ginac and cln libraries:
                     99:                       library_dirs=[], 
1.21      pearu     100:                       )
1.1       pearu     101: 
                    102: #++++++++++++++++++++ setup +++++++++++++++++++++
                    103: 
                    104: setup (name = "PyGiNaC",
1.15      pearu     105:        version = version,
1.28      pearu     106:        description = "PyGiNaC --- Python Interface to GiNaC",
1.1       pearu     107:        author = "Pearu Peterson",
                    108:        author_email = "pearu@cens.ioc.ee",
1.16      pearu     109:        maintainer = "Pearu Peterson",
                    110:        maintainer_email = "pearu@cens.ioc.ee",
1.1       pearu     111:        licence = "LGPL",
1.15      pearu     112:        long_description= """
                    113: GiNaC is an open framework for symbolic computation within the C++
                    114: programming language (http://www.ginac.de/).
1.28      pearu     115: PyGiNaC is a Python extension package that provides
                    116: an interface to the GiNaC library.
1.15      pearu     117: """,
                    118:        url = "http://cens.ioc.ee/projects/pyginac/",
1.1       pearu     119:        ext_modules = [ ginac_ext ],
1.23      pearu     120:        packages = ['ginac','ginac.doc'],
1.28      pearu     121:        package_dir = {'ginac': lib_dir,
                    122:                       'ginac.doc':os.path.join(lib_dir,'doc') },
1.1       pearu     123:        )
1.15      pearu     124: 
                    125: print "PyGiNaC Version",version

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