@@ -245,29 +245,30 @@ def ensure_venv():
245245 if platform .system () == 'Windows' :
246246 PYTHON_BIN = os .path .abspath (os .path .join (VENV_DIR , "Scripts" , "python.exe" ))
247247 REQUIREMENTS = local_path ("requirements.txt" )
248+ logger = logging .getLogger ('' )
248249
249250 # If venv doesn’t exist, create it
250251 if not os .path .exists (PYTHON_BIN ):
251- print ("Creating virtual environment..." )
252+ logger . info ("Creating virtual environment..." )
252253 venv .create (VENV_DIR , with_pip = True )
253254 requirements_not_met = False
254255 if '--no-pip' not in sys .argv :
255256 # Running pip twice lets us both capture output cleanly to see if
256257 # we need to reload the venv and send output live to the user on
257258 # actual install.
258- print ("Checking for required python dependencies" )
259+ logger . info ("Checking for required python dependencies" )
259260 req_check = subprocess .run ([PYTHON_BIN , "-m" , "pip" , "install" , "-r" , REQUIREMENTS , "--dry-run" ], capture_output = True , text = True )
260261 if req_check .returncode != 0 :
261262 raise ImportError (f"pip failed to verify required dependencies:\n { req_check .stderr } " )
262263 requirements_not_met = "collecting " in req_check .stdout .lower ()
263264 if requirements_not_met :
264- print ("Installing missing python dependencies" )
265+ logger . info ("Installing missing python dependencies" )
265266 req_check = subprocess .run ([PYTHON_BIN , "-m" , "pip" , "install" , "-r" , REQUIREMENTS ], capture_output = True , text = True )
266267 if req_check .returncode != 0 :
267268 raise ImportError (f"pip failed to install required dependencies:\n { req_check .stderr } " )
268269
269270 # If we're not already running inside the venv, restart with it
270271 if sys .executable != PYTHON_BIN or requirements_not_met :
271- print ('Re-launching in virtual environment' )
272+ logger . info ('Re-launching in virtual environment' )
272273 subprocess .check_call ([PYTHON_BIN ] + sys .argv + ['--no-pip' ])
273274 sys .exit (0 )
0 commit comments