Skip to content

Commit b9343c3

Browse files
authored
Merge pull request #4118 from smoors/20221102172755_new_pr_LQigyDaYQc
use canonical package names for findPythonDeps.py
2 parents 636eace + b0839ec commit b9343c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

easybuild/scripts/findPythonDeps.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
print('pkg_resources could not be imported: %s\nYou might need to install setuptools!' % e)
1717
sys.exit(1)
1818

19+
try:
20+
from packaging.utils import canonicalize_name
21+
except ImportError:
22+
_canonicalize_regex = re.compile(r"[-_.]+")
23+
24+
def canonicalize_name(name):
25+
return _canonicalize_regex.sub("-", name).lower()
26+
1927

2028
@contextmanager
2129
def temporary_directory(*args, **kwargs):
@@ -87,6 +95,7 @@ def find_deps(pkgs, dep_tree):
8795
"""Recursively resolve dependencies of the given package(s) and return them"""
8896
res = []
8997
for pkg in pkgs:
98+
pkg = canonicalize_name(pkg)
9099
matching_entries = [entry for entry in dep_tree
91100
if pkg in (entry['package']['package_name'], entry['package']['key'])]
92101
if not matching_entries:

0 commit comments

Comments
 (0)