-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Proposal: New arguments to control pre-releases #13221
Comments
--all-releases <format_control>
and --only-final <format_control>
arguments to control pre-releases
An existing workaroundGranular enabling of pre-releases is technically already possible by creating a constraints file and adding:
However, as far as I'm aware, it is not an intended use case for constraints, and requires creating a file (can't fully be specified by either CLI or Env Vars). |
In general, I'm in favour of this, as I think that giving users finer control in the (exceptional, hopefully!) cases where they need it is a good thing. But I'm a little concerned that pip's UI is already complex, and this adds more complexity. Unfortunately, I don't know enough about UI design to have a better idea of how to expose this functionality (I thought of having a "package selection mini-language" covering this and the various I don't want the perfect to be the enemy of the good, though, so I'm fine with this proposal as it stands. |
I like the proposal and we would find it very useful in Airflow. Small suggestion maybe - to do a bit more fine-grained behaviour and consistency with https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers:
That's a suggestion only and it would also cover the developmental case which I think currently has no separate flag. Currently Also maybe we could update the docs of |
Before considering distinguishing dev-releases and pre-releases it needs to be understood, does the spec consider dev-releases to be a type of pre-release, I pose this question from reading the spec yesterday over on packaging: pypa/packaging#875 (comment).
If we are distinguishing pre-releases from dev-releases this opens a bunch of questions I don't think the spec answers, to implement this I would be specifically working off "Handling of pre-releases" which does not distinguish pre-releases from dev-releases:
And furthermore I would be leveraging Packaging's SpecifierSet to correctly implement the spec, it accepts the pre-release value in it's And these kind of bugs would make me very wary of implementing the logic myself, if we distinguish dev-releases from pre-releases (and we don't distinguish final releases from post releases) there are 4 types of releases:
So when you say I think there are multiple answers that could be given, and I'm not personally motivated to solve that problem in this proposal, and I think it needs to be clear on the packaging side first, as in the original linked issue In general I do like the idea of giving users more control here, but I don't want to try implementing this on pip side when there are open questions about what do these terms even mean. I'm only now confident I have a good grasp on the "Handling of pre-releases" section of the spec.
I see no reason to wait on fixing that. PRs welcome from anyone for docs change, otherwise I will try to take a look myself at some point. |
IMO the current spec is clear that dev releases are pre-releases, as per the comment @notatallshaw quoted:
Treating dev releases differently than pre-releases would require a spec change, and therefore a PEP. I am strongly against pip implementing something like this without the backing of the spec, as (a) we use Frankly we've had enough trouble just pinning down the semantics of what a pre-release means. I have no appetite for adding more complexity (although if someone decides to write a PEP, I'll inevitably get sucked into the debate 🙁). |
Some time ago I've been caught by suprise that pre-release and dev-releae are very different things:
Which means that So I'd say reasonable thing would be
So:
And while a little chatty, it mkes perfect sense and is consistent. |
But yeah. there is ambiguity in the specs, so you can understand it differently, I agree. I would be fine with either choice you make. |
My point is that we shouldn't be making a choice. Nor, for that matter, should the And more fundamentally, I'm a strong -1 on extending this issue beyond the options in the original post. And this discussion has changed my view a little on that - I now think that even what's in the original post is risky, as the specification only allows user control in the form of the user explicitly requesting pre-releases to be included, so So I'm now of the view that All of this subject to change if a change to the standard gets proposed and approved, of course. Footnotes
|
Actually the spec says that tools SHOULD allow users to exclude pre-releases:
The Further I do think that tools have flexibility here to filter versions based on things that aren't defined in the spec, my main issue with tackling dev-releases in this proposal is that I do think there is ambiguity in the spec (though fortunatly not in the section "Handling of pre-releases") because if you just read:
You would definitely come away thinking that dev-releases are not pre-releases, but then other parts of the spec state or imply that dev-releases are pre-releases. I do think the spec needs clarity here as I say in pypa/packaging#875 (comment), but I'm not motivated right now to seek that clarity. For pip though, I think it should defer to packaging, and rely on packaging to follow the spec, file issues and PRs where we don't think it is, and leverage whatever packaging has to offer. |
Apologies. I missed that part of the spec.
I agree, although I think that because of the way the spec makes statements about including (or not) pre-releases, it's hard to reconcile such flexibility with the things the spec requires. IMO it would have been better if the spec had confined itself to defining ordering, and avoided all of the complexity around pre-releases. Unfortunately that would have been a significant break with user expectations (from what I recall of the discussions at the time) and is now a backward incompatible change with non-trivial implications (because version specifiers are included in dependency metadata which can therefore change meaning if pre-release handling changes).
Again, I agree, but my most recent attempt to rationalise things didn't work, because it simplified the pre-release handling too much, and so wasn't compatible with the current spec. And I have zero motivation for trying to make an incompatible change to the spec - I have no good answers to all the "but what if...?" questions that would inevitably come up. IMO, the biggest issue with the spec is the "Handling of pre-releases" section. I think1 that the rest of the spec is (fairly) self-consistent and clear. But too much of that one section just muddies the water. Ideally, we'd just remove it. But someone would have to confirm that doing so didn't cause significant problems (and I have a depressing feeling that it would). Footnotes
|
Noted, I will have a crack at this after my attempt to formalize the semantics of Requires Python. I am reading some literature, and doing some experiments, on solvability and resolution algorithms (e.g. PubGrub), and spending some time to see if Python's current version semantics can actually fit within their constraints (rather than making simplifying assumptions like uv does).
I do think this would cause significant disruption. It might be possible to rewrite this section without breaking the existing spec, by carefully defining a couple of operators that do quite closely fit standard mathematical operators, and then carefully defining the remaining operators in terms of the well defined operators. But I don't plan to have something ready soon, and like you, I think this propsal is best to carefully follow the langauge and suggestions of the current spec. |
On the side question of "Are Developmental releases a type of pre-release?": https://discuss.python.org/t/are-developmental-releases-a-type-of-pre-release/81666 |
Summary
This proposal introduces two new flags to
pip
:--all-releases <format_control>
: Allows installing all versions of a package, including pre-releases.--only-final <format_control>
: Restricts installation to final and post-releases only.These flags provide fine-grained control over release selection, following similar syntax and semantics of
--no-binary
and--only-binary
.Motivation
Currently,
pip
's handling of pre-releases is controlled globally via--pre
, but there's no package-specific control and no way to specify disabling pre-releases.Further, pip has historically not selected prereleases in places where the spec says it should due to bugs in packaging (pypa/packaging#872 and pypa/packaging#794) so users haven't had as much need to "turn off" prereleases as they might in the future.
Specification
--all-releases <format_control>
Allows installation of all versions of a package, including pre-releases. Can be supplied multiple times, and each time adds to the existing value.
:all:
to allow pre-releases for all packages:none:
to empty the setExample Usage:
--only-final <format_control>
Restricts installation to final and post-releases only. Can be supplied multiple times, and each time adds to the existing value.
:all:
to enforce only final releases for all packages:none:
to empty the setExample Usage:
Design Notes
--pre
will be the equivalent of--all-releases :all:
, and could eventually be deprecated--no-binary
and--only-binary
more specific things override less specific things, e,g,--all-releases :all: --only-final foo
does not allow pre-releases for foo.I have not included the:none:
syntax from--no-binary
and--only-binary
as I don't really understand the use case, but if there is a strong use case for it I can add itBackward Compatibility
This change is fully backward-compatible, as it introduces new optional flags without altering existing behavior.
Implementation
If there's no significant objection I'm volunteering to implement this.
However this is not being funded by anyone so work will go at the pace that I have free time, if someone else is willing to fund or work on this please let me know and we can organize something.
Bikeshedding
I'm not strongly attached to the names here, I'm happy to accept other names, I'm more interested if there are objections to the design.
The text was updated successfully, but these errors were encountered: