diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d025f1aa9..024e06c73b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## v0.X Series +### v0.11.32 (2022-07-15) + +Fixes: +* Fixed `ImportError`s during package installation with recent setuptools + by @dweindl in https://github.com/AMICI-dev/AMICI/pull/1830 + ### v0.11.31 (2022-07-12) Fixes: diff --git a/python/amici/__init__.py b/python/amici/__init__.py index 97de3323b7..a57e36c3de 100644 --- a/python/amici/__init__.py +++ b/python/amici/__init__.py @@ -63,6 +63,7 @@ def _imported_from_setup() -> bool: """Check whether this module is imported from `setup.py`""" from inspect import getouterframes, currentframe + from os import sep # in case we are imported from setup.py, this will be the AMICI package # root directory (otherwise it is most likely the Python library directory, @@ -75,7 +76,9 @@ def _imported_from_setup() -> bool: # requires the AMICI extension during its installation, but seems # unlikely... frame_path = os.path.realpath(os.path.expanduser(frame.filename)) - if frame_path == os.path.join(package_root, 'setup.py'): + if (frame_path == os.path.join(package_root, 'setup.py') + or frame_path.endswith(f"{sep}setuptools{sep}build_meta.py") + ): return True return False diff --git a/python/amici/__init__.template.py b/python/amici/__init__.template.py index f8600d8fb6..9fbab85003 100644 --- a/python/amici/__init__.template.py +++ b/python/amici/__init__.template.py @@ -1,12 +1,14 @@ """AMICI-generated module for model TPL_MODELNAME""" import amici +from pathlib import Path # Ensure we are binary-compatible, see #556 if 'TPL_AMICI_VERSION' != amici.__version__: raise amici.AmiciVersionError( - 'Cannot use model `TPL_MODELNAME`, generated with amici==' - f'TPL_AMICI_VERSION, together with amici=={amici.__version__} ' + f'Cannot use model `TPL_MODELNAME` in {Path(__file__).parent}, ' + 'generated with amici==TPL_AMICI_VERSION, ' + f'together with amici=={amici.__version__} ' 'which is currently installed. To use this model, install ' 'amici==TPL_AMICI_VERSION or re-import the model with the amici ' 'version currently installed.' diff --git a/version.txt b/version.txt index 487397bd7b..71c89d3a0d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.11.31 +0.11.32