Skip to content

Commit ae4f42f

Browse files
authored
Refactor setup_python_environment for clarity
1 parent cd74a80 commit ae4f42f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

builder/penv_setup.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ def setup_python_paths(penv_dir):
252252
site.addsitedir(str(site_path))
253253

254254
def setup_python_environment(env, platform, platform_dir, install_esptool=True):
255+
# ERZWUNGENER Pfad zum venv: immer Unterordner "penv"
255256
penv_dir = str(Path(platform_dir) / "penv")
257+
print(f"[DEBUG] setup_python_environment: Using penv directory: {penv_dir}", file=sys.stderr)
256258

259+
# Upgrade-Subprozess-Handling (Boostrap)
257260
if "--in-temp" in sys.argv:
258261
idx = sys.argv.index("--in-temp")
259262
in_penv = sys.argv[idx + 1]
@@ -268,16 +271,16 @@ def setup_python_environment(env, platform, platform_dir, install_esptool=True):
268271
uv_exec = _setup_pipenv_minimal(penv_dir)
269272

270273
python_executable = get_executable_path(penv_dir, "python")
274+
print(f"[DEBUG] Python executable path resolved to: {python_executable}", file=sys.stderr)
271275

272-
print(f"[DEBUG] Using penv python executable: {python_executable}", file=sys.stderr)
273-
276+
# Sicherstellen, dass env den korrekten Python-Interpreter benutzt
274277
if env:
275278
env.Replace(PYTHONEXE=python_executable)
276-
print(f"[DEBUG] Set env PYTHONEXE to penv python executable", file=sys.stderr)
279+
print("[DEBUG] PYTHONEXE in env gesetzt", file=sys.stderr)
277280

278-
# Zusätzlich globale Umgebungsvariable setzen, falls env nicht komplett verwendet wird
281+
# Global sicherheitshalber Umgebungsvariable setzen
279282
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', '')}"
283+
os.environ["PATH"] = f"{Path(penv_dir)/('Scripts' if IS_WINDOWS else 'bin')}{os.pathsep}{os.environ.get('PATH','')}"
281284

282285
if not Path(python_executable).exists():
283286
sys.stderr.write(f"Python executable not found in penv: {python_executable}\n")
@@ -299,9 +302,10 @@ def setup_python_environment(env, platform, platform_dir, install_esptool=True):
299302
else:
300303
_install_pyos_tool(platform, python_executable, uv_bin)
301304

302-
# Setup certifi environment variables
305+
# Setup certifi env vars
303306
try:
304-
certifi_path = subprocess.check_output([python_executable, "-m", "certifi"], text=True, timeout=5).strip()
307+
certifi_path = subprocess.check_output(
308+
[python_executable, "-m", "certifi"], text=True, timeout=5).strip()
305309
os.environ["REQUESTS_CA_BUNDLE"] = certifi_path
306310
os.environ["SSL_CERT_FILE"] = certifi_path
307311
if env:

0 commit comments

Comments
 (0)