21
21
from pipenv .patched .pip ._vendor .packaging .utils import canonicalize_name
22
22
from pipenv .patched .pip ._vendor .packaging .version import parse as parse_version
23
23
from pipenv .utils import console
24
+ from pipenv .utils .dependencies import normalized_name
24
25
from pipenv .utils .fileutils import normalize_path , temp_path
25
26
from pipenv .utils .funktools import chunked , unnest
26
27
from pipenv .utils .indexes import prepare_pip_source_args
@@ -493,7 +494,7 @@ def get_distributions(self) -> Generator[importlib.metadata.Distribution, None,
493
494
def find_egg (self , egg_dist : importlib .metadata .Distribution ) -> str :
494
495
"""Find an egg by name in the given environment"""
495
496
site_packages = self .libdir [1 ]
496
- search_filename = f"{ egg_dist . name } .egg-link"
497
+ search_filename = f"{ normalized_name ( egg_dist ) } .egg-link"
497
498
try :
498
499
user_site = site .getusersitepackages ()
499
500
except AttributeError :
@@ -528,7 +529,7 @@ def get_installed_packages(self) -> list[importlib.metadata.Distribution]:
528
529
packages = [
529
530
pkg
530
531
for pkg in workingset
531
- if self .dist_is_in_project (pkg ) and pkg . name != "python"
532
+ if self .dist_is_in_project (pkg ) and normalized_name ( pkg ) != "python"
532
533
]
533
534
return packages
534
535
@@ -556,7 +557,8 @@ def get_package_info(
556
557
557
558
with self .get_finder () as finder :
558
559
for dist in packages :
559
- all_candidates = finder .find_all_candidates (dist .name )
560
+ name = normalized_name (dist )
561
+ all_candidates = finder .find_all_candidates (name )
560
562
if not self .pipfile .get ("pre" , finder .allow_all_prereleases ):
561
563
# Remove prereleases
562
564
all_candidates = [
@@ -567,9 +569,7 @@ def get_package_info(
567
569
568
570
if not all_candidates :
569
571
continue
570
- candidate_evaluator = finder .make_candidate_evaluator (
571
- project_name = dist .name
572
- )
572
+ candidate_evaluator = finder .make_candidate_evaluator (project_name = name )
573
573
best_candidate_result = candidate_evaluator .compute_best_candidate (
574
574
all_candidates
575
575
)
@@ -627,7 +627,7 @@ def get_package_requirements(self, pkg=None):
627
627
628
628
packages = self .get_installed_packages ()
629
629
if pkg :
630
- packages = [p for p in packages if p . name == pkg ]
630
+ packages = [p for p in packages if normalized_name ( p ) == pkg ]
631
631
632
632
try :
633
633
tree = PackageDAG .from_pkgs (packages )
@@ -707,14 +707,15 @@ def is_installed(self, pkgname):
707
707
:rtype: bool
708
708
"""
709
709
710
- return any (d for d in self .get_distributions () if d . name == pkgname )
710
+ return any (d for d in self .get_distributions () if normalized_name ( d ) == pkgname )
711
711
712
712
def is_satisfied (self , req : InstallRequirement ):
713
713
match = next (
714
714
iter (
715
715
d
716
716
for d in self .get_distributions ()
717
- if req .name and canonicalize_name (d .name ) == canonicalize_name (req .name )
717
+ if req .name
718
+ and canonicalize_name (normalized_name (d )) == canonicalize_name (req .name )
718
719
),
719
720
None ,
720
721
)
0 commit comments