mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[SCons] Link Python module to Cantera shared library
This commit is contained in:
parent
5ae4847239
commit
8114f2f828
1
.github/workflows/main.yml
vendored
1
.github/workflows/main.yml
vendored
@ -384,6 +384,7 @@ jobs:
|
||||
- name: Run the examples
|
||||
# See https://unix.stackexchange.com/a/392973 for an explanation of the -exec part
|
||||
run: |
|
||||
export LD_LIBRARY_PATH=build/lib
|
||||
find samples/python -type f -iname "*.py" \
|
||||
-exec sh -c 'for n; do echo "$n" | tee -a results.txt && python3 "$n" >> results.txt || exit 1; done' sh {} +
|
||||
env:
|
||||
|
@ -2087,6 +2087,9 @@ else:
|
||||
for loc in locations:
|
||||
env[f"inst_{loc}"] = env[f"ct_{loc}"].replace(env["ct_installroot"], instRoot)
|
||||
|
||||
if env['use_rpath_linkage']:
|
||||
env.Append(RPATH=env['ct_libdir'])
|
||||
|
||||
# **************************************
|
||||
# *** Set options needed in config.h ***
|
||||
# **************************************
|
||||
|
@ -8,6 +8,12 @@ Import('env', 'build', 'install')
|
||||
|
||||
localenv = env.Clone()
|
||||
|
||||
# Add build/lib in order to find Cantera shared library
|
||||
if env['OS'] == 'Darwin':
|
||||
localenv.PrependENVPath('DYLD_LIBRARY_PATH', Dir('#build/lib').abspath)
|
||||
else:
|
||||
localenv.PrependENVPath('LD_LIBRARY_PATH', Dir('#build/lib').abspath)
|
||||
|
||||
Page = namedtuple('Page', ['name', 'title', 'objects'])
|
||||
|
||||
|
||||
|
@ -45,6 +45,11 @@ for pyxfile in multi_glob(localenv, "cantera", "pyx"):
|
||||
cython_obj.append(obj)
|
||||
cython_obj.extend(env['python_ext_objects'])
|
||||
|
||||
if not env['system_fmt']:
|
||||
# Workaround until we can figure out why all the necessary symbols aren't
|
||||
# being exported from fmt
|
||||
cython_obj.extend(localenv['fmt_targets'])
|
||||
|
||||
module_ext = localenv["py_module_ext"]
|
||||
ext = localenv.LoadableModule(f"cantera/_cantera{module_ext}",
|
||||
cython_obj, LIBPREFIX="", SHLIBSUFFIX=module_ext,
|
||||
@ -62,7 +67,16 @@ env['python_extension'] = ext
|
||||
localenv.Depends(mod, [ext, dataFiles, setup_cfg, readme, license,
|
||||
"setup.py", "pyproject.toml",
|
||||
"cantera/test/README.txt", "cantera/examples/README.txt"])
|
||||
localenv.Depends(ext, localenv['cantera_staticlib'])
|
||||
|
||||
if env['OS'] == 'Windows':
|
||||
# On Windows, the cantera library directory is likely not to be on the path.
|
||||
# However, Windows does search the directory containing a library (i.e. the
|
||||
# Python extension module) for DLL dependencies.
|
||||
dll = [f for f in localenv['cantera_shlib'] if f.name.endswith('.dll')][0]
|
||||
copy_dll = localenv.Command(f'cantera/{dll.name}', dll, Copy("$TARGET", "$SOURCE"))
|
||||
localenv.Depends(ext, copy_dll)
|
||||
else:
|
||||
localenv.Depends(ext, localenv['cantera_shlib'])
|
||||
|
||||
for f in (multi_glob(localenv, 'cantera', 'py') +
|
||||
multi_glob(localenv, 'cantera/*', 'py')):
|
||||
|
@ -51,7 +51,7 @@ packages =
|
||||
# The module extension needs to be here since we don't want setuptools to compile
|
||||
# the extension, so there are no ``source`` files in the setup.py ``extension`` and
|
||||
# we have to treat the module as package data.
|
||||
cantera = *.pxd, *@py_module_ext@, test/*.txt, examples/*.txt, data/*.*
|
||||
cantera = *.pxd, *.dll, *@py_module_ext@, test/*.txt, examples/*.txt, data/*.*
|
||||
|
||||
[options.extras_require]
|
||||
hdf5 = h5py
|
||||
|
@ -1285,7 +1285,7 @@ def setup_python_env(env):
|
||||
plat = info['plat'].replace('-', '_').replace('.', '_')
|
||||
numpy_include = info["numpy_include"]
|
||||
env.Prepend(CPPPATH=[Dir('#include'), inc, numpy_include])
|
||||
env.Prepend(LIBS=env['cantera_libs'])
|
||||
env.Prepend(LIBS=env['cantera_shared_libs'])
|
||||
|
||||
# Fix the module extension for Windows from the sysconfig library.
|
||||
# See https://github.com/python/cpython/pull/22088 and
|
||||
|
Loading…
Reference in New Issue
Block a user