Skip to content

Commit

Permalink
Fix unused pysb2amici / sbml2amici / DEExporter compiler argument
Browse files Browse the repository at this point in the history
This was ignored since switching to CMake-based builds.
Now it works again. The value of `compiler` is forwarded
to the `CXX` environment variable when CMake is invoked.

Fixes #2140
  • Loading branch information
dweindl committed Aug 30, 2023
1 parent 7d161a6 commit cdc7786
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
16 changes: 10 additions & 6 deletions python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,8 @@ class DEExporter:
due to numerical errors
:ivar compiler:
distutils/setuptools compiler selection to build the Python extension
Absolute path to the compiler executable to be used to build the Python
extension, e.g. ``/usr/bin/clang``.
:ivar functions:
carries C++ function signatures and other specifications
Expand Down Expand Up @@ -2755,8 +2756,8 @@ def __init__(
used to avoid problems with state variables that may become
negative due to numerical errors
:param compiler: distutils/setuptools compiler selection to build the
python extension
:param compiler: Absolute path to the compiler executable to be used
to build the Python extension, e.g. ``/usr/bin/clang``.
:param allow_reinit_fixpar_initcond:
see :class:`amici.de_export.DEExporter`
Expand Down Expand Up @@ -2876,8 +2877,8 @@ def _compile_c_code(
Make model compilation verbose
:param compiler:
distutils/setuptools compiler selection to build the python
extension
Absolute path to the compiler executable to be used to build the Python
extension, e.g. ``/usr/bin/clang``.
"""
# setup.py assumes it is run from within the model directory
module_dir = self.model_path
Expand All @@ -2900,8 +2901,10 @@ def _compile_c_code(
]
)

env = os.environ.copy()
if compiler is not None:
script_args.extend([f"--compiler={compiler}"])
# CMake will use the compiler specified in the CXX environment variable
env["CXX"] = compiler

Check warning on line 2907 in python/sdist/amici/de_export.py

View check run for this annotation

Codecov / codecov/patch

python/sdist/amici/de_export.py#L2907

Added line #L2907 was not covered by tests

# distutils.core.run_setup looks nicer, but does not let us check the
# result easily
Expand All @@ -2912,6 +2915,7 @@ def _compile_c_code(
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
check=True,
env=env,
)
except subprocess.CalledProcessError as e:
print(e.output.decode("utf-8"))
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/pysb_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ def pysb2amici(
errors
:param compiler:
distutils/setuptools compiler selection to build the python
extension
Absolute path to the compiler executable to be used to build the Python
extension, e.g. ``/usr/bin/clang``.
:param compute_conservation_laws:
if set to ``True``, conservation laws are automatically computed and
Expand Down
4 changes: 2 additions & 2 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ def sbml2amici(
negative due to numerical errors
:param compiler:
distutils/setuptools compiler selection to build the
python extension
Absolute path to the compiler executable to be used to build the Python
extension, e.g. ``/usr/bin/clang``.
:param allow_reinit_fixpar_initcond:
see :class:`amici.de_export.ODEExporter`
Expand Down

0 comments on commit cdc7786

Please sign in to comment.