From ee5dfc6f90cc3f0f7006566dfc6fa74108cc2a08 Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 13 May 2021 20:32:38 +0200 Subject: [PATCH] Force install pip --- cibuildwheel/macos.py | 20 +++----------------- cibuildwheel/windows.py | 28 ++++++++-------------------- 2 files changed, 11 insertions(+), 37 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 89180505..41007bf8 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -232,25 +232,11 @@ def setup_python( sys.exit(1) # ensure pip is installed - 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="/tmp") - - # Then reinstall. '--default-pip' ensures that it's installed as 'pip' - call(["python", "-m", "ensurepip", "--default-pip"], env=env, cwd="/tmp") - + call(["python", "-m", "ensurepip"], env=env, cwd="/tmp") # ensure we have the version that matches our constraints + # use "--force-install" ensures that it's installed as 'pip' call( - ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], + ["python", "-m", "pip", "install", "--force-install", "pip", *dependency_constraint_flags], env=env, cwd="/tmp", ) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 3dffbc75..4a87b53a 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -175,22 +175,14 @@ def setup_python( log.step("Installing build tools...") - # make sure pip is installed and available on PATH - if not (installation_path / "Scripts" / "pip.exe").exists(): - # perhaps pip is installed, but not available as 'pip.exe'... - try: - call(["python", "-m", "pip", "--version"], env=env, cwd="C:\\cibw") - 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.exe' - call(["python", "-m", "ensurepip", "--default-pip"], env=env, cwd="C:\\cibw") + # ensure pip is installed + call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw") + # ensure we have the version that matches our constraints + # use "--force-install" ensures that it's installed as 'pip.exe' + call( + ["python", "-m", "pip", "install", "--force-install", "pip", *dependency_constraint_flags], + env=env, + ) assert (installation_path / "Scripts" / "pip.exe").exists() where_pip = ( @@ -207,10 +199,6 @@ def setup_python( ) sys.exit(1) - call( - ["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], - env=env, - ) call(["pip", "--version"], env=env) call( ["pip", "install", "--upgrade", "setuptools", "wheel", *dependency_constraint_flags],