-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
feat: add a uv backend #762
Conversation
cd93c8e
to
c70b9d7
Compare
I pulled your changes in here, thanks @alex! (Nice username, by the way!) |
Happy to help! Looking forward to this. |
6a589b0
to
5d4b3ac
Compare
I'm thinking a nice followup could be to allow fallback backends. So |
cfaae4b
to
98a55ca
Compare
Is there a way to ignore a line from coverage only on Python 3.7? |
|
I don't believe there's a way to skip coverage by python version with just coverage.py. I think you have two choices:
|
62ab776
to
8528ea2
Compare
@FollowTheProcess, @DiddiLeija, @cjolowicz, or @theacodes, I think this is ready. Also, there are quite a few other PRs that are basically ready and useful to have open too! |
Also, Tox added UV support yesterday: https://github.com/tox-dev/tox-uv |
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.
Fantastic work! Thank you all! My 3 cents:
Also, thanks @skshetry for pointing out that bug in
Yes! 💯 That would be great! |
nox/virtualenv.py
Outdated
elif self.venv_backend == "uv": # pragma: >=3.8 cover | ||
cmd = [ | ||
"uv", | ||
"virtualenv", |
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.
"virtualenv", | |
"virtualenv", | |
"--seed", |
See point 3 in #762 (comment)
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.
IMO, there's no need for pip (or setuptools or wheel for Python <3.11) in the environments - since we have .install
instead of manually interacting with pip (hurray!), we don't have to guarantee pip is present (especially since this is opt-in; if we change the default to use uv if present, then we could install pip for back-compat purposes, maybe). Someone can install with session.install("pip")
.
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.
(I think the issue in 3. is still solvable, by the way, another way)
I kind of forgot about docs because I was initially just making it work, will add! |
@henryiii nice work! Sorry been a bit swamped recently and haven't had much time to look at Nox too much. I think once the docs get an update calling out the "no pip" behaviour as mentioned above then I'm happy and excited to get this in 👍🏻 |
@slafs: Thanks! I've addressed (1) and (2). I think I also fixed (3) by detecting |
Thank you for following through on this! Is there a good place to follow along in terms of when this will be in a release? |
Watch -> Custom -> releases (in the GH UI) is what I do. You can also get GitHub Releases via RSS, though I don't use that much anymore. I think we have a few small followups (rebuild on env change & environment fallback, maybe #776), and we might want #768 as I'd like the action to work on the new AS runners, but after that I think @theacodes has said that a release is in the near future. |
Thanks
…On Fri, Feb 23, 2024 at 12:19 PM Henry Schreiner ***@***.***> wrote:
Watch -> Custom -> releases (in the GH UI) is what I do. You can also get
GitHub Releases via RSS, though I don't use that much anymore.
I think we have a few small followups (rebuild on env change & environment
fallback, maybe #776 <#776>), and we
might want #768 <#768> as I'd like the
action to work on the new AS runners, but after that I think @theacodes
<https://github.com/theacodes> has said that a release is in the near
future.
—
Reply to this email directly, view it on GitHub
<#762 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBBJ6VK4G7NC3RAIG4TYVDFSPAVCNFSM6AAAAABDMYCT5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRG4YDONZXGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
FYI, release is out (including on PyPI and homebrew). I've been setting After the new release is out for a bit I may start moving over to the new |
Thank you!
…On Mon, Mar 4, 2024 at 11:48 AM Henry Schreiner ***@***.***> wrote:
FYI, release is out (including on PyPI and homebrew). I've been setting
NOX_DEFAULT_VENV_BACKEND=uv and it's *so* fast. It's also teaching me
where I unknowingly had dependencies on pip and need to it listed
explicitly.
After the new release is out for a bit I may start moving over to the new
uv|virtualenv syntax.
—
Reply to this email directly, view it on GitHub
<#762 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBE2O77KAZL5FHD3TNLYWSQWZAVCNFSM6AAAAABDMYCT5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZXGAZDQNZVGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
All that is necessary for evil to succeed is for good people to do nothing.
|
## [0.0.20](v0.0.19...v0.0.20) (2024-03-04) ### Chores * **deps:** bump wntrblm/nox from 2023.04.22 to 2024.03.02 ([#57](#57)) ([d177375](d177375)), closes [wntrblm/nox#762](wntrblm/nox#762) [wntrblm/nox#787](wntrblm/nox#787) [wntrblm/nox#730](wntrblm/nox#730) [wntrblm/nox#780](wntrblm/nox#780) [wntrblm/nox#770](wntrblm/nox#770) [wntrblm/nox#707](wntrblm/nox#707) [wntrblm/nox#687](wntrblm/nox#687) [wntrblm/nox#756](wntrblm/nox#756) [wntrblm/nox#652](wntrblm/nox#652) [wntrblm/nox#712](wntrblm/nox#712) [wntrblm/nox#781](wntrblm/nox#781) [wntrblm/nox#786](wntrblm/nox#786) [wntrblm/nox#684](wntrblm/nox#684) [wntrblm/nox#723](wntrblm/nox#723) [wntrblm/nox#725](wntrblm/nox#725) [wntrblm/nox#714](wntrblm/nox#714) [wntrblm/nox#715](wntrblm/nox#715) [wntrblm/nox#696](wntrblm/nox#696) [wntrblm/nox#774](wntrblm/nox#774) [wntrblm/nox#782](wntrblm/nox#782) [wntrblm/nox#722](wntrblm/nox#722) [wntrblm/nox#724](wntrblm/nox#724) [wntrblm/nox#721](wntrblm/nox#721) [wntrblm/nox#744](wntrblm/nox#744) [wntrblm/nox#738](wntrblm/nox#738) [wntrblm/nox#762](wntrblm/nox#762) [wntrblm/nox#787](wntrblm/nox#787) [wntrblm/nox#730](wntrblm/nox#730) [wntrblm/nox#780](wntrblm/nox#780) [wntrblm/nox#770](wntrblm/nox#770) [wntrblm/nox#707](wntrblm/nox#707) [wntrblm/nox#687](wntrblm/nox#687) [wntrblm/nox#756](wntrblm/nox#756) [wntrblm/nox#652](wntrblm/nox#652) [wntrblm/nox#712](wntrblm/nox#712) [wntrblm/nox#781](wntrblm/nox#781) [wntrblm/nox#786](wntrblm/nox#786) [wntrblm/nox#684](wntrblm/nox#684) [wntrblm/nox#723](wntrblm/nox#723) [wntrblm/nox#725](wntrblm/nox#725) [wntrblm/nox#714](wntrblm/nox#714) [wntrblm/nox#715](wntrblm/nox#715) [wntrblm/nox#696](wntrblm/nox#696) [wntrblm/nox#774](wntrblm/nox#774) [wntrblm/nox#782](wntrblm/nox#782) [wntrblm/nox#722](wntrblm/nox#722) [wntrblm/nox#724](wntrblm/nox#724) [wntrblm/nox#721](wntrblm/nox#721) [wntrblm/nox#744](wntrblm/nox#744) [#789](https://github.com/msclock/sphinx-deployment/issues/789) [#787](https://github.com/msclock/sphinx-deployment/issues/787) [#786](https://github.com/msclock/sphinx-deployment/issues/786) [#781](https://github.com/msclock/sphinx-deployment/issues/781) [#784](https://github.com/msclock/sphinx-deployment/issues/784) [#780](https://github.com/msclock/sphinx-deployment/issues/780) [#730](https://github.com/msclock/sphinx-deployment/issues/730) [#782](https://github.com/msclock/sphinx-deployment/issues/782) [#783](https://github.com/msclock/sphinx-deployment/issues/783) [#762](https://github.com/msclock/sphinx-deployment/issues/762) ### CI * set proper permission for preview job ([#56](#56)) ([d65e8a1](d65e8a1))
Looking at this feature now it's been released, I have a couple of comments.
|
I've been wondering if we shouldn't support using an external pip in a more seamless way. |
I'd be fine with that.
…On Wed, Mar 6, 2024 at 9:42 AM Claudio Jolowicz ***@***.***> wrote:
I've been wondering if we shouldn't support using an external pip in a
more seamless way.
—
Reply to this email directly, view it on GitHub
<#762 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAB5I47DKXZ73HFKRFETVGDYW4TNLAVCNFSM6AAAAABDMYCT5KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRGAZDGNBUG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
That said, IIUC every |
Does the
Assuming there's a pip available in the environment nox is installed in, and it's sufficiently recent, you could easily use that pip (with the I'd be willing to look at putting together a PR to do this, if there's interest. I've not contributed to the nox codebase before, so advice (in particular on the best user interface) would be welcome. |
Build 1.1 uses external pip if it can automatically. But of course, nox users can interact with pip. I’m wondering if the following would be seamless enough:
Not installing pip only makes the setup faster, and it’s only about half a second for virtualenv (the default). That’s an absolute time, so great for simple environments, not as noticeable for big ones. We have to pay the Python startup cost every Pip interaction due to no public API, also in build, etc. ;) By the way, another speedup is uv doesn’t compile bytecode by default. For build, this makes sense, as you really just want to compile what you use and anything else is wasted. But not sure for nox. Most of the time, that probably is desired, but if you make a dev environment, it’s better to precompile. I’d want to measure the cost first, but it’s apparently enough that uv didn’t want to make it default. |
Yes, “venv-backend” also controls the installer. We didn’t have multiple installers before uv. Technically, you could mix and match, but it keeps the interface simpler. You can always install pip or uv in the other’s environment. uv’s start up time is less than Python. In fact, it can finish making an empty venv before |
Why twice? |
This difference is somewhere in the region of ~20 ms on my machine FWIW, which is outside the realm of the perceptible. |
On the topic of build, readers might also be interested in pypa/build#751, adding support for uv. |
Fair enough. The documentation doesn't make this clear, which was the original point I was trying to make, and it suggests that the environment creation gains with uv are because it's simply faster, rather than actually being because it doesn't install pip. Claiming "uv environment creation is faster" is a sore point for me, as I specifically implemented the I think that mixing the two aspects might have been a mistake, and having a way to configure install backends (which could be "uv", "external pip" and "internal pip", plus whatever conda options apply) independently of environment creation options would have made it easier for the trade-offs to be presented. In practice, I imagine no-one will care that much about environment creation times, apart from eliminating the cost of installing pip (as @layday said, any remaining cost differences are imperceptible), but they will care about the time vs compatibility trade-offs with installation. Anyway, as I said I'd be willing to help separate the venv-backend and install-backend behaviours, and make using an external pip more convenient, if that's something that people are interested in. But I don't want to force that on people if there's going to be a lot of pushback on the UI aspects. |
To add, I don't know how nox creates venvs, but I assume you'd be importing the |
FYI, @pfmoore, https://fosstodon.org/@henryiii/112039400189486890 / https://twitter.com/HenrySchreiner3/status/1764755669461148138 is entirely from the |
Nox uses virtualenv by default, though there is an option to use |
Yeah, thanks - those savings in
That's an interesting point. I did a benchmark:
Averaged over 100 runs, venv took 0.007626 seconds, and uv took 0.072377 seconds. So yes, there's a significant speed benefit from using That's on Windows with Python 3.12.0. On Lunix (Ubuntu under WSL) venv was 0.001832 sec, uv was 0.564309 sec. I'm going to assume that's something to do with WSL, as otherwise that's a terrible result... Although a docker container with Python 3.12 is just as slow - I don't have a bare Linux machine to test on that.
Ouch, yes there is. Running venv in a subprocess takes 15 times longer than running it in-process. Here's my benchmarking script, for what it's worth: https://gist.github.com/pfmoore/a5406e0901609ed08cab8a0719d4e866 |
If we had independent venv and install backends, I'd say that in-process venv would be fastest env creation backend in nearly all cases, with uv being the fastest install backend and As I said, there's trade-offs 😉 |
Doh. I'm incredibly dense. nox relies on being able to create virtual environments for arbitrary Python versions, so in-process venv creation isn't possible except in extremely limited cases. My apologies, most of what I've said above isn't of any practical use for this project (although IMO it's still interesting in the broader sense of how to create an environment as fast as possible). |
As am I. I was thinking of how it works in build 🥲 |
Doesn't |
Add me to the list. :)
Ah, yes, if that's how it works.
I believe the documentation has a red warning box that says "The uv backend does not install anything by default, including pip, as Also, it doesn't mention anything about speed at all. Nothing is claimed to be faster and no advice is given on picking a backend. Even the changelog doesn't mention speed. |
Huh, you're right. I guess I simply took that from the initial comment here. My apologies - there's been a lot of hype about how fast My track record today is pretty bad, time to stop I think... |
UV just came out from the Ruff folks, and it's insanely fast - it makes venvs faster (25ms) than Python can start up (50ms). And much faster than virtualenv (400ms) and venv (nearly 5 seconds). The package install speeds are also unreal compared to pip.
There are some differences - namely
name @ .
is required instead of.
if an install is not editable (for now). But it's really nice to try it out!0001-1698.mp4
Nox's docs build in 4 seconds instead of 22 seconds using the uv backend.