diff --git a/utils/installers/install.ps1 b/utils/installers/install.ps1 index 71b89bb62a..5ca2e6b8b6 100644 --- a/utils/installers/install.ps1 +++ b/utils/installers/install.ps1 @@ -245,21 +245,50 @@ function Install-HuggingFaceHub { } if (-not $script:VenvPython) { $script:VenvPython = Join-Path $SCRIPTS_DIR "python.exe" } - # Allow optional pip arguments via HF_CLI_PIP_ARGS/HF_PIP_ARGS env vars $extraArgsRaw = if ($env:HF_CLI_PIP_ARGS) { $env:HF_CLI_PIP_ARGS } else { $env:HF_PIP_ARGS } - $pipArgs = @('-m', 'pip', 'install', '--upgrade') + + if ($extraArgsRaw) { + Write-Log "Passing extra arguments: $extraArgsRaw" + } + if ($env:HF_CLI_VERBOSE_PIP -ne '1') { - $pipArgs += @('--quiet', '--progress-bar', 'off', '--disable-pip-version-check') - Write-Log "(pip output suppressed; set HF_CLI_VERBOSE_PIP=1 for full logs)" + Write-Log "Installation output suppressed; set HF_CLI_VERBOSE_PIP=1 for full logs" } - $pipArgs += $packageSpec - if ($extraArgsRaw) { - Write-Log "Passing extra pip arguments: $extraArgsRaw" - $pipArgs += $extraArgsRaw -split '\s+' + + # Check if uv is available and use it for faster installation + if (Test-Command "uv") { + Write-Log "Using uv for faster installation" + $uvArgs = @('pip', 'install', '--python', $script:VenvPython, '--upgrade') + + if ($env:HF_CLI_VERBOSE_PIP -ne '1') { + $uvArgs += '--quiet' + } + + $uvArgs += $packageSpec + + if ($extraArgsRaw) { + $uvArgs += $extraArgsRaw -split '\s+' + } + + & uv @uvArgs + if (-not $?) { throw "Failed to install huggingface_hub with uv" } } + else { + $pipArgs = @('-m', 'pip', 'install', '--upgrade') + + if ($env:HF_CLI_VERBOSE_PIP -ne '1') { + $pipArgs += @('--quiet', '--progress-bar', 'off', '--disable-pip-version-check') + } + + $pipArgs += $packageSpec + + if ($extraArgsRaw) { + $pipArgs += $extraArgsRaw -split '\s+' + } - & $script:VenvPython @pipArgs - if (-not $?) { throw "Failed to install huggingface_hub" } + & $script:VenvPython @pipArgs + if (-not $?) { throw "Failed to install huggingface_hub" } + } } function Publish-HfCommand { @@ -347,8 +376,8 @@ function Show-UninstallInfo { Write-Log "" Write-Log "To uninstall the Hugging Face CLI:" Write-Log " Remove-Item -Path '$HF_CLI_DIR' -Recurse -Force" - Write-Log " Remove-Item -Path '$BIN_DIR\\hf.exe'" - Write-Log " Remove-Item -Path '$BIN_DIR\\hf-script.py' (if present)" + Write-Log " Remove-Item -Path '$BIN_DIR\hf.exe'" + Write-Log " Remove-Item -Path '$BIN_DIR\hf-script.py' (if present)" Write-Log "" if ($script:PathUpdated) { Write-Log "Remove '$BIN_DIR' from your user PATH via Settings ▸ Environment Variables," "INFO" diff --git a/utils/installers/install.sh b/utils/installers/install.sh index 82d3af4089..5d04bc656d 100755 --- a/utils/installers/install.sh +++ b/utils/installers/install.sh @@ -288,27 +288,38 @@ install_hf_hub() { fi local extra_pip_args="${HF_CLI_PIP_ARGS:-${HF_PIP_ARGS:-}}" - local -a pip_flags - if [ "${HF_CLI_VERBOSE_PIP:-}" = "1" ]; then - pip_flags=() - else - pip_flags=(--quiet --progress-bar off --disable-pip-version-check) - fi + local verbose="${HF_CLI_VERBOSE_PIP:-}" if [ -n "$extra_pip_args" ]; then - log_info "Passing extra pip arguments: $extra_pip_args" + log_info "Passing extra arguments: $extra_pip_args" fi - if [ "${HF_CLI_VERBOSE_PIP:-}" != "1" ]; then - log_info "pip output suppressed; set HF_CLI_VERBOSE_PIP=1 for full logs" + if [ "$verbose" != "1" ]; then + log_info "Installation output suppressed; set HF_CLI_VERBOSE_PIP=1 for full logs" fi - if [ -n "$extra_pip_args" ]; then + # Check if uv is available and use it for faster installation + if command_exists uv; then + log_info "Using uv for faster installation" + local -a uv_flags + if [ "$verbose" != "1" ]; then + uv_flags=(--quiet) + else + uv_flags=() + fi + # shellcheck disable=SC2086 - run_command "Failed to install $package_spec" "$VENV_DIR/bin/python" -m pip install --upgrade "$package_spec" ${pip_flags[*]} $extra_pip_args + run_command "Failed to install $package_spec" uv pip install --python "$VENV_DIR/bin/python" --upgrade ${uv_flags[*]} "$package_spec" $extra_pip_args else + local -a pip_flags + if [ "$verbose" != "1" ]; then + pip_flags=(--quiet --progress-bar off --disable-pip-version-check) + else + pip_flags=() + fi + # shellcheck disable=SC2086 - run_command "Failed to install $package_spec" "$VENV_DIR/bin/python" -m pip install --upgrade "$package_spec" ${pip_flags[*]} + run_command "Failed to install $package_spec" "$VENV_DIR/bin/python" -m pip install --upgrade "$package_spec" ${pip_flags[*]} $extra_pip_args fi }