forked from pubgrub-rs/pubgrub
-
Notifications
You must be signed in to change notification settings - Fork 4
Add method for incompatibilities between virtual and base packages #45
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
Open
konstin
wants to merge
15
commits into
main
Choose a base branch
from
konsti/main/add_proxy_package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
This wrapper avoids accessing the `incompatibility_store` directly in uv code. Before: ```rust let dep_incompats = self.pubgrub.add_version( package.clone(), version.clone(), dependencies, ); self.pubgrub.partial_solution.add_version( package.clone(), version.clone(), dep_incompats, &self.pubgrub.incompatibility_store, ); ``` After: ```rust self.pubgrub.add_incompatibility_from_dependencies(package.clone(), version.clone(), dependencies); ``` `add_incompatibility_from_dependencies` is one of the main methods for the custom interface to pubgrub.
* Use new GitHub output syntax * Fix tag message
This is used in uv for logging
This allows discarding a previously made decision if it turned out to be a bad decision, even if all options with this decision have not yet been rejected. We allow attempting to backtrack on packages that were not decided yet to avoid the caller from making the duplicative check. astral-sh/uv#8157
Without the default write permissions the job otherwise fails, see https://github.com/astral-sh/pubgrub/actions/runs/14617176327/job/41007947575
In uv, we don't use the `DependencyConstraints` map, but pass in the dependencies through an iterator. This means there can be duplicate dependencies in the input. This would previously make `merge_dependents` panic if a package dependent on itself twice with the same range: ```toml [package] name = "foo" version = "0.1.0" dependencies = ["foo", "foo"] ``` The fix is to ignore self-dependencies when merging dependents, given that they are always trivially true or trivially false.
Add a new method to add a single custom incompatibility that requires the base package and the proxy package share the same version range. This intended for cases where proxy packages (also known as virtual packages) are used. Without this information, pubgrub does not know that these packages have to be at the same version. In cases where the base package is already to an incompatible version, this avoids going through all versions of the proxy package. In cases where there are two incompatible proxy packages, it avoids trying versions for both of them. Both improve performance (we don't need to check all versions when there is a conflict) and error messages (report a conflict of version ranges instead of enumerating the conflicting versions). There's several usage patterns for this method. The basic one is upon encountering a dependency on a proxy package with a range, using this method with its base package and that range.
CodSpeed Performance ReportCongrats! CodSpeed is installed 🎉
You will start to see performance impacts in the reports once the benchmarks are run from your default branch.
|
konstin
added a commit
to astral-sh/uv
that referenced
this pull request
Sep 22, 2025
Add an incompatibility that lets pubgrub skip of marker packages when the base package already has an incompatible version to improve the error messages (#15199). The change is also a small perf improvement. Overall this should be able to improve performance in slow cases by avoiding trying proxy package versions that are impossible anyway, for a (ideally very small cost) for tracking the additional incompatibility and tracking the base package for each proxy package. ``` $ hhyperfine --warmup 2 "uv pip compile --universal scripts/requirements/airflow.in" "target/release/uv pip compile --universal scripts/requirements/airflow.in" Benchmark 1: uv pip compile --universal scripts/requirements/airflow.in Time (mean ± σ): 145.5 ms ± 3.9 ms [User: 154.7 ms, System: 140.7 ms] Range (min … max): 139.2 ms … 153.4 ms 20 runs Benchmark 2: target/release/uv pip compile --universal scripts/requirements/airflow.in Time (mean ± σ): 128.7 ms ± 5.5 ms [User: 141.9 ms, System: 137.3 ms] Range (min … max): 121.8 ms … 142.0 ms 23 runs Summary target/release/uv pip compile --universal scripts/requirements/airflow.in ran 1.13 ± 0.06 times faster than uv pip compile --universal scripts/requirements/airflow.in ``` This implementation is the basic version: When we see a proxy `foo{...}>=x,<y` we add a dependency edge `foo{...}>=x,<y` -> `foo>=x,<y`. There are several way to extend this, which likely help more with performance than with error messages. One idea is that if we see `foo{...}>=x,<y` but we already made a selection for `foo==z` outside that range, we can insert a dependency `foo{...}!=z` -> `foo!=z`. This avoids trying any version of the proxy package except the version that matches our previous selection. Another is that if we see a dependency `foo>=x,<y`, we also add `foo{...}>=x,y` -> `foo>=x,<y`. This allows backtracking beyond `foo` immediately if all version of `foo{...}>=x,<y` are incompatible, since `foo{...}>=x,<y` incompatible -> `foo>=x,<y` incompatible -> the package that depended of `foo>=x,<y` is incompatible. The cost for each of these operations is tracking an additional incompatibility per virtual package. An alternative approach is to only add the incompatibility lazily, only when we've tried several version of the virtual package already. This needs to be weighed of with the better error messages that the incompatibility gives, we unfortunately have only few large reference examples. Requires astral-sh/pubgrub#45 Closes #15199
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.
Add a new method to add a single custom incompatibility that requires the base package and the proxy package share the same version range.
This intended for cases where proxy packages (also known as virtual packages) are used. Without this information, pubgrub does not know that these packages have to be at the same version. In cases where the base package is already to an incompatible version, this avoids going through all versions of the proxy package. In cases where there are two incompatible proxy packages, it avoids trying versions for both of them. Both improve performance (we don't need to check all versions when there is a conflict) and error messages (report a conflict of version ranges instead of enumerating the conflicting versions).
There's several usage patterns for this method. The basic one is upon encountering a dependency on a proxy package with a range, using this method with its base package and that range.