File:  [CENS] / python / pyGiNaC / setup4.py
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Sun Aug 19 12:34:30 2001 UTC (16 years, 3 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Impl. constant

    1: #!/usr/bin/env python
    2: #
    3: #   Setup file for building/installing PyGiNaC
    4: #
    5: # Requirements:
    6: #   See README.txt
    7: #  
    8: # Usage:
    9: #   > python setup4.py install        # build _ginac
   10: #                                     # and install the package.
   11: #   > cd test4 && python test_all.py  # run doctests.
   12: #
   13: # In Python `import ginac'. Module `ginac' extension classes expose
   14: # almost all GiNaC classes to Python.
   15: # See GiNaC documentation (http://www.ginac.de/tutorial/) for usage.
   16: #
   17: # Pearu Peterson <pearu@cens.ioc.ee>
   18: # 30 March 2001
   19: # 23 April 2001
   20: # 11 August 2001
   21: 
   22: __credits__ = """\
   23: GiNaC group (www.ginac.de), for the GiNaC library.
   24: Boost.Python group (www.boost.org), for BPL that considerably
   25: simplified exposure of GiNaC C++ classes to Python.
   26: """
   27: 
   28: import sys,os,string,time
   29: 
   30: __today__ = time.asctime(time.localtime())
   31: __author__ = 'Pearu Peterson <pearu@cens.ioc.ee>'
   32: 
   33: #++++++++++++++ Require Python 2.x +++++++++++++
   34: 
   35: if eval(sys.version[0])<2:
   36:     print "You'll need Python 2.0 or higher to build PyGiNaC"
   37:     sys.exit()
   38: print 'Python Version',sys.version.split()[0]
   39: 
   40: #++++++++++++++ Rebuild ++++++++++++++++++++++++
   41: rebuild = 0
   42: disable_opt = 1 # set 0 for final compilation
   43: 
   44: if 'rebuild' in sys.argv:
   45:     sys.argv[sys.argv.index('rebuild')] = 'build'
   46:     rebuild = 1
   47: if 'reinstall' in sys.argv:
   48:     sys.argv[sys.argv.index('reinstall')] = 'install'
   49:     rebuild = 1
   50: 
   51: #++++++++++++++++++++ boost.python +++++++++++++++++++++
   52: 
   53: boost_dir = '/usr/local/share/boost'
   54: boost_dir = 'boost'
   55: 
   56: if not os.path.isdir(boost_dir):
   57:     print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
   58:     print '  Get Boost from http://www.boost.org/'
   59:     print '  Fix its path in setup4.py'
   60:     sys.exit()
   61: 
   62: bpl_dir = os.path.join(boost_dir,'libs','python','src')
   63: bpl_src = map(lambda f:os.path.join(bpl_dir,f),
   64:               ['classes.cpp',
   65:                'conversions.cpp',
   66:                'extension_class.cpp',
   67:                #'cross_module.cpp',
   68:                'functions.cpp',
   69:                'init_function.cpp',
   70:                'module_builder.cpp',
   71:                'objects.cpp','types.cpp'])
   72: 
   73: #++++++++++++++++++++++++++++++++++++++++++++++++
   74: from distutils.core import setup, Extension
   75: 
   76: #+++HACK: replace linker gcc with g++ +++++++++++
   77: #+++      turn off optimization       +++++++++++
   78: from distutils import sysconfig
   79: save_init_posix = sysconfig._init_posix
   80: def my_init_posix():
   81:     save_init_posix()
   82:     g = sysconfig._config_vars
   83:     if g['LDSHARED'][:3]=='gcc':
   84:         print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
   85:         g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
   86:         print 'to',`g['LDSHARED']`
   87:     if disable_opt and g['OPT'][:6]=='-g -O2':
   88:         print 'my_init_posix: changing OPT =',`g['OPT']`,
   89:         g['OPT'] = '-g'+g['OPT'][6:]
   90:         print 'to',`g['OPT']`
   91: sysconfig._init_posix = my_init_posix
   92: 
   93: #+++++++++++++++++ PyGiNaC version ++++++++++++++
   94: 
   95: edition = 4
   96: wrapper_dir = 'wrappers%d'%edition
   97: lib_dir = 'lib%d'%edition
   98: src_dir = 'src%d'%edition
   99: 
  100: major_version = 0
  101: minor_version = 6
  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: version_info = (major_version,minor_version,revision_version,'proto',edition)
  106: 
  107: print 'Creating %s/__version__.py'%lib_dir
  108: f = open(os.path.join(lib_dir,'__version__.py'),'w')
  109: f.write('__version__ = "%s"\n'%(version))
  110: f.close()
  111: 
  112: #++++++++++++++++ ginac._ginac +++++++++++++++++++++
  113: 
  114: ginac_src = []
  115: for n in ['_ginac.cpp',
  116:           'ginac_enhancements.cpp'
  117:           ]:
  118:     ginac_src.append(os.path.join(wrapper_dir,n))
  119: 
  120: if len(sys.argv)==1:
  121:     print "PyGiNaC Version",version
  122:     sys.exit()
  123: 
  124: if rebuild:
  125:     for n in ['_ginac.cpp']:
  126:         n = os.path.join(wrapper_dir,n)
  127:         print 'touch '+n
  128:         os.system('touch '+n)
  129: 
  130: _ginac_ext = Extension('ginac._ginac',
  131:                       sources=ginac_src+bpl_src,
  132:                       include_dirs=[boost_dir,
  133:                                     wrapper_dir,
  134:                                     #'tools',       # for sstream
  135:                                     ],
  136:                       libraries=['ginac','cln'],
  137:                       library_dirs=[],
  138:                       )
  139: 
  140: #+++++++++++++++ force rebuild ++++++++++++++++++
  141: 
  142: 
  143: #++++++++++++++ extension modules +++++++++++++++
  144: 
  145: ext_modules = [_ginac_ext]
  146: 
  147: #++++++++++++++++++++ setup +++++++++++++++++++++
  148: 
  149: setup (name = "PyGiNaC",
  150:        version = version,
  151:        description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
  152:        author = "Pearu Peterson",
  153:        author_email = "pearu@cens.ioc.ee",
  154:        maintainer = "Pearu Peterson",
  155:        maintainer_email = "pearu@cens.ioc.ee",
  156:        licence = "LGPL",
  157:        long_description= """
  158: GiNaC is an open framework for symbolic computation within the C++
  159: programming language (http://www.ginac.de/).
  160: PyGiNaC is a Python extension package that implements a complete
  161: and transparent interface to the GiNaC library.
  162: """,
  163:        url = "http://cens.ioc.ee/projects/pyginac/",
  164:        ext_modules = ext_modules,
  165:        packages = ['ginac'],
  166:        package_dir = {'ginac': lib_dir},
  167:        )
  168: 
  169: print "PyGiNaC Version",version

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