Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions utils/installers/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,34 @@ 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 ($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)"
}
$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, $packageSpec)
if ($env:HF_CLI_VERBOSE_PIP -ne '1') {
$uvArgs += '--quiet'
}

& uv @uvArgs
if (-not $?) { throw "Failed to install huggingface_hub with uv" }
}
else {
# 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 ($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)"
}
$pipArgs += $packageSpec
if ($extraArgsRaw) {
Write-Log "Passing extra pip arguments: $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 {
Expand Down Expand Up @@ -347,8 +360,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"
Expand Down Expand Up @@ -418,4 +431,4 @@ $null = Register-ObjectEvent -InputObject ([Console]) -EventName CancelKeyPress
}

# Run main function
Main
Main
45 changes: 29 additions & 16 deletions utils/installers/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -287,28 +287,41 @@ install_hf_hub() {
log_info "Installing The Hugging Face CLI (latest)..."
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=()
# 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 [ "${HF_CLI_VERBOSE_PIP:-}" = "1" ]; then
uv_flags=()
else
uv_flags=(--quiet)
fi

run_command "Failed to install $package_spec" uv pip install --python "$VENV_DIR/bin/python" ${uv_flags[*]} "$package_spec"
else
pip_flags=(--quiet --progress-bar off --disable-pip-version-check)
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

if [ -n "$extra_pip_args" ]; then
log_info "Passing extra pip arguments: $extra_pip_args"
fi
if [ -n "$extra_pip_args" ]; then
log_info "Passing extra pip 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"
fi

if [ -n "$extra_pip_args" ]; then
# 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
else
# shellcheck disable=SC2086
run_command "Failed to install $package_spec" "$VENV_DIR/bin/python" -m pip install --upgrade "$package_spec" ${pip_flags[*]}
if [ -n "$extra_pip_args" ]; then
# 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
else
# shellcheck disable=SC2086
run_command "Failed to install $package_spec" "$VENV_DIR/bin/python" -m pip install --upgrade "$package_spec" ${pip_flags[*]}
fi
fi
}

Expand Down Expand Up @@ -512,4 +525,4 @@ main() {
# Handle Ctrl+C
trap 'log_error "Installation interrupted"; exit 130' INT

main "$@"
main "$@"