8000 fix: environment variable affect initial setup macOS/win (#956) · Develop-Python/cibuildwheel@53b8f81 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53b8f81

Browse files
authored
fix: environment variable affect initial setup macOS/win (pypa#956)
1 parent 3b40094 commit 53b8f81

File tree

2 files changed

+43
-39
lines changed

2 files changed

+43
-39
lines changed

cibuildwheel/macos.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,10 @@ def setup_python(
192192
# https://github.com/pypa/virtualenv/issues/620
193193
# Also see https://github.com/python/cpython/pull/9516
194194
env.pop("__PYVENV_LAUNCHER__", None)
195-
env = environment.as_dictionary(prev_environment=env)
196195

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

200-
# check what version we're on
201-
call(["which", "python"], env=env)
202-
call(["python", "--version"], env=env)
203-
which_python = subprocess.run(
204-
["which", "python"], env=env, universal_newlines=True, check=True, stdout=subprocess.PIPE
205-
).stdout.strip()
206-
if which_python != "/tmp/cibw_bin/python":
207-
print(
208-
"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.",
209-
file=sys.stderr,
210-
)
211-
sys.exit(1)
212-
213199
# Install pip
214200

215201
requires_reinstall = not (installation_bin_path / "pip").exists()
@@ -233,6 +219,10 @@ def setup_python(
233219
cwd="/tmp",
234220
)
235221

222+
# Apply our environment after pip is ready
223+
env = environment.as_dictionary(prev_environment=env)
224+
225+
# check what pip version we're on
236226
assert (installation_bin_path / "pip").exists()
237227
call(["which", "pip"], env=env)
238228
call(["pip", "--version"], env=env)
@@ -246,6 +236,19 @@ def setup_python(
246236
)
247237
sys.exit(1)
248238

239+
# check what Python version we're on
240+
call(["which", "python"], env=env)
241+
call(["python", "--version"], env=env)
242+
which_python = subprocess.run(
243+
["which", "python"], env=env, universal_newlines=True, check=True, stdout=subprocess.PIPE
244+
).stdout.strip()
245+
if which_python != "/tmp/cibw_bin/python":
246+
print(
247+
"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.",
248+
file=sys.stderr,
249+
)
250+
sys.exit(1)
251+
249252
# Set MACOSX_DEPLOYMENT_TARGET to 10.9, if the user didn't set it.
250253
# PyPy defaults to 10.7, causing inconsistencies if it's left unset.
251254
env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9")

cibuildwheel/windows.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -157,31 +157,6 @@ def setup_python(
157157
)
158158
env["PIP_DISABLE_PIP_VERSION_CHECK"] = "1"
159159

160-
# update env with results from CIBW_ENVIRONMENT
161-
env = environment.as_dictionary(prev_environment=env)
162-
163-
# for the logs - check we're running the right version of python
164-
call(["where", "python"], env=env)
165-
call(["python", "--version"], env=env)
166-
call(["python", "-c", "\"import struct; print(struct.calcsize('P') * 8)\""], env=env)
167-
where_python = (
168-
subprocess.run(
169-
["where", "python"],
170-
env=env,
171-
universal_newlines=True,
172-
check=True,
173-
stdout=subprocess.PIPE,
174-
)
175-
.stdout.splitlines()[0]
176-
.strip()
177-
)
178-
if where_python != str(installation_path / "python.exe"):
179-
print(
180-
"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.",
181-
file=sys.stderr,
182-
)
183-
sys.exit(1)
184-
185160
log.step("Installing build tools...")
186161

187162
# Install pip
@@ -230,6 +205,32 @@ def setup_python(
230205
cwd=CIBW_INSTALL_PATH,
231206
)
232207

208+
# update env with results from CIBW_ENVIRONMENT
209+
env = environment.as_dictionary(prev_environment=env)
210+
211+
# check what Python version we're on
212+
call(["where", "python"], env=env)
213+
call(["python", "--version"], env=env)
214+
call(["python", "-c", "\"import struct; print(struct.calcsize('P') * 8)\""], env=env)
215+
where_python = (
216+
subprocess.run(
217+
["where", "python"],
218+
env=env,
219+
universal_newlines=True,
220+
check=True,
221+
stdout=subprocess.PIPE,
222+
)
223+
.stdout.splitlines()[0]
224+
.strip()
225+
)
226+
if where_python != str(installation_path / "python.exe"):
227+
print(
228+
"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.",
229+
file=sys.stderr,
230+
)
231+
sys.exit(1)
232+
233+
# check what pip version we're on
233234
assert (installation_path / "Scripts" / "pip.exe").exists()
234235
where_pip = (
235236
subprocess.run(

0 commit comments

Comments
 (0)
0