Skip to content

Commit

Permalink
Look at all sitepackages
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleknap committed Jan 30, 2024
1 parent bcf9b13 commit 54e21a4
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/dependencies/test_closure.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from packaging.requirements import Requirement

_NESTED_STR_DICT = Dict[str, "_NESTED_STR_DICT"]
_SITE_PACKAGES = site.getsitepackages()[0]


@pytest.fixture()
Expand Down Expand Up @@ -82,13 +81,14 @@ def _get_distribution(self, name: str) -> importlib.metadata.Distribution:
# Packages names may have a "-". These get converted to "_" for
# their respective directory names in the site packages directory.
snake_case_name = name.replace("-", "_")
print(_SITE_PACKAGES)
for filename in os.listdir(_SITE_PACKAGES):
print(filename)
if fnmatch.fnmatch(filename, f"{snake_case_name}-*.dist-info"):
return importlib.metadata.Distribution.at(
os.path.join(_SITE_PACKAGES, filename)
)
for sitepackages in site.getsitepackages():
print(sitepackages)
for filename in os.listdir(sitepackages):
print(filename)
if fnmatch.fnmatch(filename, f"{snake_case_name}-*.dist-info"):
return importlib.metadata.Distribution.at(
os.path.join(sitepackages, filename)
)
raise ValueError(
f'Could not find .dist-info directory for {self.name}'
)
Expand Down

0 comments on commit 54e21a4

Please sign in to comment.