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

5780: Always reinstall linked packages #5781

Closed
Closed
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
2 changes: 1 addition & 1 deletion src/pip/_internal/req/req_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def check_if_exists(self, use_user_site):
no_marker = Requirement(str(self.req))
no_marker.marker = None
self.satisfied_by = pkg_resources.get_distribution(str(no_marker))
if self.editable and self.satisfied_by:
if (self.editable or self.link) and self.satisfied_by:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think self.link is exclusive to the PEP 508 link format of requirement. Have you ensured that this doesn't force reinstall in cases you aren't intending to change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, I am still new to the pip codebase. My hope was that this PR would generate discussion about the issue and one potential way to address it.

This approach is a bit overkill, but it's the smallest impact change I can think of. I would rather have a tool that was extra cautious and reinstalled more often than was necessary instead of missing cases where a reinstall should have been required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, no problem (this code is complex!) but I think it probably will affect things that it shouldn't in that case.

In contrast to you, I'd strongly prefer pip to not modify my system unless it needs to, so I'm keen that this change doesn't impact anything that it shouldn't. I haven't really got any direct experience of (or familiarity with) the situations where PEP 508 URL links (or their predecessors, dependency_links) are useful, so I can't really comment on whether the issue here should be handled by forcing a reinstall, I'll have to leave that to others. Although I will say that if there's no change to the project name or version, then IMO there should be no need to reinstall even if the URL changes - the idea is that the same project name and version should never refer to functionally different code (the one exception being local directories, which are assumed to be "in-development" code). I've added a comment to the original issue asking for more clarification on the need for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing @benoit-pierre's comment here: #5780 (comment), I will close this PR. The proposed alternative is much cleaner and fits both of our requirements.

self.conflicts_with = self.satisfied_by
# when installing editables, nothing pre-existing should ever
# satisfy
Expand Down