-
-
Notifications
You must be signed in to change notification settings - Fork 470
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
bootstrap using uv #754
bootstrap using uv #754
Conversation
We are starting a common module that includes some functionality that we will reuse when writing a script to fetch uv downloads.
A simple, probably not very efficient, script to generate rust code referencing the most recent uv version download. This will be used for bootstrapping rye.
We move the current sources into sources::py to distinguish it from the upcoming sources::uv. This is quite a big refactor, but it's worthwhile to keep python and other potential bootstrapping tools separated. Notable we also introduce a directory sources/generated which includes all generated download urls.
d54747c
to
04d6b54
Compare
The PR works with TODO:
|
Okay the pull request as is works with pip-tools. There is an open question regarding pip-tools handling. At the moment pip-tools bootstraps into $RYE_HOME/pip-tools since we need it to bootstrap $RYE_HOME/self. However, since we now bootstrap with uv, we could just add |
I ran some basic local tests, both with uv bootstrapping:
|
The issue is that pip-tools needs a fresh venv matching the target python version :( Cannot be installed into the global venv. |
Right. Let's keep it then how it is. There is a good chance I've missed a piece to the puzzle, but with my basic testing the PR is good for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The uv==0.1.9
line in the self requirements at this point probably should be removed. Otherwise you end up with two uvs for no good reason.
rye/src/bootstrap.rs
Outdated
// Request a download for the default uv binary for this platform. | ||
// For instance on aarch64 macos this will request a compatible uv version. | ||
let download = UvDownload::try_from(UvRequest::default())?; | ||
let uv_dir = get_app_dir().join("uv").join(download.version()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there much of a benefit of having multiple uv versions and not just to retain only the latest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason here is that i can check for the version with one simple stat
call and not have to execv
uv. This allows me in later changes to make use of ensure_exists
to obtain a Uv
on any code path. It also opens the door for pinning uv if we ever need to (I don't see why, but it feels more future proof). I am happy to just nuke the uv directory before I download a new version which will keep it clean for now. If you insist i can remove the version.
Other than the few nits I think this looks good. Also makes for a quicker bootstrap process. I think a good followup would be to make the virtualenv quiet as it now spits out some quite confusing output during installation:
Since that env really only exists internally I don't think it makes sense to reveal where it is and how it's being activated. |
Okay that makes sense. This will add a few more changes as we rely on uv being in |
Add a uv struct that will hold our bootstrapping functionality. We implement a simple function to ensure we have a uv binary at all times.
We move the handling of the UV installation to it's own module, so that we can reuse it for when we currently use the installed uv into self.
Okay changes made: I keep self-venv creation is now using CommandOutput::Quiet to surpress any call to uv during the process. |
Looks good! |
This is the commit that made it so I really do not like the fact that it now means that a properly configured tool now has to point to an absolute path and it needs to be edited should |
@ImportTaste what about all other non-relocatable things in a python virtualenv, is there a solution for them? Let's say I inspect for example ~/.rye/self/bin/pip3 and find that its shebang has an absolute path as well to the python in the venv, this is typically how virtual environments work unfortunately(!). But since it's a long standing issue, I could see there could be tools to "relocate" them. In my experience, python virtual environments need to be recreated and can't be relocated unfortunately. |
I wasn't aware of that. I guess nevermind then. |
NOTE This is the first iteration on the PR. There is probably a bunch to clean up. Nevertheless I am happy to get early feedback and iterate.
This PR aims to remove pip-tools with uv. We do this by:
At the moment we only include one version of uv in the rye binary and ensure this one is used for bootstrapping (multiple versions can co-exists in $RYE_HOME/uv)
Open questions:
--use-uv
for a while?