diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 736f1484..5d30a931 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -232,26 +232,21 @@ def setup_python( sys.exit(1) # ensure pip is installed - 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", - ) + call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") - # ensure we have the version that matches our constraints + # 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() call( - ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], + [ + "python", + "-m", + "pip", + "install", + "--force-reinstall" if requires_reinstall else "--upgrade", + "pip", + *dependency_constraint_flags, + ], env=env, cwd="/tmp", ) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 259af70e..699a4406 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -176,25 +176,21 @@ def setup_python( log.step("Installing build tools...") # ensure pip is installed - 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, - ) + call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") - # ensure we have the version that matches our constraints + # 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() call( - ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], + [ + "python", + "-m", + "pip", + "install", + "--force-reinstall" if requires_reinstall else "--upgrade", + "pip", + *dependency_constraint_flags, + ], env=env, )