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

pip does not reinstall an already installed package from a different direct url requirement #7678

Closed
sbidoul opened this issue Jan 31, 2020 · 17 comments
Labels
C: direct url Direct URL references (PEP 440, PEP 508, PEP 610) C: vcs pip's interaction with version control systems like git, svn and bzr PEP implementation Involves some PEP type: enhancement Improvements to functionality

Comments

@sbidoul
Copy link
Member

sbidoul commented Jan 31, 2020

What's the problem this feature will solve?

Assume packaging has been installed with pip install "packaging @ git+https://github.com/pypa/packaging@20.0".

Then try to install from the 20.1 tag: pip install "packaging @ git+https://github.com/pypa/packaging@20.1". The second install does nothing, saying the requirement is already satisfied.

Describe the solution you'd like

The second install should reinstall with the requested requirement.

Alternative Solutions

  • Document this as a limitation of direct URL references support in PIP.

Additional context

This requires PEP 610 to implement. This may or may not influence the ongoing reflection about the resolver.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jan 31, 2020
@sbidoul sbidoul added the type: enhancement Improvements to functionality label Jan 31, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Jan 31, 2020
@sbidoul sbidoul added C: vcs pip's interaction with version control systems like git, svn and bzr PEP implementation Involves some PEP labels Jan 31, 2020
@uranusjr
Copy link
Member

Does the old #egg style URL correctly upgrade? I’d think the two should behave the same (i.e. if the old style upgrades, this should as well; if it doesn’t, we can treat this as a limitation).

@sbidoul
Copy link
Member Author

sbidoul commented Jan 31, 2020

Does the old #egg style URL correctly upgrade?

No, it does not.

Note a direct reference without package name does upgrade (unconditionally reinstalls? - I've not checked yet). I think in this case it should first get metadata to find out the name and then behave the same as when the name is provided upfront).

I think all 3 cases (without name, #egg and PEP 440 name-in-front) should behave the same wrt reinstalling or not.

In editable mode, it always upgrades (which makes sense).

@uranusjr
Copy link
Member

Completely agree that the three cases should behave the same. I wonder why nobody really noticed the nameless and #egg cases have different behaviour (or maybe there is, just no maintainers care).

@uranusjr
Copy link
Member

#3212 looks similar (but instead of deliberately wrong name this provides no name at all). #6457 also observe the non-upgrades when #egg= is specified.

@pfmoore
Copy link
Member

pfmoore commented Jan 31, 2020

Agreed all 3 should work the same. But given that pip install packaging would need -U to upgrade if packaging 20.0 was installed, but 20.1 was available on the index, I could argue that -U should be needed here. Does the upgrade happen if -U is specified?

Note: I understand that the user's intention is clearly different in this case - the explicit specification of name + version strongly suggests that the user wants 20.1 whether or not 20.0 is present. But I'd like to better understand how we would cleanly describe the semantics here - it feels like we're getting dangerously close to wanting pip to just "do what I mean" which is notoriously hard to get right, and even harder to document (people don't always mean the same thing, even when the same command is specified!).

@pfmoore
Copy link
Member

pfmoore commented Jan 31, 2020

#536 has an extensive discussion over whether we should force reinstall explicitly specified locations. Apparently I was ambivalent when it was discussed then, as well 🙂

@sbidoul
Copy link
Member Author

sbidoul commented Jan 31, 2020

Interesting discussion in #536. I'm not sure why it is closed, though.

Was it the intent to reinstall always (which is the case today for nameless direct requirements)?

@pfmoore
Copy link
Member

pfmoore commented Jan 31, 2020

Yeah, I wasn't sure either. The discussion looks inconclusive to me, and the linked PR that supposedly closed it doesn't seem to cover the same topic.

I think the problem is that there wasn't consensus on an agreed intent.

Personally, I prefer simpler mental models, so my preference is to say that if you want to upgrade, you should just add --upgrade or --force-reinstall. But I can see the arguments that the user "obviously" means to do an upgrade, so we should do that.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 31, 2020

With PEP 610 direct_url.json we can reinstall only if the URL has changed. That covers common cases of installing from a VCS tag or commit id, or an archive with a version number in its name. When installing from a VCS branch or local directory, the user can use --force-reinstall if needed.

@sbidoul
Copy link
Member Author

sbidoul commented Feb 6, 2020

I seems using --upgrade makes pip always reinstall direct URLs, which is a reasonable workaround.

The default behaviour of not upgrading is unintuitive in most cases, however.

So maybe we can approach this in two steps:

  1. Make it work identically for nameless and named URLs. We need to decide which is the best:
  • reinstall always (as pip does for nameless direct URL requirements now)
  • reinstall when --upgrade is requested (as pip does for named direct URL requirements now)
  1. In a second step, consider a smart approach of reinstalling

@sbidoul
Copy link
Member Author

sbidoul commented Feb 6, 2020

PR #6402 trying to address #5780 also touches this subject.

@pfmoore
Copy link
Member

pfmoore commented Feb 6, 2020

Note that the new resolver will affect behaviour here. Currently, requesting an install of a URL or file (named or nameless) will basically do that install (subject to the question here about upgrades). With a real resolver, there's the possibility that installing will cause a conflict, and so will get rejected for that reason.

So the user expectation will need to be a little more nuanced that "reinstall always" in any case under the new resolver.

I'm not sure if this affects the discussion here, but I wanted to point it out because it's a subtle but important UX difference with the new resolver that will likely need careful managing as part of the resolver rollout.

@sbidoul
Copy link
Member Author

sbidoul commented Feb 6, 2020

@pfmoore my impression (trying to factor out my own use cases) is that the common use case for direct URLs is very similar to pinning a version. For instance when pointing to a VCS tag, a VCS commit id, an archive with a version number in it, or a local directory, the user says "I want this specific version and not any other one".

So this could mean direct URL requirements could be handled the same as == version specifiers wrt conflict handling.

@pfmoore
Copy link
Member

pfmoore commented Feb 6, 2020

Yes, that's how I'd expect the new resolver to handle it.

@pradyunsg
Copy link
Member

Yes, that's how I'd expect the new resolver to handle it.

We'd want to check this out. :)

@sbidoul sbidoul added the C: direct url Direct URL references (PEP 440, PEP 508, PEP 610) label Aug 4, 2020
@pradyunsg
Copy link
Member

Hey, is this basically a part of #5780 now?

@uranusjr
Copy link
Member

uranusjr commented Dec 3, 2020

I’ll go ahead and close this in favour of #5780. Kindly raise your voice if you feel it is a mistake.

@uranusjr uranusjr closed this as completed Dec 3, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: direct url Direct URL references (PEP 440, PEP 508, PEP 610) C: vcs pip's interaction with version control systems like git, svn and bzr PEP implementation Involves some PEP type: enhancement Improvements to functionality
Projects
None yet
Development

No branches or pull requests

4 participants