From 39302c7c43ff682f0eac1ea8bfe81f426656dcb8 Mon Sep 17 00:00:00 2001 From: Joe Rickerby Date: Sat, 15 May 2021 17:04:39 +0100 Subject: [PATCH] Try adding the existence check before reinstalling --- cibuildwheel/macos.py | 30 +++++++++++++++++++----------- cibuildwheel/windows.py | 28 +++++++++++++++++----------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 0426441c..736f1484 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -232,22 +232,30 @@ def setup_python( sys.exit(1) # ensure pip is installed - call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") + if not (installation_bin_path / "pip").exists(): + call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") + # use "--force-reinstall" ensures that it's installed as 'pip' + call( + [ + "python", + "-m", + "pip", + "install", + "--force-reinstall", + "pip", + *dependency_constraint_flags, + ], + env=env, + cwd="/tmp", + ) + # ensure we have the version that matches our constraints - # use "--force-reinstall" ensures that it's installed as 'pip' call( - [ - "python", - "-m", - "pip", - "install", - "--force-reinstall", - "pip", - *dependency_constraint_flags, - ], + ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], env=env, cwd="/tmp", ) + assert (installation_bin_path / "pip").exists() call(["which", "pip"], env=env) call(["pip", "--version"], env=env) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 42dfc85d..259af70e 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -176,19 +176,25 @@ def setup_python( log.step("Installing build tools...") # ensure pip is installed - call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") + if not (installation_path / "Scripts" / "pip.exe").exists(): + call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") + # use "--force-reinstall" ensures that it's installed as 'pip.exe' + call( + [ + "python", + "-m", + "pip", + "install", + "--force-reinstall", + "pip", + *dependency_constraint_flags, + ], + env=env, + ) + # ensure we have the version that matches our constraints - # use "--force-reinstall" ensures that it's installed as 'pip.exe' call( - [ - "python", - "-m", - "pip", - "install", - "--force-reinstall", - "pip", - *dependency_constraint_flags, - ], + ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], env=env, )