This commit is contained in:
Joe Rickerby
2021-05-09 10:20:51 +01:00
parent 0838df4ebb
commit f5046a600e
3 changed files with 13 additions and 17 deletions
+1 -1
View File
@@ -231,7 +231,7 @@ def setup_python(
) )
sys.exit(1) sys.exit(1)
# install pip # ensure pip is installed
call( call(
["python", "-m", "ensurepip", "--default-pip"], ["python", "-m", "ensurepip", "--default-pip"],
env=env, env=env,
+1 -3
View File
@@ -1,7 +1,7 @@
import os import os
import subprocess import subprocess
import sys import sys
from typing import TYPE_CHECKING, Any, NoReturn, Set, Union from typing import TYPE_CHECKING, NoReturn, Set, Union
if sys.version_info < (3, 8): if sys.version_info < (3, 8):
from typing_extensions import Final, Literal, TypedDict from typing_extensions import Final, Literal, TypedDict
@@ -26,11 +26,9 @@ __all__ = (
if TYPE_CHECKING: if TYPE_CHECKING:
PopenBytes = subprocess.Popen[bytes] PopenBytes = subprocess.Popen[bytes]
PathOrStr = Union[str, os.PathLike[str]] PathOrStr = Union[str, os.PathLike[str]]
CompletedProcess = subprocess.CompletedProcess[Any]
else: else:
PopenBytes = subprocess.Popen PopenBytes = subprocess.Popen
PathOrStr = Union[str, "os.PathLike[str]"] PathOrStr = Union[str, "os.PathLike[str]"]
CompletedProcess = subprocess.CompletedProcess
PlatformName = Literal["linux", "macos", "windows"] PlatformName = Literal["linux", "macos", "windows"]
+11 -13
View File
@@ -10,7 +10,7 @@ from zipfile import ZipFile
from .architecture import Architecture from .architecture import Architecture
from .environment import ParsedEnvironment from .environment import ParsedEnvironment
from .logger import log from .logger import log
from .typing import CompletedProcess, PathOrStr from .typing import PathOrStr
from .util import ( from .util import (
BuildOptions, BuildOptions,
BuildSelector, BuildSelector,
@@ -23,15 +23,12 @@ from .util import (
def call( def call(
args: Sequence[PathOrStr], args: Sequence[PathOrStr], env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None
env: Optional[Dict[str, str]] = None, ) -> None:
cwd: Optional[str] = None,
check: bool = True,
) -> CompletedProcess:
print("+ " + " ".join(str(a) for a in args)) print("+ " + " ".join(str(a) for a in args))
# we use shell=True here, even though we don't need a shell due to a bug # we use shell=True here, even though we don't need a shell due to a bug
# https://bugs.python.org/issue8557 # https://bugs.python.org/issue8557
return subprocess.run([str(a) for a in args], env=env, cwd=cwd, shell=True, check=check) subprocess.run([str(a) for a in args], env=env, cwd=cwd, shell=True, check=True)
def shell(command: str, env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None) -> None: def shell(command: str, env: Optional[Dict[str, str]] = None, cwd: Optional[str] = None) -> None:
@@ -181,12 +178,13 @@ def setup_python(
# make sure pip is installed and available on PATH # make sure pip is installed and available on PATH
if not (installation_path / "Scripts" / "pip.exe").exists(): if not (installation_path / "Scripts" / "pip.exe").exists():
# perhaps pip is installed, but not available as 'pip.exe'... # perhaps pip is installed, but not available as 'pip.exe'...
pip_is_installed = ( try:
call( call(["python", "-m", "pip", "--version"], env=env, cwd="C:\\cibw")
["python", "-m", "pip", "--version"], env=env, cwd="C:\\cibw", check=False except subprocess.CalledProcessError:
).returncode pip_is_installed = False
== 0 else:
) pip_is_installed = True
if pip_is_installed: if pip_is_installed:
# if it's there, remove that version of pip. # if it's there, remove that version of pip.
call(["python", "-m", "pip", "uninstall", "--yes", "pip"], env=env, cwd="C:\\cibw") call(["python", "-m", "pip", "uninstall", "--yes", "pip"], env=env, cwd="C:\\cibw")