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

Respect visitation order for proxy packages #10833

Merged
merged 3 commits into from
Jan 22, 2025
Merged

Respect visitation order for proxy packages #10833

merged 3 commits into from
Jan 22, 2025

Conversation

charliermarsh
Copy link
Member

Summary

This PR reverts #10441 and applies a different fix for #10425.

In #10441, I changed prioritization to visit proxies eagerly. I think this is actually wrong, since it means we prioritize proxy packages above everything else. And while a proxy only depends on itself, it does mean we're selecting a version for the proxy package earlier than anything else. So, if you look at #10828, we end up choosing a version for async-timeout before we choose a version for langchain, despite the latter being a first-party dependency. (async-timeout has a marker on it, so it has a proxy package, so we solve for it first.)

To fix #10425, we instead need to make sure we visit proxies in the order we see them. I think the virtual tiebreaker for proxies is reversed? We want to visit the package we see first, first.

So, in short: this reverts #10441, then corrects the ordering for visiting proxies.

Closes #10828.

@charliermarsh charliermarsh requested a review from konstin January 21, 2025 23:15
@charliermarsh charliermarsh added bug Something isn't working resolver Related to the package resolver labels Jan 21, 2025
@konstin
Copy link
Member

konstin commented Jan 22, 2025

To fix #10425, we instead need to make sure we visit proxies in the order we see them. I think the virtual tiebreaker for proxies is reversed? We want to visit the package we see first, first.

Would it fix #10425 if we visited the virtual packages inside the package-batch first?

Like:

  • A{foo}
  • A{bar}
  • A <- This one is last
  • B <- has no virtual packages
  • C{python_version}
  • C{extra}
  • C <- this one is last

Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #10853 for a follow-up

Comment on lines +2304 to -2313
// Verify that the package is allowed under the hash-checking policy.
if !self
.hasher
.allows_package(candidate.name(), candidate.version())
{
return Ok(None);
}

// Emit a request to fetch the metadata for this version.
if self.index.distributions().register(candidate.version_id()) {
// Verify that the package is allowed under the hash-checking policy.
if !self
.hasher
.allows_package(candidate.name(), candidate.version())
{
return Err(ResolveError::UnhashedPackage(candidate.name().clone()));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the hash changes coming from?

/// Main priority and tiebreak for virtual packages
type Priority = (Option<PubGrubPriority>, u32);
/// Main priority and tiebreak for virtual packages.
type Priority = (Option<PubGrubPriority>, Option<PubGrubTiebreaker>);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #10853

@charliermarsh
Copy link
Member Author

@konstin -- I actually don't think that would be sufficient. Imagine:

foo==1
bar==1

We resolve foo, which depends on bar ; sys_platform == "darwin". We'd then prioritize the bar ; sys_platform == "darwin" proxy over the base package, and we'd select a version of bar that didn't meet the bar==1 requirement.

@charliermarsh
Copy link
Member Author

I think a separate thing we could do, to make the order here less critical, is change these hash-mismatch errors to incompatibilities, so we backtrack rather than fail hard just for trying an incompatible package.

@charliermarsh charliermarsh enabled auto-merge (squash) January 22, 2025 17:04
@charliermarsh charliermarsh merged commit f0dc1f4 into main Jan 22, 2025
68 checks passed
@charliermarsh charliermarsh deleted the charlie/rev branch January 22, 2025 17:12
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Jan 26, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [astral-sh/uv](https://github.com/astral-sh/uv) | patch | `0.5.22` -> `0.5.24` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>astral-sh/uv (astral-sh/uv)</summary>

### [`v0.5.24`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0524)

[Compare Source](astral-sh/uv@0.5.23...0.5.24)

##### Enhancements

-   Improve determinism of resolution by always setting package priorities ([#&#8203;10853](astral-sh/uv#10853))
-   Upgrade to `cargo-dist` 0.28.0; improves several installer behaviors ([#&#8203;10884](astral-sh/uv#10884))

##### Performance

-   Remove dependencies clone in resolver ([#&#8203;10880](astral-sh/uv#10880))
-   Use Hashbrown's raw entry API to reduce hashes and clone in resolver priority determination ([#&#8203;10881](astral-sh/uv#10881))

##### Bug fixes

-   Allow fallback to Python download on non-critical discovery errors ([#&#8203;10908](astral-sh/uv#10908))

##### Preview features

-   Register managed Python version with the Windows Registry (PEP 514) ([#&#8203;10634](astral-sh/uv#10634))

##### Documentation

-   Improve documentation for some environment variables ([#&#8203;10887](astral-sh/uv#10887))
-   Add git subdirectory example ([#&#8203;10894](astral-sh/uv#10894))

### [`v0.5.23`](https://github.com/astral-sh/uv/blob/HEAD/CHANGELOG.md#0523)

[Compare Source](astral-sh/uv@0.5.22...0.5.23)

##### Enhancements

-   Add `--refresh` to `uv venv` ([#&#8203;10834](astral-sh/uv#10834))
-   Add `--no-default-groups` command-line flag ([#&#8203;10618](astral-sh/uv#10618))

##### Bug fixes

-   Sort extras and groups when comparing lockfile requirements ([#&#8203;10856](astral-sh/uv#10856))
-   Include `commit_id` and `requested_revision` in `direct_url.json` ([#&#8203;10862](astral-sh/uv#10862))
-   Invalidate lockfile when static versions change ([#&#8203;10858](astral-sh/uv#10858))
-   Make GitHub fast path errors non-fatal ([#&#8203;10859](astral-sh/uv#10859))
-   Remove warnings for `--frozen` and `--locked` in `uv run --script` ([#&#8203;10840](astral-sh/uv#10840))
-   Resolve `find-links` paths relative to the configuration file ([#&#8203;10827](astral-sh/uv#10827))
-   Respect visitation order for proxy packages ([#&#8203;10833](astral-sh/uv#10833))
-   Treat version mismatch errors as non-fatal in fast paths ([#&#8203;10860](astral-sh/uv#10860))
-   Mark `--locked` and `--upgrade` are conflicting ([#&#8203;10836](astral-sh/uv#10836))
-   Relax error checking around unconditional enabling of conflicting extras ([#&#8203;10875](astral-sh/uv#10875))

##### Documentation

-   Reduce ambiguity in conflicting extras example ([#&#8203;10877](astral-sh/uv#10877))
-   Update pre-commit documentation  ([#&#8203;10756](astral-sh/uv#10756))

##### Error messages

-   Error when workspace contains conflicting Python requirements ([#&#8203;10841](astral-sh/uv#10841))
-   Improve uvx error message when uv is missing ([#&#8203;9745](astral-sh/uv#9745))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMjIuMCIsInVwZGF0ZWRJblZlciI6IjM5LjEyNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolver Related to the package resolver
Projects
None yet
2 participants