Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pkg_resources with importlib.metadata #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nrn_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
wheel
importlib_metadata
setuptools
setuptools_scm
scikit-build
Expand Down
24 changes: 11 additions & 13 deletions share/lib/python/scripts/_binwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import shutil
import subprocess
import sys
from pkg_resources import working_set
from importlib_metadata import distributions
from setuptools.command.build_ext import new_compiler
from packaging.version import Version
from sysconfig import get_config_vars, get_config_var
Expand Down Expand Up @@ -63,22 +63,20 @@ def _check_cpp_compiler_version():

def _config_exe(exe_name):
"""Sets the environment to run the real executable (returned)"""
NRN_PREFIX = None
package_names = ["neuron", "neuron-nightly"]

package_name = "neuron"
# Search for NEURON package installation location using importlib.metadata
for dist in distributions():
if dist.metadata["Name"] in package_names:
NRN_PREFIX = dist.locate_file("neuron", ".data")
print(f"INFO : Using {dist.metadata['Name']} Package")
break

# determine package to find the install location
if "neuron-nightly" in working_set.by_key:
print("INFO : Using neuron-nightly Package (Developer Version)")
package_name = "neuron-nightly"
elif "neuron" in working_set.by_key:
package_name = "neuron"
else:
if NRN_PREFIX is None:
raise RuntimeError("NEURON package not found! Verify PYTHONPATH")

NRN_PREFIX = os.path.join(
working_set.by_key[package_name].location, "neuron", ".data"
)
os.environ["NEURONHOME"] = os.path.join(NRN_PREFIX, "share/nrn")
os.environ["NEURONHOME"] = os.path.join(NRN_PREFIX, "share", "nrn")
os.environ["NRNHOME"] = NRN_PREFIX
os.environ["CORENRNHOME"] = NRN_PREFIX
os.environ["NRN_PYTHONEXE"] = sys.executable
Expand Down
Loading