-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Python lib issue with sympy solver (#1165)
* Fix for Python sympy solver * Add corresponding test * Update requirements --------- Co-authored-by: Luc Grosheintz <luc.grosheintz@gmail.com>
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,41 @@ | ||
import os | ||
import sys | ||
|
||
if sys.version_info >= (3, 9): | ||
from importlib.resources import files | ||
else: | ||
from importlib_resources import files | ||
|
||
from find_libpython import find_libpython | ||
|
||
# try to add libpython*.so path to environment if not already set | ||
try: | ||
os.environ["NMODL_PYLIB"] = os.environ.get( | ||
"NMODL_PYLIB", | ||
find_libpython(), | ||
) | ||
except TypeError as exc: | ||
raise RuntimeError( | ||
"find_libpython was unable to find the Python library on this platform; " | ||
"please make sure that the Python library is installed correctly\n" | ||
"You can also try to manually set the NMODL_PYLIB environmental variable " | ||
"to the Python library" | ||
) from exc | ||
|
||
# add nmodl home to environment (i.e. necessary for nrnunits.lib) if not | ||
# already set | ||
# `files` will automatically raise a `ModuleNotFoundError` | ||
os.environ["NMODLHOME"] = os.environ.get( | ||
"NMODLHOME", | ||
str(files("nmodl") / ".data"), | ||
) | ||
|
||
|
||
try: | ||
# Try importing but catch exception in case bindings are not available | ||
from ._nmodl import NmodlDriver, to_json, to_nmodl # noqa | ||
from ._nmodl import __version__ | ||
|
||
__all__ = ["NmodlDriver", "to_json", "to_nmodl"] | ||
except ImportError: | ||
print("[NMODL] [warning] :: Python bindings are not available") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ sympy | |
numpy | ||
find_libpython | ||
scikit-build | ||
importlib_resources;python_version<"3.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters