-
Notifications
You must be signed in to change notification settings - Fork 837
Add uv support to installation scripts for faster package installation #3486
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
base: main
Are you sure you want to change the base?
Conversation
Added support for uv package manager installation and updated installation logic to use uv if available. Modified logging and error handling for better user guidance.
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.
Hi @Boulaouaney , thanks for your interest and for the PR! I like the idea of using uv if it exists but don't think we should add new parameters to the scripts. Also please modify only the parts related to this PR (i.e. do not remove comments or alter existing logic). I have left a few comments to guide you a bit.
If this PR is AI-generated, please let us know in advance and please review the AI-generated diff' to check it really makes sense.
Thanks in advance!
| .PARAMETER NoUv | ||
| Use pip instead of uv for package installation. | ||
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 don't think we need a parameter for that (too many parameter bloats the API). Let's use uv by default when it exists and that's it
| HF_HOME Installation base directory; installer uses $env:HF_HOME\cli when set | ||
| HF_CLI_BIN_DIR Directory for the hf wrapper (default: $env:USERPROFILE\.local\bin) | ||
| HF_CLI_VERSION Install a specific huggingface_hub version (default: latest) | ||
| HF_CLI_USE_UV Use uv for package installation (default: true) |
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.
Same here, I would remove HF_CLI_USE_UV env variable
| $env:HF_CLI_VERBOSE_PIP = '1' | ||
| } | ||
|
|
||
| # Set error action preference |
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.
can you put back these comments please?
| throw "Python 3.9+ not found" | ||
| } | ||
|
|
||
| function Install-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.
let's not install uv, just use it if already installed
|
|
||
| # Fail fast when venv module is unavailable | ||
| try { | ||
| if ($script:UseUv) { |
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.
Let's not create the venv with uv. The current venv creation logic is already good and fast enough
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' # No Color | ||
| NC='\033[0m' |
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.
don't remove comments
| USE_UV="${HF_CLI_USE_UV:-true}" | ||
| UV_INSTALLED="false" |
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.
let's not add environment variables
| --force Recreate the Hugging Face CLI virtual environment if it exists | ||
| --no-modify-path Skip adding the hf wrapper directory to PATH | ||
| -v, --verbose Enable verbose output (includes full pip logs) | ||
| --no-uv Use pip instead of uv for package installation |
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.
same
| HF_HOME Installation base directory; installer uses $HF_HOME/cli when set | ||
| HF_CLI_BIN_DIR Directory for the hf wrapper (default: ~/.local/bin) | ||
| HF_CLI_VERSION Install a specific huggingface_hub version (default: latest) | ||
| HF_CLI_USE_UV Use uv for package installation (default: true) |
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.
same
| } | ||
|
|
||
| # Create directories | ||
| ensure_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.
logic to be updated to avoid using USE_UV env variable
|
@Wauplin thanks for the detailed feedback! I did indeed use Claude Code to refactor, and tested on my home setup through ssh on my phone as I am currently traveling and don't have direct access to a computer. I will go through and address all your comments as soon as I can. |
Summary
Adds support for the
uvpackage manager to both Unix and Windows installation scripts, providing 10-100x faster package installation while maintaining full backwards compatibility with pip.Changes
ensure_uv()function and uv-based venv/package installationInstall-Uvfunction and uv-based installation flow--no-uvflag (Unix) and-NoUvparameter (Windows) to explicitly use pipHF_CLI_USE_UVenvironment variable (defaults totrue)Benefits
Testing
Tested on:
Both platforms work correctly with uv enabled and fall back gracefully to pip when needed.
Backwards Compatibility
--no-uv/-NoUvor environment variable