Skip to content

Comments

Add support for uv-based venvs/install via PRE_COMMIT_USE_UV#3131

Closed
akx wants to merge 1 commit intopre-commit:mainfrom
akx:uv
Closed

Add support for uv-based venvs/install via PRE_COMMIT_USE_UV#3131
akx wants to merge 1 commit intopre-commit:mainfrom
akx:uv

Conversation

@akx
Copy link

@akx akx commented Feb 19, 2024

This PR adds opt-in support for creating Python virtualenvs (and installing dependencies within them) using uv, using the environment variable PRE_COMMIT_USE_UV (in the vein of PRE_COMMIT_USE_MAMBA or PRE_COMMIT_USE_MICROMAMBA).

There are some caveats related to uv's freshness (see comments in code), but this seems to work.

On my machine, this seems to make setting up Python environments quite a bit faster (which, of course, should not happen very often, but when it does, it's nice that it happens a bit quicker).

(babel) ~/b/babel (master) $ hyperfine 'pre-commit clean && pre-commit run --all-files'
Benchmark 1: pre-commit clean && pre-commit run --all-files
  Time (mean ± σ):      5.570 s ±  0.051 s    [User: 4.020 s, System: 1.855 s]
  Range (min … max):    5.494 s …  5.639 s    10 runs

(babel) ~/b/babel (master) $ env PRE_COMMIT_USE_UV=1 hyperfine 'pre-commit clean && pre-commit run --all-files'
Benchmark 1: pre-commit clean && pre-commit run --all-files
  Time (mean ± σ):      3.832 s ±  0.107 s    [User: 2.978 s, System: 1.316 s]
  Range (min … max):    3.725 s …  4.069 s    10 runs

@asottile
Copy link
Member

please discuss features first before wasting time on implementation

this is unlikely to make a significant difference but greatly increases complexity so I am declining it

@asottile asottile closed this Feb 19, 2024
@akx
Copy link
Author

akx commented Feb 19, 2024

please discuss features first before wasting time on implementation

Sorry, I didn't see that discussion was required for PRs (can't seem to find that in the contribution guidelines either).

If it makes you feel better, I only spent 20 minutes on this. 😄

this is unlikely to make a significant difference but greatly increases complexity so I am declining it

I'd disagree on "greatly", but as you like.

@pre-commit pre-commit deleted a comment from akx Aug 6, 2024
@pre-commit pre-commit locked as off-topic and limited conversation to collaborators Aug 6, 2024
@asottile
Copy link
Member

asottile commented Aug 6, 2024

the issue tracker is not an advertisement portal for unsupported hacks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants