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

Skip prefetching when --no-deps is specified #2373

Merged
merged 1 commit into from
Mar 12, 2024
Merged

Conversation

charliermarsh
Copy link
Member

Summary

When running under --no-deps, we don't need to pre-fetch, because pre-fetching fetches the distribution metadata. But with --no-deps, we only need the package metadata for the top-level requirements. We never need distribution metadata.

Incidentally, this will fix #2300.

Test Plan

  • cargo test
  • ./target/debug/uv pip install --verbose --no-cache-dir --no-deps --reinstall ddtrace==2.6.2 debugpy==1.8.1 ecdsa==0.18.0 editorconfig==0.12.4 --verbose in a Python 3.10 Docker contain repeatedly.

@charliermarsh charliermarsh added the bug Something isn't working label Mar 12, 2024
@charliermarsh charliermarsh marked this pull request as ready for review March 12, 2024 03:30
@charliermarsh
Copy link
Member Author

There is a more complete fix for #2300 that I will put up separately, but this does fix the proximate cause.

@charliermarsh charliermarsh enabled auto-merge (squash) March 12, 2024 03:38
@charliermarsh charliermarsh merged commit 1d21e65 into main Mar 12, 2024
7 checks passed
@charliermarsh charliermarsh deleted the charlie/deps branch March 12, 2024 03:44
charliermarsh added a commit that referenced this pull request Mar 12, 2024
## Summary

This is a more robust fix for
#2300.

The basic issue is:

- When we resolve, we attempt to pre-fetch the distribution metadata for
candidate packages.
- It's possible that the resolution completes _without_ those pre-fetch
responses. (In the linked issue, this was mainly because we were running
with `--no-deps`, but the pre-fetch was causing us to attempt to build a
package to get its dependencies. The resolution would then finish before
the build completed.)
- In that case, the `Index` will be marked as "waiting" for that
response -- but it'll never come through.
- If there's a subsequent call to the `Index`, to see if we should fetch
or are waiting for that response, we'll end up waiting for it forever,
since it _looks_ like it's in-flight (but isn't). (In the linked issue,
we had to build the source distribution for the install phase of `pip
install`, but `setuptools` was in this bad state from the _resolve_
phase.)

This PR modifies the resolver to ensure that we flush the stream of
requests before returning. Specifically, we now `join` rather than
`select` between the resolution and request-handling futures.

This _could_ be wasteful, since we don't _need_ those requests, but it
at least ensures that every `.wait` is followed by ` .done`. In
practice, I expect this not to have any significant effect on
performance, since we end up using the pre-fetched distributions almost
every time.

## Test Plan

I ran through the test plan from
#2373, but ran the build 10 times
and ensured it never crashed. (I reverted
#2373, since that _also_ fixes the
issue in the proximate case, by never fetching `setuptools` during the
resolve phase.)

I also added logging to verify that requests are being handled _after_
the resolution completes, as expected.

I also introduced an arbitrary error in `fetch` to ensure that the error
was immediately propagated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uv hangs on install
1 participant