diff --git a/SConstruct b/SConstruct index 54d0dca75..b010a1acd 100644 --- a/SConstruct +++ b/SConstruct @@ -1329,10 +1329,14 @@ def getParentDirs(path, top=True): # Files installed by SCons allfiles = FindInstalledFiles() -# Files installed by the Python installer -pyFiles = 'build/python-installed-files.txt' -if os.path.exists(pyFiles): - allfiles.extend([File(f.strip()) for f in open(pyFiles).readlines()]) +# Files installed by the Python installer(s) +pyFiles = ['build/python-installed-files.txt', + 'build/python2-installed-files.txt', + 'build/python3-installed-files.txt'] + +for filename in pyFiles: + if os.path.exists(filename): + allfiles.extend([File(f.strip()) for f in open(filename).readlines()]) # After removing files (which SCons keeps track of), # remove any empty directories (which SCons doesn't track) diff --git a/interfaces/cython/SConscript b/interfaces/cython/SConscript index 05ac4cf67..801dcaae3 100644 --- a/interfaces/cython/SConscript +++ b/interfaces/cython/SConscript @@ -24,9 +24,10 @@ if localenv['python3_package'] == 'y': '\n'.join(("from distutils.sysconfig import *", "import numpy", "print(get_config_var('SO'))", + "print(get_python_version())", "print(numpy.get_include())"))) - module_ext, numpy_include = info.split('\n') + module_ext, py3_version, numpy_include = info.split('\n') incDirs = (".", "../../include", numpy_include, localenv['sundials_include'], localenv['boost_inc_dir']) @@ -36,11 +37,13 @@ if localenv['python3_package'] == 'y': '#interfaces/cython/setup.py.in') build(make_setup) - opts = '--build-lib=../../build/python3 --build-temp=../../build/temp' + build_cmd = ('cd interfaces/cython &&' + ' $python3_cmd setup3.py build' + ' --build-lib=../../build/python3' + ' --build-temp=../../build/temp-py3') mod = build(localenv.Command('#build/python3/cantera/_cantera%s' % module_ext, 'setup3.py', - 'cd interfaces/cython && ' - '$python3_cmd $SOURCE.name build %s' % opts)) + build_cmd)) localenv.AddPreAction(mod, Delete('interfaces/cython/cantera/_cantera.cpp')) @@ -48,14 +51,35 @@ if localenv['python3_package'] == 'y': for f in mglob(localenv, 'cantera', 'pyx', 'pxd'): localenv.Depends(mod, f) + # Install the Python module + if localenv['python3_prefix']: + # A specific location for the Cantera python module has been specified + extra = '--prefix="%s"' % localenv['python3_prefix'] + else: + # Install Python module in the default location + extra = '' + + if localenv['PYTHON_INSTALLER'] == 'direct': + install(localenv.Command, 'dummy3', mod, + build_cmd + ' install --record ../../build/python3-installed-files.txt %s' % extra) + elif localenv['PYTHON_INSTALLER'] == 'debian': + install(localenv.Command, 'dummy3', mod, + build_cmd + ' install --install-layout=deb --no-compile %s' % extra) + elif localenv['PYTHON_INSTALLER'] == 'binary': + install(localenv.Command, 'dummy3', mod, + build_cmd + ' bdist_msi --dist-dir=../..' + + ' --target-version=%s' + py3_version) + + 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 get_python_version()", "print numpy.get_include()"))) - module_ext, numpy_include = info.split('\n') + module_ext, py2_version, numpy_include = info.split('\n') incDirs = (".", "../../include", numpy_include, localenv['sundials_include'], localenv['boost_inc_dir']) @@ -65,14 +89,36 @@ if localenv['python_package'] == 'new': '#interfaces/cython/setup.py.in') build(make_setup) - opts = '--build-lib=../../build/python2 --build-temp=../../build/temp' + build_cmd = ('cd interfaces/cython &&' + ' $python_cmd setup2.py build' + ' --build-lib=../../build/python2' + ' --build-temp=../../build/temp-py2') + mod = build(localenv.Command('#build/python2/cantera/_cantera%s' % module_ext, 'setup2.py', - 'cd interfaces/cython && ' - '$python_cmd $SOURCE.name build %s' % opts)) + build_cmd)) 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) + + # Install the Python module + if localenv['python_prefix']: + # A specific location for the Cantera python module has been specified + extra = '--prefix="%s"' % localenv['python_prefix'] + else: + # Install Python module in the default location + extra = '' + + if localenv['PYTHON_INSTALLER'] == 'direct': + install(localenv.Command, 'dummy2', mod, + build_cmd + ' install --record ../../build/python2-installed-files.txt %s' % extra) + elif localenv['PYTHON_INSTALLER'] == 'debian': + install(localenv.Command, 'dummy2', mod, + build_cmd + ' install --install-layout=deb --no-compile %s' % extra) + elif localenv['PYTHON_INSTALLER'] == 'binary': + install(localenv.Command, 'dummy2', mod, + build_cmd + ' bdist_msi --dist-dir=../..' + + ' --target-version=%s' % py2_version)