Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: environment variable affect initial setup macOS/win #956

Merged
merged 2 commits into from Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 17 additions & 14 deletions cibuildwheel/macos.py
Expand Up @@ -192,24 +192,10 @@ def setup_python(
# https://github.com/pypa/virtualenv/issues/620
# Also see https://github.com/python/cpython/pull/9516
env.pop("__PYVENV_LAUNCHER__", None)
env = environment.as_dictionary(prev_environment=env)

# we version pip ourselves, so we don't care about pip version checking
env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"

# check what version we're on
call(["which", "python"], env=env)
call(["python", "--version"], env=env)
which_python = subprocess.run(
["which", "python"], env=env, universal_newlines=True, check=True, stdout=subprocess.PIPE
).stdout.strip()
if which_python != "/tmp/cibw_bin/python":
print(
"cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.",
file=sys.stderr,
)
sys.exit(1)

# Install pip

requires_reinstall = not (installation_bin_path / "pip").exists()
Expand All @@ -233,6 +219,10 @@ def setup_python(
cwd="/tmp",
)

# Apply our environment after pip is ready
env = environment.as_dictionary(prev_environment=env)

# check what pip version we're on
assert (installation_bin_path / "pip").exists()
call(["which", "pip"], env=env)
call(["pip", "--version"], env=env)
Expand All @@ -246,6 +236,19 @@ def setup_python(
)
sys.exit(1)

# check what Python version we're on
call(["which", "python"], env=env)
call(["python", "--version"], env=env)
which_python = subprocess.run(
["which", "python"], env=env, universal_newlines=True, check=True, stdout=subprocess.PIPE
).stdout.strip()
if which_python != "/tmp/cibw_bin/python":
print(
"cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.",
file=sys.stderr,
)
sys.exit(1)

# Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it.
# PyPy defaults to 10.7, causing inconsistencies if it's left unset.
env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9")
Expand Down
51 changes: 26 additions & 25 deletions cibuildwheel/windows.py
Expand Up @@ -157,31 +157,6 @@ def setup_python(
)
env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"

# update env with results from CIBW_ENVIRONMENT
env = environment.as_dictionary(prev_environment=env)

# for the logs - check we're running the right version of python
call(["where", "python"], env=env)
call(["python", "--version"], env=env)
call(["python", "-c", "\"import struct; print(struct.calcsize('P') * 8)\""], env=env)
where_python = (
subprocess.run(
["where", "python"],
env=env,
universal_newlines=True,
check=True,
stdout=subprocess.PIPE,
)
.stdout.splitlines()[0]
.strip()
)
if where_python != str(installation_path / "python.exe"):
print(
"cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.",
file=sys.stderr,
)
sys.exit(1)

log.step("Installing build tools...")

# Install pip
Expand Down Expand Up @@ -230,6 +205,32 @@ def setup_python(
cwd=CIBW_INSTALL_PATH,
)

# update env with results from CIBW_ENVIRONMENT
env = environment.as_dictionary(prev_environment=env)

# check what Python version we're on
call(["where", "python"], env=env)
call(["python", "--version"], env=env)
call(["python", "-c", "\"import struct; print(struct.calcsize('P') * 8)\""], env=env)
where_python = (
subprocess.run(
["where", "python"],
env=env,
universal_newlines=True,
check=True,
stdout=subprocess.PIPE,
)
.stdout.splitlines()[0]
.strip()
)
if where_python != str(installation_path / "python.exe"):
print(
"cibuildwheel: python available on PATH doesn't match our installed instance. If you have modified PATH, ensure that you don't overwrite cibuildwheel's entry or insert python above it.",
file=sys.stderr,
)
sys.exit(1)

# check what pip version we're on
assert (installation_path / "Scripts" / "pip.exe").exists()
where_pip = (
subprocess.run(
Expand Down