SCons builds the new Python module with Python 2 and Python 3 simultaneously
This commit is contained in:
parent
0c904bebfa
commit
a0fdaa9f8a
3 changed files with 44 additions and 14 deletions
14
SConstruct
14
SConstruct
|
|
@ -260,7 +260,7 @@ opts.AddVariables(
|
|||
(actually, only one file). The default behavior is to build
|
||||
the Python package if the required prerequisites (numpy) are
|
||||
installed.""",
|
||||
'default', ('full', 'minimal', 'none','default')),
|
||||
'default', ('new', 'full', 'minimal', 'none', 'default')),
|
||||
PathVariable(
|
||||
'python_cmd',
|
||||
"""Cantera needs to know where to find the Python interpreter. If
|
||||
|
|
@ -769,7 +769,7 @@ env = conf.Finish()
|
|||
|
||||
|
||||
# Python 2 Package Settings
|
||||
if env['python_package'] in ('full','default'):
|
||||
if env['python_package'] in ('full','default','new'):
|
||||
# Test to see if we can import the specified array module
|
||||
warnNoPython = False
|
||||
if env['python_array_home']:
|
||||
|
|
@ -783,9 +783,10 @@ if env['python_package'] in ('full','default'):
|
|||
env['python_array_include'] = ''
|
||||
|
||||
print """INFO: Building the full Python package using %s.""" % env['python_array']
|
||||
env['python_package'] = 'full'
|
||||
if env['python_package'] == 'default':
|
||||
env['python_package'] = 'full'
|
||||
except ImportError:
|
||||
if env['python_package'] == 'full':
|
||||
if env['python_package'] in ('full', 'new'):
|
||||
print ("""ERROR: Unable to find the array package """
|
||||
"""'%s' required by the full Python package.""" % env['python_array'])
|
||||
sys.exit(1)
|
||||
|
|
@ -1205,9 +1206,8 @@ if env['python_package'] in ('full','minimal'):
|
|||
VariantDir('build/src/python', 'src/python', duplicate=0)
|
||||
SConscript('build/src/python/SConscript')
|
||||
|
||||
if env['python3_package'] == 'y':
|
||||
VariantDir('build/python3', 'interfaces/cython', duplicate=0)
|
||||
SConscript('build/cython/SConscript')
|
||||
if env['python3_package'] == 'y' or env['python_package'] == 'new':
|
||||
SConscript('interfaces/cython/SConscript')
|
||||
|
||||
SConscript('build/src/apps/SConscript')
|
||||
|
||||
|
|
|
|||
3
interfaces/cython/.gitignore
vendored
3
interfaces/cython/.gitignore
vendored
|
|
@ -2,4 +2,5 @@ cantera/*.cpp
|
|||
cantera/*.c
|
||||
cantera/data/*.cti
|
||||
cantera/data/*.xml
|
||||
setup.py
|
||||
setup2.py
|
||||
setup3.py
|
||||
|
|
|
|||
|
|
@ -26,24 +26,53 @@ if localenv['python3_package'] == 'y':
|
|||
"print(get_config_var('SO'))",
|
||||
"print(numpy.get_include())")))
|
||||
|
||||
module_extension, localenv['python3_array_include'] = info.split('\n')
|
||||
module_ext, numpy_include = info.split('\n')
|
||||
|
||||
incDirs = (".", "../../include", localenv['python3_array_include'],
|
||||
incDirs = (".", "../../include", numpy_include,
|
||||
localenv['sundials_include'], localenv['boost_inc_dir'])
|
||||
localenv['py_include_dirs'] = repr([x for x in incDirs if x])
|
||||
|
||||
|
||||
make_setup = localenv.SubstFile('#interfaces/cython/setup.py',
|
||||
make_setup = localenv.SubstFile('#interfaces/cython/setup3.py',
|
||||
'#interfaces/cython/setup.py.in')
|
||||
build(make_setup)
|
||||
|
||||
opts = '--build-lib=../../build/python3 --build-temp=../../build/temp'
|
||||
mod = build(localenv.Command('cantera/_cantera%s' % module_extension,
|
||||
'setup.py',
|
||||
mod = build(localenv.Command('#build/python3/cantera/_cantera%s' % module_ext,
|
||||
'setup3.py',
|
||||
'cd interfaces/cython && '
|
||||
'$python3_cmd $SOURCE.name build %s' % opts))
|
||||
|
||||
localenv.AddPreAction(mod, Delete('interfaces/cython/cantera/_cantera.cpp'))
|
||||
|
||||
localenv.Depends(mod, localenv['cantera_staticlib'])
|
||||
for f in mglob(localenv, 'cantera', 'pyx', 'pxd'):
|
||||
localenv.Depends(mod, f)
|
||||
|
||||
if localenv['python_package'] == 'new':
|
||||
info = getCommandOutput(localenv['python_cmd'], '-c',
|
||||
'\n'.join(("from distutils.sysconfig import *",
|
||||
"import numpy",
|
||||
"print get_config_var('SO')",
|
||||
"print numpy.get_include()")))
|
||||
|
||||
module_ext, numpy_include = info.split('\n')
|
||||
|
||||
incDirs = (".", "../../include", numpy_include,
|
||||
localenv['sundials_include'], localenv['boost_inc_dir'])
|
||||
localenv['py_include_dirs'] = repr([x for x in incDirs if x])
|
||||
|
||||
make_setup = localenv.SubstFile('#interfaces/cython/setup2.py',
|
||||
'#interfaces/cython/setup.py.in')
|
||||
build(make_setup)
|
||||
|
||||
opts = '--build-lib=../../build/python2 --build-temp=../../build/temp'
|
||||
mod = build(localenv.Command('#build/python2/cantera/_cantera%s' % module_ext,
|
||||
'setup2.py',
|
||||
'cd interfaces/cython && '
|
||||
'$python_cmd $SOURCE.name build %s' % opts))
|
||||
|
||||
localenv.AddPreAction(mod, Delete('interfaces/cython/cantera/_cantera.cpp'))
|
||||
|
||||
localenv.Depends(mod, localenv['cantera_staticlib'])
|
||||
for f in mglob(localenv, 'cantera', 'pyx', 'pxd'):
|
||||
localenv.Depends(mod, f)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue