From fd94e77db4cc98bb0100e1324524e3bae89df278 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sun, 16 May 2021 10:56:19 +0100 Subject: [PATCH] Only call ensurepip if bin/pip wasn't found --- cibuildwheel/macos.py | 11 +++++++---- cibuildwheel/windows.py | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 5d30a931..cd6c9d70 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -231,12 +231,15 @@ def setup_python( ) sys.exit(1) - # ensure pip is installed - call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") + # Install pip - # upgrade to the version matching our constraints - # if necessary, reinstall it to ensure that it's installed as 'pip' requires_reinstall = not (installation_bin_path / "pip").exists() + if requires_reinstall: + # maybe pip isn't installed at all. ensurepip resolves that. + call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") + + # upgrade pip to the version matching our constraints + # if necessary, reinstall it to ensure that it's available on PATH as 'pip' call( [ "python", diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 699a4406..04884289 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -175,12 +175,15 @@ def setup_python( log.step("Installing build tools...") - # ensure pip is installed - call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") + # Install pip - # upgrade to the version matching our constraints - # if necessary, reinstall it to ensure that it's installed as 'pip.exe' requires_reinstall = not (installation_path / "Scripts" / "pip.exe").exists() + if requires_reinstall: + # maybe pip isn't installed at all. ensurepip resolves that. + call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") + + # upgrade pip to the version matching our constraints + # if necessary, reinstall it to ensure that it's available on PATH as 'pip.exe' call( [ "python", @@ -192,6 +195,7 @@ def setup_python( *dependency_constraint_flags, ], env=env, + cwd="C:\\cibw", ) assert (installation_path / "Scripts" / "pip.exe").exists()