Fixed building / installation of Python module in Windows

This commit is contained in:
Ray Speth 2011-12-14 19:34:53 +00:00
parent 508b71fecd
commit 49ee5391e0
4 changed files with 22 additions and 22 deletions

View file

@ -6,6 +6,8 @@ localenv = env.Clone()
lib = localenv.SharedLibrary(pjoin('../../lib', 'clib'),
source=mglob(localenv, 'src', 'cpp'),
LIBS=env['cantera_libs'])
env['clib_shared'] = lib
inst = localenv.Install('$ct_libdir', lib)
buildTargets.extend(lib)
installTargets.extend(inst)

View file

@ -23,24 +23,28 @@ if env['python_package'] == 'full':
SHLIBSUFFIX=gcv('SO'))
buildTargets.extend(pymodule)
localenv.Depends(pymodule, make_setup)
if localenv['OS'] == 'Windows':
for file in localenv['clib_shared']:
dest = pjoin('Cantera', 'python', 'Cantera', file.name)
localenv.AddPreAction(pymodule,Copy(dest, file))
elif env['python_package'] == 'minimal':
pymodule = make_setup
localenv.AddPostAction(make_setup, 'cd Cantera/python; $python_cmd setup.py build')
moddir = pjoin('Cantera', 'python')
localenv.AddPostAction(make_setup,
'cd %s && $python_cmd setup.py build' % moddir)
# Install the Python module
if env['cantera_python_home'] is None:
if env['python_prefix']:
# A specific location for the Cantera python module has been specified
extra = '--prefix="%s"' % env['python_prefix']
else:
# 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)
'cd %s && $python_cmd setup.py install %s' % (moddir,extra))
installTargets.extend(inst)
if env['python_package'] == 'full':

View file

@ -1,13 +1,10 @@
import sys
import string
from distutils.core import setup, Extension
from distutils.sysconfig import get_config_var
import os
platform = sys.platform
# values:
# 0 do nothing
# 1 install only ctml_writer.py
# 2 install full package
dataFiles = ['_cantera%s' % get_config_var('SO')]
if os.name == 'nt':
dataFiles.append('clib.dll')
if '@python_package@' == 'full':
setup(name="Cantera",
@ -21,7 +18,7 @@ if '@python_package@' == 'full':
package_dir = {'MixMaster':'../../apps/MixMaster'},
packages = ["","Cantera","Cantera.OneD",
"MixMaster","MixMaster.Units"],
package_data = {'Cantera': ['_cantera.so']})
package_data = {'Cantera': dataFiles})
elif '@python_package@' == 'minimal':
setup(name="Cantera CTI File Processor",
version="@cantera_version@",

View file

@ -118,7 +118,7 @@ opts.AddVariables(
the home directory for numpy.""",
'', PathVariable.PathAccept),
PathVariable(
'cantera_python_home',
'python_prefix',
"""If you want to install the Cantera Python package somewhere
other than the default 'site-packages' directory within the
Python library directory, then set this to the desired
@ -482,9 +482,6 @@ env['HAS_MATH_H_ERF'] = conf.CheckDeclaration('erf', '#include <math.h>', 'C++')
env['HAS_BOOST_MATH'] = conf.CheckCXXHeader('boost/math/special_functions/erf.hpp', '<>')
env = conf.Finish()
if env['cantera_python_home'] == '' and env['prefix'] != defaults.prefix:
env['cantera_python_home'] = env['prefix']
if env['python_package'] in ('full','default'):
# Test to see if we can import the specified array module
warnNoPython = False