Visitar URL original
Complete PIP_CONSTRAINT build-environment deprecation by notatallshaw · Pull Request #14094 · pypa/pip · GitHub
Skip to content

Complete PIP_CONSTRAINT build-environment deprecation - #14094

Merged
ichard26 merged 4 commits into
pypa:mainfrom
notatallshaw:build-constraint-default
Jul 1, 2026
Merged

ichard26 merged 4 commits into
pypa:mainfrom
notatallshaw:build-constraint-default

Conversation

@notatallshaw

Copy link
Copy Markdown
Member

Completes the gone_in="26.2" deprecation: PIP_CONSTRAINT and config-file constraints no longer affect isolated build environments. Build dependencies are constrained only with --build-constraint or PIP_BUILD_CONSTRAINT. Second and final phase of the deprecation; towards #13787.

build-constraint moves into ALWAYS_ENABLED_FEATURES (like truststore), so --use-feature=build-constraint is accepted but now a no-op that reports the feature is always enabled. The former opt-in becomes the default: with no build constraints the subprocess installer ignores any inherited constraints; with them it passes each file via both --constraint and --build-constraint, so nested builds stay constrained.

Drops the now-dead build_constraint_feature_enabled plumbing and the redundant base_command warning.

Also fixes test_constraints_dont_pass_through, which set PIP_CONSTRAINT via mock.patch.dict that never reached the subprocess, so it passed without testing the behavior. It now uses script.environ.

@ichard26 ichard26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks generally good, but it seems like the build constraints deprecation had a bug this entire time. 😔 Codex reported that PIP_CONSTRAINT can still leak into the build environment when the subprocess installer is used.

Here is an easy reproduction example in a development pip tree:

$ echo "flit-core==2.0" > constraints.txt
$ touch blank-constraints.txt
$ PIP_CONSTRAINT=constraints.txt pip install -e . --build-constraint blank-constraints.txt
Obtaining file:///home/ichard26/dev/oss/pip
  Installing build dependencies ... error
  error: subprocess-exited-with-error
  
  × installing build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      ERROR: Cannot install flit-core<4 and >=3.11 because these package versions have conflicting dependencies.
      
      The conflict is caused by:
          The user requested flit-core<4 and >=3.11
          The user requested (constraint) flit-core==2.0
      
      Additionally, some packages in these conflicts have no matching distributions available for your environment:
          flit-core
      
      To fix this you could try to:
      1. loosen the range of package versions you've specified
      2. remove package versions to allow pip to attempt to solve the dependency conflict
      
      ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build 'file:///home/ichard26/dev/oss/pip' when installing build dependencies

This also reproduces on main, too. The cause seems to be that the --(build-)constraint option is additive so passing it on the command-line in the subprocess installer doesn't clear constraint files set from envvars (or config files...).

This seems to require a fix/hack at the configuration parsing level which TBH I'm scared to touch.

This issue does not exist with the inprocess installer.1

Footnotes

  1. It's frustrating that the inprocess installer and venv based isolation fix so many issues we're running into today, but they're currently incompatible. Of course, they also run the risk of introducing new bugs, but I'm working through those. ↩

@notatallshaw

Copy link
Copy Markdown
Member Author

This also reproduces on main, too. The cause seems to be that the --(build-)constraint option is additive so passing it on the command-line in the subprocess installer doesn't clear constraint files set from envvars (or config files...).

I have no problem fixing this, but the question is whether to fix it on main and postpone removal or fix and remove at the same time, do you have any opinion?

@ichard26

Copy link
Copy Markdown
Member

@notatallshaw given that the issue only exists if the user opted into build constraints by passing --build-constraint (notably, passing just --use-feature=build-constraint doesn't cause this). I doubt this caused any significant issues in practice.1 Affected users wouldn't have been relying on PIP_CONSTRAINT implicitly being carried over to the build environment which IMO is the main risk of this bug.

So, I don't think it would be beneficial to postpone the removal further.

Footnotes

  1. Especially since build dependencies usually don't overlap with runtime dependencies. That's probably why we never heard about this bug from the public since it if they did overlap, things probably would've broke loudly. ↩

@notatallshaw

Copy link
Copy Markdown
Member Author

Updated, ready for review/merge.

@ichard26 ichard26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ichard26
ichard26 merged commit 087bbab into pypa:main Jul 1, 2026
37 checks passed
YakBizzarro pushed a commit to YakBizzarro/pip that referenced this pull request Jul 9, 2026
Completes the `gone_in="26.2"` deprecation: `PIP_CONSTRAINT` and
config-file constraints no longer affect isolated build environments.
Build dependencies are constrained only with `--build-constraint` or
`PIP_BUILD_CONSTRAINT`.

It was discovered passing --build-constraint would let PIP_CONSTRAINT
leak through to the build environment (but not
--use-feature=build-constraint). This was fixed by disabling
--constraint ALWAYS for build processes. We chose to continue with
the final deprecation as affected users would've been using build
constraints properly anyway so it isn't a huge deal in practice.
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants