Skip to content

Conversation

@Boulaouaney
Copy link

Summary

Adds support for the uv package manager to both Unix and Windows installation scripts, providing 10-100x faster package installation while maintaining full backwards compatibility with pip.

Changes

  • Unix (install.sh): Added ensure_uv() function and uv-based venv/package installation
  • Windows (install.ps1): Added Install-Uv function and uv-based installation flow
  • Both scripts gracefully fall back to pip if uv installation fails
  • Added --no-uv flag (Unix) and -NoUv parameter (Windows) to explicitly use pip
  • Added HF_CLI_USE_UV environment variable (defaults to true)

Benefits

  • Significantly faster installation times (10-100x speedup in package resolution and installation)
  • Better dependency resolution
  • Zero breaking changes - existing workflows continue to work
  • Automatic fallback ensures reliability

Testing

Tested on:

  • ✅ Windows (local)
  • ✅ Linux server (local)

Both platforms work correctly with uv enabled and fall back gracefully to pip when needed.

Backwards Compatibility

  • All existing flags, parameters, and environment variables work unchanged
  • Users who don't have uv will automatically use pip
  • Explicit opt-out available via --no-uv / -NoUv or environment variable

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.
Copy link
Contributor

@Wauplin Wauplin left a 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!

Comment on lines +21 to +23
.PARAMETER NoUv
Use pip instead of uv for package installation.
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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) {
Copy link
Contributor

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remove comments

Comment on lines +42 to +43
USE_UV="${HF_CLI_USE_UV:-true}"
UV_INSTALLED="false"
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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() {
Copy link
Contributor

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

@Boulaouaney
Copy link
Author

@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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants