-
-
Notifications
You must be signed in to change notification settings - Fork 469
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
uv: move all uv commands to uv.rs #869
Merged
Merged
Conversation
This file contains 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
We are creating an empty ExpandedSources, as we will use them later to implement a default struct of Uv.
We are marking ensure_exists deprecated. In the follow up commits we will introduce UvBuilder as an alternative way to construct a Uv struct. We will then replace uses of `Uv::ensure_exists` in the codebase with `UvBuilder`, before finally removing `ensure_exists`.
We are using a builder pattern now to create an instance of Uv. The builder pattern will allow us to create an instance of `Uv` with sources, working directory and an command output mode set already.
In some instances we want to re-use the uv object when we have a venv. In that case, we need to have the ability to reset the command output mode.
I really like this. Something similar for toolchains is pending in #839. Definitely feels like a good direction. |
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.
The pull requests moves all invocations of
uv
tosrc/uv.rs
. The invokations are now structured into three main structures:UvBuilder
, which can be used to create a new instance of auv
binary that ensuresuv
exists on disk.Uv
, which provides operations usinguv
outside of the virtual environment, for example creating a venv, compiling lockfiles ,etc.UvWithVenv
, which must be obtained usingUv::venv()
to guarantee a venv is available, which encapsulates operations on the venv.This opens the door to implement the same patterns for
pip-tools
and intorduce a trait to use dynamic dispatching instead of the existingif/else
structure. If we continue down this path, we can hopefully in the future just do:Important Note:
Note that the changes are not 100% equivalent to the previous code. Most notable, in order to operate on a venv, all codepaths must go through
Uv::venv
, which will always check if the existing venv is compatbile. This is a safer, but more expensive path (since we at least always read the marker). If we are worried about this, we can introduce anassume_venv
which will returnUvWithVenv
without checks.