Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

pip 26.2+ will enforce that PIP_CONSTRAINT no longer affects build constraints. The deprecation warning recommends using PIP_BUILD_CONSTRAINT for build-time constraints.

Changes

  • build_env.py: Updated _create_constraints_file() to read PIP_BUILD_CONSTRAINT environment variable first, falling back to PIP_CONSTRAINT for backward compatibility
  • config.py:
    • Added pip_build_constraint to BUILD_KEY_TO_VAR mapping to recognize the environment variable
    • Added default computed value for pip_build_constraint that defaults to $(PIP_CONSTRAINT) for environments where it's not explicitly set
  • builder.py: Set both PIP_CONSTRAINT and PIP_BUILD_CONSTRAINT to the constraints file path when building packages
  • test_build_env.py: Added comprehensive tests to verify PIP_BUILD_CONSTRAINT functionality:
    • Test that PIP_BUILD_CONSTRAINT is used when explicitly set
    • Test that default values from xbuildenv are used when no override is provided
    • Test that PIP_BUILD_CONSTRAINT takes precedence over PIP_CONSTRAINT when both are set
  • CHANGELOG.md: Documented the new feature for pip 26.2+ compatibility
# builder.py - sets both environment variables
constraints_file = str(self._create_constraints_file())
build_env["PIP_CONSTRAINT"] = constraints_file
build_env["PIP_BUILD_CONSTRAINT"] = constraints_file
# build_env.py - prioritizes PIP_BUILD_CONSTRAINT with fallback
def _create_constraints_file() -> str:
    # PIP_BUILD_CONSTRAINT takes precedence; fall back to PIP_CONSTRAINT for backward compatibility
    try:
        constraints = get_build_flag("PIP_BUILD_CONSTRAINT")
    except ValueError:
        try:
            constraints = get_build_flag("PIP_CONSTRAINT")
        except ValueError:
            return ""
    ...

Behavior

  • If PIP_BUILD_CONSTRAINT is set in the environment, it will be used for build constraints
  • If not set, it defaults to PIP_CONSTRAINT value for backward compatibility
  • Both variables are set in the build environment to ensure pip uses them correctly
  • No binary xbuildenv file changes required

Testing

  • ✅ All constraint-related tests pass (18 tests)
  • ✅ All new tests for PIP_BUILD_CONSTRAINT functionality pass (3 tests)
  • ✅ No linting issues
  • ✅ Code review passed
  • ✅ Security checks passed

This ensures compatibility with pip 26.2+ which will enforce the separation of build constraints from install constraints while maintaining full backward compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>PIP_CONSTRAINT deprecated</issue_title>
<issue_description> DEPRECATION: Setting PIP_CONSTRAINT will not affect build constraints in the future, pip 26.2 will enforce this behaviour change. A possible replacement is to specify build constraints using --build-constraint or PIP_BUILD_CONSTRAINT. To disable this warning without any build constraints set --use-feature=build-constraint or PIP_USE_FEATURE="build-constraint".

</issue_description>

<agent_instructions>We are setting PIP_CONSTRAINT. Update to also set PIP_BUILD_CONSTRAINT to handle it correctly.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Update PIP_CONSTRAINT to use PIP_BUILD_CONSTRAINT Set PIP_BUILD_CONSTRAINT alongside PIP_CONSTRAINT for pip 26.2+ compatibility Feb 2, 2026
Copilot AI requested a review from ryanking13 February 2, 2026 05:30
@ryanking13
Copy link
Member

ryanking13 commented Feb 2, 2026

@copilot Do not change the binary xbuildenv file

Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot Do not change the binary xbuildenv file

Reverted the binary xbuildenv file and removed pip_build_constraint from the config mapping. PIP_BUILD_CONSTRAINT is now set directly in the build environment without needing config system changes. See commit bf63a45.

@ryanking13
Copy link
Member

@copilot

Update _create_constraints_file to read the env variable PIP_BUILD_CONSTRAINT. And also update the config.py to handle PIP_BUILD_CONSTRAINT env variable.

Copy link
Contributor Author

Copilot AI commented Feb 2, 2026

@copilot

Update _create_constraints_file to read the env variable PIP_BUILD_CONSTRAINT. And also update the config.py to handle PIP_BUILD_CONSTRAINT env variable.

Updated _create_constraints_file in build_env.py to read PIP_BUILD_CONSTRAINT first, falling back to PIP_CONSTRAINT for backward compatibility. Added pip_build_constraint to config.py BUILD_KEY_TO_VAR mapping and DEFAULT_CONFIG_COMPUTED with a default value of $(PIP_CONSTRAINT). See commits 8c4088d and b301349.

Copilot AI changed the title Set PIP_BUILD_CONSTRAINT alongside PIP_CONSTRAINT for pip 26.2+ compatibility Add PIP_BUILD_CONSTRAINT support for pip 26.2+ compatibility Feb 2, 2026
@ryanking13
Copy link
Member

@copilot update test and changelog

Copy link
Contributor Author

Copilot AI commented Feb 3, 2026

@copilot update test and changelog

Added three comprehensive tests for PIP_BUILD_CONSTRAINT functionality in test_build_env.py and updated CHANGELOG.md to document the new feature. See commits 1afa9ee and 02f4e82.

@ryanking13 ryanking13 marked this pull request as ready for review February 3, 2026 07:00
@ryanking13 ryanking13 merged commit 9344349 into main Feb 3, 2026
6 checks passed
@ryanking13 ryanking13 deleted the copilot/update-pip-constraint-setting branch February 3, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PIP_CONSTRAINT deprecated

2 participants