File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,18 @@ def needs_subprocess_shell(command: str) -> bool:
301301    return  False 
302302
303303
304+ def  env_with_python_path ():
305+     """Return a copy of current environment variables with PATH 
306+     modified to include the python interpreter""" 
307+     # Get the directory of the current Python interpreter 
308+     python_dir  =  os .path .dirname (sys .executable )
309+ 
310+     # Add Python interpreter to PATH 
311+     env  =  os .environ .copy ()
312+     env ["PATH" ] =  python_dir  +  os .pathsep  +  env ["PATH" ]
313+     return  env 
314+ 
315+ 
304316def  _run_script (script_cmd : str , control_path : Path ) ->  None :
305317    """Helper recursive function to attempt running a script command. 
306318
@@ -315,9 +327,11 @@ def _run_script(script_cmd: str, control_path: Path) -> None:
315327    # First try to interpret the argument as a full command 
316328    try :
317329        if  needs_subprocess_shell (script_cmd ):
318-             subprocess .check_call (script_cmd , shell = True )
330+             subprocess .check_call (script_cmd , shell = True ,
331+                                   env = env_with_python_path ())
319332        else :
320-             subprocess .check_call (shlex .split (script_cmd ))
333+             subprocess .check_call (shlex .split (script_cmd ),
334+                                   env = env_with_python_path ())
321335        print (script_cmd )
322336
323337    except  FileNotFoundError :
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments