From 5c33d08138e5fd387ddad49ee0f35a007fe14257 Mon Sep 17 00:00:00 2001 From: Priyagupta108 Date: Thu, 23 Apr 2026 17:44:12 +0530 Subject: [PATCH] Check pip availability before running ensurepip --- installers/macos-pkg-setup-template.sh | 4 +++- installers/nix-setup-template.sh | 4 +++- installers/win-setup-template.ps1 | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/installers/macos-pkg-setup-template.sh b/installers/macos-pkg-setup-template.sh index a6c909ee..bc477f99 100644 --- a/installers/macos-pkg-setup-template.sh +++ b/installers/macos-pkg-setup-template.sh @@ -84,7 +84,9 @@ chmod +x $PYTHON_MAJOR $PYTHON_MAJOR_DOT_MINOR $PYTHON_MAJOR_MINOR python echo "Upgrading pip..." export PIP_ROOT_USER_ACTION=ignore -./python -m ensurepip +if ! ./python -c "import pip" 2>/dev/null; then + ./python -m ensurepip +fi ./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location echo "Install OpenSSL certificates" diff --git a/installers/nix-setup-template.sh b/installers/nix-setup-template.sh index d452ca3f..16389f60 100644 --- a/installers/nix-setup-template.sh +++ b/installers/nix-setup-template.sh @@ -51,7 +51,9 @@ chmod +x ../python $PYTHON_MAJOR $PYTHON_MAJOR_DOT_MINOR $PYTHON_MAJORMINOR pyth echo "Upgrading pip..." export PIP_ROOT_USER_ACTION=ignore -./python -m ensurepip +if ! ./python -c "import pip" 2>/dev/null; then + ./python -m ensurepip +fi ./python -m pip install --upgrade --force-reinstall pip --disable-pip-version-check --no-warn-script-location echo "Create complete file" diff --git a/installers/win-setup-template.ps1 b/installers/win-setup-template.ps1 index 4f7b5f1e..08a7040c 100644 --- a/installers/win-setup-template.ps1 +++ b/installers/win-setup-template.ps1 @@ -138,7 +138,11 @@ New-Item -Path "$PythonArchPath\python3.exe" -ItemType SymbolicLink -Value "$Pyt Write-Host "Install and upgrade Pip" $Env:PIP_ROOT_USER_ACTION = "ignore" $PythonExePath = Join-Path -Path $PythonArchPath -ChildPath "python.exe" -cmd.exe /c "$PythonExePath -m ensurepip && $PythonExePath -m pip install --upgrade --force-reinstall pip --no-warn-script-location" +cmd.exe /c "$PythonExePath -c ""import pip""" +if ($LASTEXITCODE -ne 0) { + cmd.exe /c "$PythonExePath -m ensurepip" +} +cmd.exe /c "$PythonExePath -m pip install --upgrade --force-reinstall pip --no-warn-script-location" if ($LASTEXITCODE -ne 0) { Throw "Error happened during pip installation / upgrade" }