Use SCons to generate a customized setup.py for the new Python module

This commit is contained in:
Ray Speth 2012-09-06 19:55:34 +00:00
parent 8afc669b67
commit 3a838018fc
3 changed files with 40 additions and 13 deletions

View file

@ -1116,6 +1116,7 @@ if not env['single_library']:
# Add lapack and blas to the link line
if env['blas_lapack_libs']:
linkLibs.extend(env['blas_lapack_libs'])
linkSharedLibs.extend(env['blas_lapack_libs'])
elif not env['single_library']:
linkLibs.extend(('ctlapack', 'ctblas'))
linkSharedLibs.extend(('ctlapack_shared', 'ctblas_shared'))

View file

@ -9,22 +9,22 @@ if os.name == 'nt':
else:
dataFiles.append('libcantera_shared.so')
canteraExtensions = []
exts = []
def addExtension(name):
canteraExtensions.append(Extension("cantera.%s" % name,
["cantera/%s.pyx" % name],
include_dirs=[".", "../../include"],
language="c++",
libraries=['cantera_shared','sundials_cvodes','sundials_idas','sundials_nvecserial','lapack','blas'],
library_dirs=['../../build/lib'],
extra_link_args=['-Wl,-rpath=$ORIGIN']))
exts.append(Extension("cantera.%s" % name,
["cantera/%s.pyx" % name],
include_dirs=@py_include_dirs@,
language="c++",
libraries=@py_cantera_libs@,
library_dirs=@py_libdirs@,
extra_link_args=@py_extra_link_args@))
addExtension('solution')
addExtension('utils')
setup(name="Cantera",
version="2.1a1",
version="@cantera_version@",
description="The Cantera Python Interface",
long_description="""
""",
@ -33,5 +33,5 @@ setup(name="Cantera",
url="http://code.google.com/p/cantera",
packages = ["cantera"],
cmdclass = {'build_ext': build_ext},
ext_modules = canteraExtensions,
ext_modules = exts,
package_data = {'cantera': dataFiles})

View file

@ -3,10 +3,14 @@ import distutils.sysconfig
Import('env', 'build', 'install')
localenv = env.Clone()
gcv = distutils.sysconfig.get_config_var
####################################
### Old Python Module: Raw C API ###
####################################
localenv = env.Clone()
localenv.Append(CPPPATH=[gcv('INCLUDEPY'), env['python_array_include']],
CPPFLAGS=((gcv('BASECFLAGS') or '').split() +
(gcv('OPT') or '').split()),
@ -25,7 +29,6 @@ for var in ('VS80COMNTOOLS', 'VS90COMNTOOLS', 'VS100COMNTOOLS'):
if var in os.environ:
localenv['ENV'][var] = os.environ[var]
localenv['spam_source'] = repr(File('#src/python/spam.c').abspath)
make_setup = localenv.SubstFile('#interfaces/python/setup.py',
'#interfaces/python/setup.py.in')
@ -102,3 +105,26 @@ elif localenv['PYTHON_INSTALLER'] == 'binary':
if localenv['python_package'] == 'full':
install(localenv.RecursiveInstall, pjoin('$inst_sampledir', 'python'),
'#samples/python')
#################################
### New Python Module: Cython ###
#################################
localenv = env.Clone()
incDirs = (".", "../../include", localenv['python_array_include'],
localenv['sundials_include'], localenv['boost_inc_dir'])
libDirs = ('../../build/lib', localenv['sundials_libdir'],
localenv['boost_lib_dir'])
localenv['py_include_dirs'] = repr([x for x in incDirs if x])
localenv['py_cantera_libs'] = repr(localenv['cantera_shared_libs'])
localenv['py_libdirs'] = repr([x for x in libDirs if x])
if localenv['CC'] == 'cl':
localenv['py_extra_link_args'] = repr([])
else:
localenv['py_extra_link_args'] = repr(['-Wl,-rpath=$$ORIGIN'])
make_setup = localenv.SubstFile('#interfaces/cython/setup.py',
'#interfaces/cython/setup.py.in')
build(make_setup)