Skip to content

Commit

Permalink
Fix CMake using incorrect Python library for building model extension (
Browse files Browse the repository at this point in the history
…#2220)

This fixes a bug where a model extension would be built for an incorrect Python version. If there is a newer Python version available than the one in use during model import, CMake would incorrectly used the newer version. This results in not so informative errors like:
```
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/model_name/model_name.py", line 12, in <module>
    import _model_name
ModuleNotFoundError: No module named '_model_name'
```

Fixed here by explicitly setting the Python executable that is used to find the matching libraries.
  • Loading branch information
dweindl authored Dec 3, 2023
1 parent 52b1af6 commit a973bc0
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/sdist/amici/setup.template.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""AMICI model package setup"""
import os
import sys
from pathlib import Path

from amici import _get_amici_path
Expand Down Expand Up @@ -33,6 +34,7 @@ def get_extension() -> CMakeExtension:
f"{prefix_path.as_posix()}/lib64/cmake/SuiteSparse",
f"-DKLU_ROOT={prefix_path.as_posix()}",
"-DAMICI_PYTHON_BUILD_EXT_ONLY=ON",
f"-DPython3_EXECUTABLE={Path(sys.executable).as_posix()}",
],
)

Expand Down

0 comments on commit a973bc0

Please sign in to comment.