Repository navigation
Support transitive pre-release dependencies with a fixed universe - #19998
Closed
charliermarsh wants to merge 20 commits into
Closed
charliermarsh wants to merge 20 commits into
charliermarsh wants to merge 20 commits into
Conversation
Merging this PR will degrade performance by 16.3%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression with the CodSpeed MCP and your agent. Comparing |
charliermarsh
force-pushed
the
charlie/prerelease-fixed-universe
branch
from
June 26, 2026 01:59
9ac9895 to
cb803fc
Compare
uv test inventory changesThis PR changes the tests when compared with the latest
|
charliermarsh
added a commit
that referenced
this pull request
Jul 14, 2026
## Summary Prior to this change, we needed to know upfront whether a given package was "allowed" to use a pre-release -- either by way of being a first-party dependency with a pre-release marker on it (e.g., `flask >= 2.0.0a0`), or by _only_ having pre-releases available on PyPI at all, or by the user _always_ allowing pre-releases via configuration. By default, if transitive metadata later introduced a requirement like `foo>=2.0.0b1`, that requirement did _not_ enable pre-releases for `foo`, even though it should've (per the spec). This PR adds support for actual transitive pre-release requirements: we prefer stable candidates that satisfy the current range, then consider pre-releases when those candidates are exhausted. An explicit pre-release requirement discovered during resolution is represented by a PubGrub proxy package. For completeness, I also prototyped a [nab](https://github.com/notatallshaw/nab)-style solution in #19998. That design encoded stable- and pre-release-enabled variants directly in PubGrub. It's arguably semantically nicer, but it was much more invasive and caused more significant CodSpeed regressions on large graphs. I ultimately decided that this solution is better for now, given that it's both simpler and closer to how we model versions today. This smaller, proxy-package solution does get at least one case wrong. If a selected stable version of package A satisfies requirements, and we then find a package that depends on A with a pre-release, PubGrub may retain that version instead of "upgrading" it to a newer pre-release. The net effect is that we may accept an older stable release rather than upgrading to a newer pre-release if we see a pre-release requirement later on in a solve. I think this is an acceptable limitation as compared to the number of issues we'll be able to close here. And nab suffers from some similar issues (as per #19993 (comment)). Finally, the former `--prerelease=explicit` policy has been deprecated. `explicit` is the only mode we can't support here, because it requires adding pre-release candidates after resolution has already begun. The behavior is preserved, but unlike the other modes, it doesn't support transitive pre-releases (i.e., it's ~unchanged vs. main). Personally, I don't think that `explicit` vs. `if-necessary-or-explicit` is really an important distinction. Related: #3602. Related: #14851. Closes #19593. Closes #2685. Closes #11483. Closes #19324. Closes #12589. Closes #9395. Closes #16494. Closes #16893.
konstin
pushed a commit
that referenced
this pull request
Jul 21, 2026
## Summary Prior to this change, we needed to know upfront whether a given package was "allowed" to use a pre-release -- either by way of being a first-party dependency with a pre-release marker on it (e.g., `flask >= 2.0.0a0`), or by _only_ having pre-releases available on PyPI at all, or by the user _always_ allowing pre-releases via configuration. By default, if transitive metadata later introduced a requirement like `foo>=2.0.0b1`, that requirement did _not_ enable pre-releases for `foo`, even though it should've (per the spec). This PR adds support for actual transitive pre-release requirements: we prefer stable candidates that satisfy the current range, then consider pre-releases when those candidates are exhausted. An explicit pre-release requirement discovered during resolution is represented by a PubGrub proxy package. For completeness, I also prototyped a [nab](https://github.com/notatallshaw/nab)-style solution in #19998. That design encoded stable- and pre-release-enabled variants directly in PubGrub. It's arguably semantically nicer, but it was much more invasive and caused more significant CodSpeed regressions on large graphs. I ultimately decided that this solution is better for now, given that it's both simpler and closer to how we model versions today. This smaller, proxy-package solution does get at least one case wrong. If a selected stable version of package A satisfies requirements, and we then find a package that depends on A with a pre-release, PubGrub may retain that version instead of "upgrading" it to a newer pre-release. The net effect is that we may accept an older stable release rather than upgrading to a newer pre-release if we see a pre-release requirement later on in a solve. I think this is an acceptable limitation as compared to the number of issues we'll be able to close here. And nab suffers from some similar issues (as per #19993 (comment)). Finally, the former `--prerelease=explicit` policy has been deprecated. `explicit` is the only mode we can't support here, because it requires adding pre-release candidates after resolution has already begun. The behavior is preserved, but unlike the other modes, it doesn't support transitive pre-releases (i.e., it's ~unchanged vs. main). Personally, I don't think that `explicit` vs. `if-necessary-or-explicit` is really an important distinction. Related: #3602. Related: #14851. Closes #19593. Closes #2685. Closes #11483. Closes #19324. Closes #12589. Closes #9395. Closes #16494. Closes #16893.
konstin
pushed a commit
that referenced
this pull request
Jul 24, 2026
Prior to this change, we needed to know upfront whether a given package was "allowed" to use a pre-release -- either by way of being a first-party dependency with a pre-release marker on it (e.g., `flask >= 2.0.0a0`), or by _only_ having pre-releases available on PyPI at all, or by the user _always_ allowing pre-releases via configuration. By default, if transitive metadata later introduced a requirement like `foo>=2.0.0b1`, that requirement did _not_ enable pre-releases for `foo`, even though it should've (per the spec). This PR adds support for actual transitive pre-release requirements: we prefer stable candidates that satisfy the current range, then consider pre-releases when those candidates are exhausted. An explicit pre-release requirement discovered during resolution is represented by a PubGrub proxy package. For completeness, I also prototyped a [nab](https://github.com/notatallshaw/nab)-style solution in #19998. That design encoded stable- and pre-release-enabled variants directly in PubGrub. It's arguably semantically nicer, but it was much more invasive and caused more significant CodSpeed regressions on large graphs. I ultimately decided that this solution is better for now, given that it's both simpler and closer to how we model versions today. This smaller, proxy-package solution does get at least one case wrong. If a selected stable version of package A satisfies requirements, and we then find a package that depends on A with a pre-release, PubGrub may retain that version instead of "upgrading" it to a newer pre-release. The net effect is that we may accept an older stable release rather than upgrading to a newer pre-release if we see a pre-release requirement later on in a solve. I think this is an acceptable limitation as compared to the number of issues we'll be able to close here. And nab suffers from some similar issues (as per #19993 (comment)). Finally, the former `--prerelease=explicit` policy has been deprecated. `explicit` is the only mode we can't support here, because it requires adding pre-release candidates after resolution has already begun. The behavior is preserved, but unlike the other modes, it doesn't support transitive pre-releases (i.e., it's ~unchanged vs. main). Personally, I don't think that `explicit` vs. `if-necessary-or-explicit` is really an important distinction. Related: #3602. Related: #14851. Closes #19593. Closes #2685. Closes #11483. Closes #19324. Closes #12589. Closes #9395. Closes #16494. Closes #16893.
konstin
pushed a commit
that referenced
this pull request
Jul 28, 2026
Prior to this change, we needed to know upfront whether a given package was "allowed" to use a pre-release -- either by way of being a first-party dependency with a pre-release marker on it (e.g., `flask >= 2.0.0a0`), or by _only_ having pre-releases available on PyPI at all, or by the user _always_ allowing pre-releases via configuration. By default, if transitive metadata later introduced a requirement like `foo>=2.0.0b1`, that requirement did _not_ enable pre-releases for `foo`, even though it should've (per the spec). This PR adds support for actual transitive pre-release requirements: we prefer stable candidates that satisfy the current range, then consider pre-releases when those candidates are exhausted. An explicit pre-release requirement discovered during resolution is represented by a PubGrub proxy package. For completeness, I also prototyped a [nab](https://github.com/notatallshaw/nab)-style solution in #19998. That design encoded stable- and pre-release-enabled variants directly in PubGrub. It's arguably semantically nicer, but it was much more invasive and caused more significant CodSpeed regressions on large graphs. I ultimately decided that this solution is better for now, given that it's both simpler and closer to how we model versions today. This smaller, proxy-package solution does get at least one case wrong. If a selected stable version of package A satisfies requirements, and we then find a package that depends on A with a pre-release, PubGrub may retain that version instead of "upgrading" it to a newer pre-release. The net effect is that we may accept an older stable release rather than upgrading to a newer pre-release if we see a pre-release requirement later on in a solve. I think this is an acceptable limitation as compared to the number of issues we'll be able to close here. And nab suffers from some similar issues (as per #19993 (comment)). Finally, the former `--prerelease=explicit` policy has been deprecated. `explicit` is the only mode we can't support here, because it requires adding pre-release candidates after resolution has already begun. The behavior is preserved, but unlike the other modes, it doesn't support transitive pre-releases (i.e., it's ~unchanged vs. main). Personally, I don't think that `explicit` vs. `if-necessary-or-explicit` is really an important distinction. Related: #3602. Related: #14851. Closes #19593. Closes #2685. Closes #11483. Closes #19324. Closes #12589. Closes #9395. Closes #16494. Closes #16893.
zanieb
pushed a commit
that referenced
this pull request
Jul 28, 2026
Prior to this change, we needed to know upfront whether a given package was "allowed" to use a pre-release -- either by way of being a first-party dependency with a pre-release marker on it (e.g., `flask >= 2.0.0a0`), or by _only_ having pre-releases available on PyPI at all, or by the user _always_ allowing pre-releases via configuration. By default, if transitive metadata later introduced a requirement like `foo>=2.0.0b1`, that requirement did _not_ enable pre-releases for `foo`, even though it should've (per the spec). This PR adds support for actual transitive pre-release requirements: we prefer stable candidates that satisfy the current range, then consider pre-releases when those candidates are exhausted. An explicit pre-release requirement discovered during resolution is represented by a PubGrub proxy package. For completeness, I also prototyped a [nab](https://github.com/notatallshaw/nab)-style solution in #19998. That design encoded stable- and pre-release-enabled variants directly in PubGrub. It's arguably semantically nicer, but it was much more invasive and caused more significant CodSpeed regressions on large graphs. I ultimately decided that this solution is better for now, given that it's both simpler and closer to how we model versions today. This smaller, proxy-package solution does get at least one case wrong. If a selected stable version of package A satisfies requirements, and we then find a package that depends on A with a pre-release, PubGrub may retain that version instead of "upgrading" it to a newer pre-release. The net effect is that we may accept an older stable release rather than upgrading to a newer pre-release if we see a pre-release requirement later on in a solve. I think this is an acceptable limitation as compared to the number of issues we'll be able to close here. And nab suffers from some similar issues (as per #19993 (comment)). Finally, the former `--prerelease=explicit` policy has been deprecated. `explicit` is the only mode we can't support here, because it requires adding pre-release candidates after resolution has already begun. The behavior is preserved, but unlike the other modes, it doesn't support transitive pre-releases (i.e., it's ~unchanged vs. main). Personally, I don't think that `explicit` vs. `if-necessary-or-explicit` is really an important distinction. Related: #3602. Related: #14851. Closes #19593. Closes #2685. Closes #11483. Closes #19324. Closes #12589. Closes #9395. Closes #16494. Closes #16893.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #19993.
Prior to this change, uv decided whether pre-releases were enabled for a package before dependency resolution began. An explicit pre-release requirement discovered in transitive metadata therefore did not authorize that package, while
--prerelease=allowenabled pre-releases globally and could select unrelated pre-releases. Theif-necessarymodes also fell back only when a package had no stable releases at all, rather than when no stable candidate satisfied the active constraints.This makes pre-release fallback range-relative and represents candidate preference directly in PubGrub's version universe. Each release has a stable-preferring solver variant and a pre-release-enabled variant. Ordinary requirements admit both variants, while an active requirement that names a pre-release admits only the enabled variant. PubGrub's existing range intersection and backtracking can therefore reconsider an earlier stable decision when transitive authorization appears, discard authorization when its parent is rejected, and keep marker forks isolated, without resolver restarts, mutable global authorization, proxy packages, or changes to PubGrub itself.
Metadata, availability facts, and dependency incompatibilities are shared between the two variants of the same release, while candidate selection and batch prefetch preserve the selected preference dimension. Final resolutions and derivation trees collapse the variants back to ordinary versions. This preserves existing diagnostics, avoids duplicate metadata work, and prevents speculative prefetches from crossing into the wrong preference dimension.
if-necessaryand the defaultif-necessary-or-explicitnow prefer stable candidates relative to the active range; the standaloneexplicitmode is removed.The regression coverage exercises transitive requirements, late authorization after a stable decision, extras, markers, cached metadata, multi-hop chains, rejected parents, universal-resolution forks, isolated build requirements,
disallow, offline diagnostics, incorrect pre-release hints, and preference-aware prefetch. The resolution and compatibility documentation now describe the fixed-universe model.Related to #3602 and #14851.
Closes #19593.
Closes #2685.
Closes #11483.
Closes #19324.
Closes #12589.
Closes #9395.
Closes #16494.
Closes #16893.