-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fixed a bug with locking packages with non canonical names #6057
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a bug with locking projects that contains packages with non canonical names from private indexes |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
from pipenv.patched.pip._internal.req.req_install import InstallRequirement | ||
from pipenv.patched.pip._internal.utils.temp_dir import global_tempdir_manager | ||
from pipenv.patched.pip._vendor import pkg_resources, rich | ||
from pipenv.patched.pip._vendor.packaging.utils import canonicalize_name | ||
from pipenv.project import Project | ||
from pipenv.utils.fileutils import create_tracked_tempdir | ||
from pipenv.utils.requirements import normalize_name | ||
|
@@ -200,6 +201,7 @@ def create( | |
for package_name, dep in deps.items(): # Build up the index and markers lookups | ||
if not dep: | ||
continue | ||
canonical_package_name = canonicalize_name(package_name) | ||
is_constraint = True | ||
install_req, _ = expansive_install_req_from_line(dep, expand_env=True) | ||
original_deps[package_name] = dep | ||
|
@@ -210,14 +212,18 @@ def create( | |
pipfile_entries[package_name] = pipfile_entry | ||
if isinstance(pipfile_entry, dict): | ||
if packages[package_name].get("index"): | ||
index_lookup[package_name] = packages[package_name].get("index") | ||
index_lookup[canonical_package_name] = packages[package_name].get( | ||
"index" | ||
) | ||
if packages[package_name].get("skip_resolver"): | ||
is_constraint = False | ||
skipped[package_name] = dep | ||
elif index: | ||
index_lookup[package_name] = index | ||
index_lookup[canonical_package_name] = index | ||
else: | ||
index_lookup[package_name] = project.get_default_index()["name"] | ||
index_lookup[canonical_package_name] = project.get_default_index()[ | ||
"name" | ||
] | ||
if install_req.markers: | ||
markers_lookup[package_name] = install_req.markers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should use everywhere canonical_package_name instead of raw_package_name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah you are right, I wish this is something I hadn't broke, but I think your patch makes sense as an iteration in the right direction. I will think more about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we apply my patch? P.S. I sent it because at my team we have some issues with pipenv. And we can't migrate to the freshest version (we still use pretty old one) |
||
if is_constraint: | ||
|
@@ -546,9 +552,13 @@ def collect_hashes(self, ireq): | |
return set() | ||
|
||
sources = self.sources # Enforce index restrictions | ||
if ireq.name in self.index_lookup: | ||
canonical_ireq_name = canonicalize_name(ireq.name) | ||
if canonical_ireq_name in self.index_lookup: | ||
sources = list( | ||
filter(lambda s: s.get("name") == self.index_lookup[ireq.name], sources) | ||
filter( | ||
lambda s: s.get("name") == self.index_lookup[canonical_ireq_name], | ||
sources, | ||
) | ||
) | ||
source = sources[0] if len(sources) else None | ||
if source: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of vie we should use canonicalize_name funiction from pip instead of normalize_name function everywhere.
WDYT?