File tree Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Expand file tree Collapse file tree 2 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ def __init__(self, create_args: ToxEnvCreateArgs) -> None:
5151        self ._executor : Execute  |  None  =  None 
5252        self ._installer : UvInstaller  |  None  =  None 
5353        self ._created  =  False 
54+         self ._displayed_uv_constraint_warning  =  False 
5455        super ().__init__ (create_args )
5556
5657    def  register_config (self ) ->  None :
@@ -183,12 +184,14 @@ def environment_variables(self) -> dict[str, str]:
183184        env  =  super ().environment_variables 
184185        env .pop ("UV_PYTHON" , None )  # UV_PYTHON takes precedence over VIRTUAL_ENV 
185186        env ["VIRTUAL_ENV" ] =  str (self .venv_dir )
186-         for  pip_var  in  ("PIP_CONSTRAINT" , "PIP_CONSTRAINTS" ):
187-             if  pip_var  in  env :
188-                 _LOGGER .warning (
189-                     "Found %s defined, you may want to also define UV_CONSTRAINT to match pip behavior." , pip_var 
190-                 )
191-                 break 
187+         if  "UV_CONSTRAINT"  not  in   env  and  not  self ._displayed_uv_constraint_warning :
188+             for  pip_var  in  ("PIP_CONSTRAINT" , "PIP_CONSTRAINTS" ):
189+                 if  pip_var  in  env :
190+                     _LOGGER .warning (
191+                         "Found %s defined, you may want to also define UV_CONSTRAINT to match pip behavior." , pip_var 
192+                     )
193+                     self ._displayed_uv_constraint_warning  =  True 
194+                     break 
192195        return  env 
193196
194197    def  _default_pass_env (self ) ->  list [str ]:
Original file line number Diff line number Diff line change @@ -396,5 +396,27 @@ def test_uv_pip_constraints(tox_project: ToxProjectCreator) -> None:
396396    result  =  project .run ()
397397    result .assert_success ()
398398    assert  (
399-         "Found PIP_CONSTRAINTS defined, you may want to also define UV_CONSTRAINT to match pip behavior."  in  result .out 
399+         result .out .count (
400+             "Found PIP_CONSTRAINTS defined, you may want to also define UV_CONSTRAINT to match pip behavior." 
401+         )
402+         ==  1 
403+     ), "Warning should be found once and only once in output." 
404+ 
405+ 
406+ def  test_uv_pip_constraints_no (tox_project : ToxProjectCreator ) ->  None :
407+     project  =  tox_project ({
408+         "tox.ini" : f""" 
409+             [testenv] 
410+             package=skip 
411+             setenv= 
412+                 PIP_CONSTRAINTS={ os .devnull }  
413+                 UV_CONSTRAINT={ os .devnull }  
414+             commands=python --version 
415+             """ 
416+     })
417+     result  =  project .run ()
418+     result .assert_success ()
419+     assert  (
420+         "Found PIP_CONSTRAINTS defined, you may want to also define UV_CONSTRAINT to match pip behavior." 
421+         not  in   result .out 
400422    )
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments