File:  [CENS] / python / pyGiNaC / setup.py
Revision 1.23: download - view: text, annotated - select for diffs - revision graph
Wed Apr 11 20:31:30 2001 UTC (16 years, 7 months ago) by pearu
Branches: MAIN
CVS tags: HEAD
Exposed lots of functions. Documented most important classes/functions. minor_version = 2

#!/usr/bin/env python
#
#   Setup file for building/installing PyGiNaC
#
# Requirements:
#   Python 2.0 or higher (http://www.python.org/)
#   GiNaC 0.8.0 or higher (http://www.ginac.de/)
#     For GiNaC, you'll need CLN 1.1 (http://clisp.cons.org/~haible/packages-cln.html)
#       Optional, but recommended, CLN can use GMP 3.1.1 (http://www.swox.com/gmp/)
#   Boost 1.21.1 or higher (http://www.boost.org/)
#  
# Usage:
#   > python setup.py install
#
# In Python `import ginac'. Module `ginac' extension classes exposing
# almost all GiNaC classes to Python.
# See GiNaC documentation (http://www.ginac.de/tutorial/) for usage.
#
# Notes:
# 1. Compilation of PyGiNaC requires more than 160MB memory (with gcc -O2
#   on Intel Linux). However, if you don't need all the GiNaC classes
#   to be exposed to Python, you can edit the list `wrap_input' below
#   to indicate your needs, this will decrease also the memory consumption
#   during the compilation. You don't need to worry about class dependencies
#   they are solved automatically. After you edit `wrap_input', run
#  > python setup.py reinstall
#
# Pearu Peterson <pearu@cens.ioc.ee>
# 30 March 2001

__credits__ = """\
GiNaC people (www.ginac.de), for the GiNaC library.
Boost.Python people (www.boost.org), for BPL that considerably
simplified the wrapping of GiNaC C++ classes to Python.
"""

import sys,os,string,time

#++++++++++++++ Require Python 2.x +++++++++++++

if eval(sys.version[0])<2:
    print "You'll need Python 2.0 or higher to build PyGiNaC"
    sys.exit()

#++++++++++++++ Rebuild ++++++++++++++++++++++++
rebuild = 0
gendoc = 0
disable_opt = 1 # set 0 for final compilation

if 'doc' in sys.argv:
    del sys.argv[sys.argv.index('doc')]
    gendoc = 1

if 'rebuild' in sys.argv:
    sys.argv[sys.argv.index('rebuild')] = 'build'
    rebuild = 1
if 'reinstall' in sys.argv:
    sys.argv[sys.argv.index('reinstall')] = 'install'
    rebuild = 1

wrap_input = ['symbol','numeric','constant','relational',
              'lst','idx','varidx','power','add','mul',
              'ncmul','pseries','matrix','function','inifcns',
              'function','flags','exvector',
              'indexed','color','clifford','tensor']

#wrap_input = ['function','inifcns']
#wrap_input = ['add','mul','power','lst','pseries','relational','matrix','numeric','constant','symbol','varidx']
#wrap_input = ['symbol','lst','matrix']
#wrap_input = ['symbol','tensor']

#++++++++++++++++ Parameters ++++++++++++++++
nof_lst_params = 10   # max 15 for ginac, max 10 for boost.python, min 1
nof_ncmul_params = 6  # max 6
nof_function_params = 9 # max 13 for ginac, max 9 for boost.python, min 1
#++++++++++++++++++++ boost +++++++++++++++++++++

boost_dir = '/usr/local/share/boost'

if not os.path.isdir(boost_dir):
    print 'boost_dir=%s must be existing directory.'%(`boost_dir`)
    print 'Get Boost from http://www.boost.org/ and fix its path in setup.py'
    sys.exit()

bpl_dir = os.path.join(boost_dir,'libs','python','src')
bpl_src = map(lambda f:os.path.join(bpl_dir,f),
              ['classes.cpp','conversions.cpp','extension_class.cpp',
               'functions.cpp','init_function.cpp','module_builder.cpp',
               'objects.cpp','types.cpp'])

#++++++++++++++++++++++++++++++++++++++++++++++++
from distutils.core import setup, Extension

#+++HACK: replace linker gcc with g++ +++++++++++
from distutils import sysconfig
save_init_posix = sysconfig._init_posix
def my_init_posix():
    save_init_posix()
    g = sysconfig._config_vars
    if g['LDSHARED'][:3]=='gcc':
        print 'my_init_posix: changing LDSHARED =',`g['LDSHARED']`,
        g['LDSHARED'] = 'g++'+g['LDSHARED'][3:]
        print 'to',`g['LDSHARED']`
    if disable_opt and g['OPT'][:6]=='-g -O2':
        print 'my_init_posix: changing OPT =',`g['OPT']`,
        g['OPT'] = '-g'+g['OPT'][6:]
        print 'to',`g['OPT']`
sysconfig._init_posix = my_init_posix

#+++++++++++++++++ PyGiNaC version ++++++++++++++

major_version = 0
minor_version = 2
try: execfile(os.path.join('tools','get_revision.py'))
except: revision_version = 0
version='%d.%d.%d'%(major_version,minor_version,revision_version)

#++++++++++++++++ ginac._ginac +++++++++++++++++++++

ginac_cpp = os.path.join('src','_ginac.cpp')

cppsrc = [ginac_cpp]
wrapper_dir = 'wrappers'
if gendoc:
    execfile(os.path.join(wrapper_dir,'build.py'))
    build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=1,
                    vers=version,credits=__credits__)
    if len(sys.argv)==1:
        print "PyGiNaC Version",version
        sys.exit()
if rebuild or not os.path.exists(ginac_cpp):
    execfile(os.path.join(wrapper_dir,'build.py'))
    build_ginac_cpp(wrap_input,ginac_cpp,wrapper_dir,onlydoc=0,
                    vers=version,credits=__credits__)

ginac_ext = Extension('ginac._ginac',
                      sources=cppsrc+bpl_src,
                      include_dirs=[boost_dir],
                      libraries=['ginac','cln'],
                      library_dirs=[],
                      define_macros=[
#    ('DEBUG_PYGINAC', None),
    ],
                      )

#++++++++++++++++++++ setup +++++++++++++++++++++

setup (name = "PyGiNaC",
       version = version,
       description = "PyGiNaC --- the wrapper of C++ library GiNaC to Python",
       author = "Pearu Peterson",
       author_email = "pearu@cens.ioc.ee",
       maintainer = "Pearu Peterson",
       maintainer_email = "pearu@cens.ioc.ee",
       licence = "LGPL",
       long_description= """
GiNaC is an open framework for symbolic computation within the C++
programming language (http://www.ginac.de/).
PyGiNaC is a Python package that provides a transparent interface
to GiNaC library. Currently the following GiNaC classes are exposed:
  ex, symbol, numeric, constant, relational, add, mul, power, ncmul,
  matrix, pseries, function, idx, varidx, tensor, indexed,
  lst, exvector, expair, exlist, epvector, etc.
In addition, PyGiNaC provides wrappers for various elementary functions,
such as sin, factorial, etc.
""",
       url = "http://cens.ioc.ee/projects/pyginac/",
       ext_modules = [ ginac_ext ],
       packages = ['ginac','ginac.doc'],
       package_dir = {'ginac': 'lib',
                      'ginac.doc':os.path.join('lib','doc') },
       )

print "PyGiNaC Version",version

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