Skip to content

Commit e06f4b9

Browse files
add legacy support for env variable WINPYDIRBASE
1 parent 9eaaa1a commit e06f4b9

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

scripts/run_with_env.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ def resolve_python(project_root: Path) -> str:
106106
winpy_base = os.environ.get("WINPYDIRBASE")
107107
if winpy_base and Path(winpy_base).is_dir():
108108
# Search for python.exe in the WinPython directory structure
109-
# (e.g. WINPYDIRBASE/python-3.11.5.amd64/python.exe)
110-
for candidate in sorted(Path(winpy_base).glob("python-*/python.exe")):
111-
if candidate.is_file():
112-
resolved = str(candidate.absolute())
113-
print(f" 🐍 Using WINPYDIRBASE (legacy): {resolved}")
114-
return resolved
109+
# Patterns: python-3.11.5.amd64/python.exe (old) or python/python.exe (new)
110+
for pattern in ("python-*/python.exe", "python/python.exe"):
111+
for candidate in sorted(Path(winpy_base).glob(pattern)):
112+
if candidate.is_file():
113+
resolved = str(candidate.absolute())
114+
print(f" 🐍 Using WINPYDIRBASE (legacy): {resolved}")
115+
return resolved
115116
# Also try direct python.exe in the base directory
116117
direct = Path(winpy_base) / "python.exe"
117118
if direct.is_file():
@@ -156,8 +157,9 @@ def load_env_file(env_path: str | None = None) -> None:
156157
if not line or line.startswith("#") or "=" not in line:
157158
continue
158159
key, value = line.split("=", 1)
159-
os.environ[key.strip()] = value.strip()
160-
print(f" Loaded variable: {key.strip()}={value.strip()}")
160+
value = value.strip().strip('"').strip("'")
161+
os.environ[key.strip()] = value
162+
print(f" Loaded variable: {key.strip()}={value}")
161163

162164

163165
def execute_command(command: list[str], python_exe: str) -> int:

0 commit comments

Comments
 (0)