pip: Follow PEP 440 and install non-dev versions if `--pre` is not given
People installing scanpy==1.4.4.post1 (which specifies anndata>=0.6.22rc1) currently get anndata==0.7rc2. I think they should get anndata==0.6.22 instead.
What’s the problem this feature will solve?
Currently pip treats the >= and rc parts separately:
>=means to pip “Anything bigger is OK” (except for rcs and alphas and betas)rcmeans “The user is OK with release candidates”
I don’t think that makes sense: When you specify a dependency as >=X.YrcZ, you mean “I need X.Y and consider the prereleases of X.Y to be stable enough”. It doesn’t mean you extend trust to any future prereleases of that package.
Describe the solution you’d like
If rc, alpha, beta, … appears in a version, >= should mean “get me any higher development versions of that version, or any higher release versions” E.g. >=0.6.22a1 should mean 0.6.22a2, 0.6.22b1, 0.6.22rc2, are OK, and any stable version >=0.6.22
Follow PEP 440 as described below:
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 3
- Comments: 15 (8 by maintainers)
I wouldn’t say conclusively (yet?) this is what the users expect as a consensus. And pip maintainers most certainly do not intend to send that message if they do decide to stick with the current behaviour. Please keep things reasonable here.
I don’t think there is a change in the version specification logic, but a weird quirk in the dependency discovery logic:
The “difference” between pip 19 and 20 you see is due to
co2mpaschanging its dependencies. pip did not change.Linking https://github.com/pypa/pip/issues/4969 which I saw first but is closed (for the next person who finds their way there). I also feel current behavior is confusing.
No problem - I wasn’t trying to defend pip’s current behaviour, just pointing out that the PEP leaves a lot of details optional. But either way, thanks for the clarification and no need to worry about it any further.
I did a check, and it looks like the packaging library is allowing pre-releases if the specifier includes a pre-release in the constraint:
This appears deliberate. From the documentation:
Maybe pip should avoid passing
Noneand only ever use a value reflecting whether the user supplied the--preargument. The relevant code path in pip starts here. Conversely, maybe the auto-detection done bypackagingis unnecessary - the basic behaviour in the PEP seems to cover the practical use cases better than “if the specifier mentions a pre-release, then accept any pre-preleases”.I’m unlikely to have time to dig into this further at any time in the near future (although the work on the new resolver might touch this code, in which case that would be an opportunity to look at this). But if someone else wants to take this on, I’d be fine with that.
Please note that it’s very hard to find a respectful way to continue this discussion in the light of describing anybody’s attitude like this. I’d strongly request that you keep your tone polite in future - assume everyone is acting with the best intentions, but that no-one is immune from making mistakes.
The reality is that the PEP is specific in what it requires, but the implications of those requirements are subtle. Add to that the fact that some of the PEP’s requirements are non-mandatory (which is what “should” means - it’s not “if you don’t do this you’re ignoring user expectations”, it’s simply “a number of possible approaches exist, and tools are allowed to make their own judgement as to which suits their users best”) and there are some complexities to sort out.
Pip’s current behaviour is based (as far as I can see) on the flexibility allowed by the PEP over how the user may opt into accepting pre-releases, and is assuming that if the user has a dependency that explicitly mentions pre-releases, that implies that they are willing to accept them. On consideration of the case noted here, it looks like that might be too broad an assumption, and we should remove it. I’d be happy to see that happen, but I don’t personally have much need for pre-releases, so I’d rather hear views from other people with an actual stake in the behaviour.
By the way, it should also be noted that pip uses
packaging.specifiersto do PEP 440 version matching, so any change would likely end up having to be made there, rather than in pip.