Skip to content

Commit 402a6be

Browse files
Merge branch 'mr/kanya/update' into 'master'
Update interpreter to accept Path See merge request it/e3-core!415
2 parents 46b53a8 + b071775 commit 402a6be

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/e3/sys.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def set_python_env(prefix: str) -> None:
231231
env.add_dll_path(str(Path(prefix, "lib")))
232232

233233

234-
def interpreter(prefix: str | None = None) -> str:
234+
def interpreter(prefix: str | Path | None = None) -> str:
235235
"""Return location of the Python interpreter.
236236
237237
When there are both a python3 and python binary file return the path to
@@ -243,20 +243,22 @@ def interpreter(prefix: str | None = None) -> str:
243243
"""
244244
if prefix is None:
245245
return sys.executable
246+
if isinstance(prefix, str):
247+
prefix = Path(prefix)
246248
if sys.platform == "win32": # unix: no cover
247-
python3 = Path(prefix, "python3.exe")
249+
python3 = prefix / "python3.exe"
248250
if python3.exists():
249251
return str(python3)
250252
# Might be the python location when in a venv
251-
python3 = Path(prefix, "Scripts", "python.exe")
253+
python3 = prefix / "Scripts" / "python.exe"
252254
if python3.exists():
253255
return str(python3)
254-
return str(Path(prefix, "python.exe"))
256+
return str(prefix / "python.exe")
255257
# windows: no cover
256-
python3 = Path(prefix, "bin", "python3") # type: ignore[unreachable]
258+
python3 = prefix / "bin" / "python3" # type: ignore[unreachable]
257259
if python3.exists():
258260
return str(python3)
259-
return str(Path(prefix, "bin", "python"))
261+
return str(prefix / "bin" / "python")
260262

261263

262264
def python_script(name: str, prefix: str | None = None) -> list[str]:

0 commit comments

Comments
 (0)