cantera/Cantera/python/SConscript
Ray Speth 79b7686e63 More robust installation of the Python package with SCons
SCons now checks for an array package (numpy by default) and builds
the full Python module if it finds it, otherwise it builds the minimal
package.
2011-12-14 03:53:50 +00:00

53 lines
2 KiB
Python

from buildutils import *
import distutils.sysconfig
Import('env', 'buildTargets', 'installTargets')
localenv = env.Clone()
gcv = distutils.sysconfig.get_config_var
localenv.Append(CPPPATH=[gcv('INCLUDEPY')],
SHLINKFLAGS=gcv('LDFLAGS'),
CPPFLAGS=[gcv('BASECFLAGS'), gcv('OPT')])
make_setup = localenv.SubstFile('setup.py', 'setup.py.in')
if env['python_package'] == 'full':
pymodule = localenv.SharedLibrary('Cantera/_cantera', ['src/pycantera.cpp'],
LIBS=localenv['cantera_libs'],
SHLIBPREFIX='',
SHLIBSUFFIX=gcv('SO'))
buildTargets.extend(pymodule)
localenv.Depends(pymodule, make_setup)
elif env['python_package'] == 'minimal':
pymodule = make_setup
localenv.AddPostAction(make_setup, 'cd Cantera/python; $python_cmd setup.py build')
# Install the Python module
if env['cantera_python_home'] is None:
# Install Python module in the default location
extra = ''
elif env['cantera_python_home'] == env['prefix']:
# Cantera is being installed with a non-default prefix
extra = '--prefix=' + env['prefix']
else:
# A specific location for the Cantera python module has been specified
extra = '--home=' + env['cantera_python_home']
inst = localenv.Command('dummy', pymodule,
'cd Cantera/python; $python_cmd setup.py install %s' % extra)
installTargets.extend(inst)
if env['python_package'] == 'full':
# Copy tutorials
inst = localenv.Install('$ct_tutdir', mglob(localenv, 'tutorial', 'py'))
installTargets.extend(inst)
# Copy examples
exampleFiles = sum([localenv.Glob(pjoin('examples', '*', '*', name))
for name in ['runtest', 'cleanup', '*.txt', '*.py', '*.csv']], [])
for f in exampleFiles:
subdir1, subdir2 = psplit(f.path)[3:5]
installTargets.extend(localenv.Install(pjoin('$ct_demodir','python',subdir1,subdir2), f))