Force install pip

This commit is contained in:
mayeut
2021-05-13 20:32:38 +02:00
parent a116c2e486
commit ee5dfc6f90
2 changed files with 11 additions and 37 deletions
+3 -17
View File
@@ -232,25 +232,11 @@ def setup_python(
sys.exit(1) sys.exit(1)
# ensure pip is installed # ensure pip is installed
if not (installation_bin_path / "pip").exists(): call(["python", "-m", "ensurepip"], env=env, cwd="/tmp")
# 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")
# ensure we have the version that matches our constraints # ensure we have the version that matches our constraints
# use "--force-install" ensures that it's installed as 'pip'
call( call(
["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags], ["python", "-m", "pip", "install", "--force-install", "pip", *dependency_constraint_flags],
env=env, env=env,
cwd="/tmp", cwd="/tmp",
) )
+8 -20
View File
@@ -175,22 +175,14 @@ def setup_python(
log.step("Installing build tools...") log.step("Installing build tools...")
# make sure pip is installed and available on PATH # ensure pip is installed
if not (installation_path / "Scripts" / "pip.exe").exists(): call(["python", "-m", "ensurepip"], env=env, cwd="C:\\cibw")
# perhaps pip is installed, but not available as 'pip.exe'... # ensure we have the version that matches our constraints
try: # use "--force-install" ensures that it's installed as 'pip.exe'
call(["python", "-m", "pip", "--version"], env=env, cwd="C:\\cibw") call(
except subprocess.CalledProcessError: ["python", "-m", "pip", "install", "--force-install", "pip", *dependency_constraint_flags],
pip_is_installed = False env=env,
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")
assert (installation_path / "Scripts" / "pip.exe").exists() assert (installation_path / "Scripts" / "pip.exe").exists()
where_pip = ( where_pip = (
@@ -207,10 +199,6 @@ def setup_python(
) )
sys.exit(1) sys.exit(1)
call(
["python", "-m", "pip", "install", "--upgrade", "pip", *dependency_constraint_flags],
env=env,
)
call(["pip", "--version"], env=env) call(["pip", "--version"], env=env)
call( call(
["pip", "install", "--upgrade", "setuptools", "wheel", *dependency_constraint_flags], ["pip", "install", "--upgrade", "setuptools", "wheel", *dependency_constraint_flags],