@@ -269,11 +269,18 @@ def setup_python_environment(env, platform, platform_dir, install_esptool=True):
269269
270270 python_executable = get_executable_path (penv_dir , "python" )
271271
272+ print (f"[DEBUG] Using penv python executable: { python_executable } " , file = sys .stderr )
273+
272274 if env :
273275 env .Replace (PYTHONEXE = python_executable )
276+ print (f"[DEBUG] Set env PYTHONEXE to penv python executable" , file = sys .stderr )
277+
278+ # Zusätzlich globale Umgebungsvariable setzen, falls env nicht komplett verwendet wird
279+ os .environ ["PYTHONEXE" ] = python_executable
280+ os .environ ["PATH" ] = f"{ Path (penv_dir ) / ('Scripts' if IS_WINDOWS else 'bin' )} { os .pathsep } { os .environ .get ('PATH' , '' )} "
274281
275282 if not Path (python_executable ).exists ():
276- sys .stderr .write (f"Python executable not found: { python_executable } \n " )
283+ sys .stderr .write (f"Python executable not found in penv : { python_executable } \n " )
277284 sys .exit (1 )
278285
279286 setup_python_paths (penv_dir )
@@ -283,23 +290,25 @@ def setup_python_environment(env, platform, platform_dir, install_esptool=True):
283290
284291 if has_internet_connection () or bool (os .getenv ("GITHUB_ACTIONS" )):
285292 if not install_dependencies (python_executable , uv_exec ):
286- sys .stderr .write ("Failed to install dependencies\n " )
293+ sys .stderr .write ("Failed to install Python dependencies\n " )
287294 sys .exit (1 )
288295
289296 if install_esptool :
290297 if env :
291- # Use env-specific install if applicable
292298 platform .install_esptool (env , platform , python_executable , uv_bin )
293299 else :
294300 _install_pyos_tool (platform , python_executable , uv_bin )
295301
296- # Certifi etc env
297- certifi_path = subprocess .check_output ([python_executable , "-m" , "certifi" ], text = True , timeout = 5 ).strip ()
298- os .environ ["REQUESTS_CA_BUNDLE" ] = certifi_path
299- os .environ ["SSL_CERT_FILE" ] = certifi_path
300- if env :
301- env .AppendENVPath ("REQUESTS_CA_BUNDLE" , certifi_path )
302- env .AppendENVPath ("SSL_CERT_FILE" , certifi_path )
302+ # Setup certifi environment variables
303+ try :
304+ certifi_path = subprocess .check_output ([python_executable , "-m" , "certifi" ], text = True , timeout = 5 ).strip ()
305+ os .environ ["REQUESTS_CA_BUNDLE" ] = certifi_path
306+ os .environ ["SSL_CERT_FILE" ] = certifi_path
307+ if env :
308+ env .AppendENVPath ("REQUESTS_CA_BUNDLE" , certifi_path )
309+ env .AppendENVPath ("SSL_CERT_FILE" , certifi_path )
310+ except Exception as e :
311+ print (f"Warning: Could not configure certifi environment variables: { e } " , file = sys .stderr )
303312
304313 return python_executable , esptool_bin
305314
0 commit comments