@@ -128,23 +128,29 @@ def _deprecation_constraint_check(self) -> None:
128128 if self ._build_constraint_feature_enabled :
129129 return
130130
131+ if self ._build_constraints :
132+ return
133+
131134 if not self ._constraints :
132135 return
133136
134137 if not os .environ .get ("PIP_CONSTRAINT" ):
135138 return
136139
137140 pip_constraint_files = [
138- f . strip () for f in os .environ ["PIP_CONSTRAINT" ].split () if f .strip ()
141+ f for f in os .environ ["PIP_CONSTRAINT" ].split () if f .strip ()
139142 ]
140- if pip_constraint_files and set ( pip_constraint_files ) == set ( self ._constraints ) :
143+ if pip_constraint_files and pip_constraint_files == self ._constraints :
141144 deprecated (
142145 reason = (
143146 "Setting PIP_CONSTRAINT will not affect "
144147 "build constraints in the future,"
145148 ),
146149 replacement = (
147- 'PIP_BUILD_CONSTRAINT with PIP_USE_FEATURE="build-constraint"'
150+ "to specify build constraints use --build-constraint or "
151+ "PIP_BUILD_CONSTRAINT, to disable this warning without "
152+ "any build constraints set --use-feature=build-constraint or "
153+ 'PIP_USE_FEATURE="build-constraint"'
148154 ),
149155 gone_in = "26.2" ,
150156 issue = None ,
@@ -219,19 +225,21 @@ def install(
219225 # Handle build constraints
220226 extra_environ : ExtraEnviron = {}
221227 if self ._build_constraint_feature_enabled :
228+ args .extend (["--use-feature" , "build-constraint" ])
229+
230+ if self ._build_constraints :
222231 # Build constraints must be passed as both constraints
223- # and build constraints to the subprocess
232+ # and build constraints, so that nested builds receive
233+ # build constraints
224234 for constraint_file in self ._build_constraints :
225235 args .extend (["--constraint" , constraint_file ])
226236 args .extend (["--build-constraint" , constraint_file ])
227- args .extend (["--use-feature" , "build-constraint" ])
228237
238+ if self ._build_constraint_feature_enabled and not self ._build_constraints :
229239 # If there are no build constraints but the build constraint
230- # process is enabled then we must ignore regular constraints
231- if not self ._build_constraints :
232- extra_environ = {
233- "extra_environ" : {"_PIP_IN_BUILD_IGNORE_CONSTRAINTS" : "1" }
234- }
240+ # feature is enabled then we must ignore regular constraints
241+ # in the isolated build environment
242+ extra_environ = {"extra_environ" : {"_PIP_IN_BUILD_IGNORE_CONSTRAINTS" : "1" }}
235243
236244 args .append ("--" )
237245 args .extend (requirements )
0 commit comments