Skip to content

Commit b71c47a

Browse files
committed
Use PIP_BUILD_CONSTRAINT for build-isolation Cython pin
PIP_CONSTRAINT (--constraint) only affects the outer install; pip does not propagate it into PEP 517 build-isolation subprocesses. That's why the previous fix appeared to be applied (env dump showed PIP_CONSTRAINT set) but pyzmq's isolated build env still resolved Cython 3.3.0 and hit 'hint redeclared'. The right knob is PIP_BUILD_CONSTRAINT (pip 24.2+, maps to --build-constraint), which is what constrains build-isolation deps like Cython. Set both env vars for safety, since the outer install pins pyzmq==exact-version anyway.
1 parent 6c664cf commit b71c47a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎tests/test_verify_build.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,11 @@ def test_pip_install_salt_w_static_requirements(pipexec, pyexec, build, tmp_path
308308
# build-time Cython below 3.3 so the transitive pyzmq build succeeds.
309309
constraint = tmp_path / "cython-constraint.txt"
310310
constraint.write_text("cython<3.3\n")
311+
# PIP_BUILD_CONSTRAINT (pip 24.2+, maps to --build-constraint) is what
312+
# constrains PEP 517 *build-isolation* deps like Cython. PIP_CONSTRAINT
313+
# (--constraint) only affects the outer install and is not propagated
314+
# into the isolated build subprocess.
315+
env["PIP_BUILD_CONSTRAINT"] = str(constraint)
311316
env["PIP_CONSTRAINT"] = str(constraint)
312317
p = subprocess.run(
313318
[
@@ -372,6 +377,11 @@ def test_pip_install_salt_w_package_requirements(pipexec, pyexec, tmp_path, salt
372377
# ("'hint' redeclared"). Constrain build-time Cython to <3.3.
373378
constraint = tmp_path / "cython-constraint.txt"
374379
constraint.write_text("cython<3.3\n")
380+
# PIP_BUILD_CONSTRAINT (pip 24.2+, maps to --build-constraint) is what
381+
# constrains PEP 517 *build-isolation* deps like Cython. PIP_CONSTRAINT
382+
# (--constraint) only affects the outer install and is not propagated
383+
# into the isolated build subprocess.
384+
env["PIP_BUILD_CONSTRAINT"] = str(constraint)
375385
env["PIP_CONSTRAINT"] = str(constraint)
376386
p = subprocess.run(
377387
[
@@ -534,6 +544,11 @@ def test_pip_install_pyzmq(
534544
# otherwise the reset wipes it before the pyzmq install subprocess runs.
535545
constraint = tmp_path / "cython-constraint.txt"
536546
constraint.write_text("cython<3.3\n")
547+
# PIP_BUILD_CONSTRAINT (pip 24.2+, maps to --build-constraint) is what
548+
# constrains PEP 517 *build-isolation* deps like Cython. PIP_CONSTRAINT
549+
# (--constraint) only affects the outer install and is not propagated
550+
# into the isolated build subprocess.
551+
env["PIP_BUILD_CONSTRAINT"] = str(constraint)
537552
env["PIP_CONSTRAINT"] = str(constraint)
538553

539554
if sys.platform == "linux":

0 commit comments

Comments
 (0)