diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 9b4a1ec7..86fc4529 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -232,11 +232,22 @@ def setup_python( sys.exit(1) # ensure pip is installed - call( - ["python", "-m", "ensurepip", "--default-pip"], - env=env, - cwd="/tmp", - ) + if not (installation_bin_path / "pip").exists(): + # perhaps pip is installed, but not available as 'pip'... + try: + call(["python", "-m", "pip", "--version"], env=env, cwd="/tmp") + except subprocess.CalledProcessError: + pip_is_installed = False + else: + pip_is_installed = True + + if pip_is_installed: + # if it's there, remove that version of pip. + call(["python", "-m", "pip", "uninstall", "--yes", "pip"], env=env, cwd="C:\\cibw") + + # Then reinstall. '--default-pip' ensures that it's installed as 'pip' + call(["python", "-m", "ensurepip", "--default-pip"], env=env, cwd="C:\\cibw") + # ensure we have the version that matches our constraints call( ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags],