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

Update toolchain discovery to avoid runtime panic #3330

Merged
merged 1 commit into from
May 2, 2024
Merged

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented May 1, 2024

Split out of #3266

If UV_BOOTSTRAP_DIR and CARGO_MANIFEST_DIR are both unset, we currently panic. This isn't good once we start to use managed toolchains in production. We'll need to change this more later once the toolchain directory is more user-facing.

@zanieb zanieb added the internal A refactor or improvement that is not user-facing label May 1, 2024
Copy link

codspeed-hq bot commented May 1, 2024

CodSpeed Performance Report

Merging #3330 will not alter performance

Comparing zb/toolchain-panic (98150aa) with main (614c073)

Summary

✅ 12 untouched benchmarks

@zanieb zanieb marked this pull request as ready for review May 1, 2024 17:40
@zanieb zanieb mentioned this pull request May 1, 2024
2 tasks
@zanieb zanieb merged commit 5048cce into main May 2, 2024
43 checks passed
@zanieb zanieb deleted the zb/toolchain-panic branch May 2, 2024 11:44
zanieb added a commit that referenced this pull request May 21, 2024
Updates our Python interpreter discovery to conform to the rules
described in #2386, please see that issue for a full description of the
behavior. Briefly, we now will search for interpreters that satisfy a
requested version without stopping at the first Python executable.
Additionally, if retrieving information about an interpreter fails we
will continue to search for a working interpreter. We also add the
plumbing necessary to request Python implementations other than CPython,
though we do not add support for other implementations at this time.

A major internal goal of this work is to prepare for user-facing managed
toolchains i.e. fetching a requested version during `uv run`. These APIs
are not introduced, but there is some managed toolchain handling as
required for our test suite.

Some noteworthy implementation changes:

- The `uv_interpreter::find_python` module has been removed in favor of
a `uv_interpreter::discovery` module.
- There are new types to help structure interpreter requests and track
sources
- Executable discovery is implemented as a big lazy iterator and is a
central authority for source precedence
- `uv_interpreter::Error` variants were split into scoped types in each
module
- There's much more unit test coverage, but not for Windows yet

Remaining work:

- [x] Write new test cases
- [x] Determine correct behavior around executables in the current
directory
- _Future_: Combine `PythonVersion` and `VersionRequest`
- _Future_: Consider splitting `ManagedToolchain` into local and remote
variants
- _Future_: Add Windows unit test coverage
- _Future_: Explore behavior around implementation precedence (i.e.
CPython over PyPy)

Refactors split into:

- #3329 
- #3330 
- #3331
- #3332

Closes #2386
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal A refactor or improvement that is not user-facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants