From 03101e1fbea11365739be0625dc456113e401ec8 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 30 Aug 2023 12:13:18 +0200 Subject: [PATCH] Fix unused pysb2amici / sbml2amici / DEExporter `compiler` argument 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 --- python/sdist/amici/de_export.py | 16 ++++++++++------ python/sdist/amici/pysb_import.py | 4 ++-- python/sdist/amici/sbml_import.py | 4 ++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/python/sdist/amici/de_export.py b/python/sdist/amici/de_export.py index 1b46b5be84..de1b96a1c6 100644 --- a/python/sdist/amici/de_export.py +++ b/python/sdist/amici/de_export.py @@ -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 @@ -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` @@ -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 @@ -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 # distutils.core.run_setup looks nicer, but does not let us check the # result easily @@ -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")) diff --git a/python/sdist/amici/pysb_import.py b/python/sdist/amici/pysb_import.py index 7e413a2a88..0dbba69ddb 100644 --- a/python/sdist/amici/pysb_import.py +++ b/python/sdist/amici/pysb_import.py @@ -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 diff --git a/python/sdist/amici/sbml_import.py b/python/sdist/amici/sbml_import.py index 8c43d35cf2..98313c3d77 100644 --- a/python/sdist/amici/sbml_import.py +++ b/python/sdist/amici/sbml_import.py @@ -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`