Skip to content

Commit b3b1e80

Browse files
committed
replace PATH readout with shutil.which()
1 parent 389bf5c commit b3b1e80

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/gardenlinux/build/exporter.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,7 @@ def _getInterpreter(path: str | PathLike[str]) -> pathlib.Path:
6363
return pathlib.Path("/lib64/ld-linux-x86-64.so.2")
6464
case arch:
6565
raise RuntimeError(f"Error: Unsupported architecture for {path}: only support x86_64 (003e), aarch64 (00b7) and i686 (0003), but was {arch}")
66-
67-
def _get_python_from_path() -> pathlib.Path | None:
68-
interpreter = None
69-
for dir in os.environ["PATH"].split(":"):
70-
binary = pathlib.Path(dir, "python3")
71-
if binary.is_file():
72-
interpreter = binary
73-
break
74-
return interpreter
75-
66+
7667
def _get_default_package_dir() -> pathlib.Path | None:
7768
"""
7869
Finds the default site-packages or dist-packages directory of the default python3 environment
@@ -82,7 +73,7 @@ def _get_default_package_dir() -> pathlib.Path | None:
8273
"""
8374

8475
# Needs to escape the virtual environment python-gardenlinx-lib is running in
85-
interpreter = _get_python_from_path()
76+
interpreter = shutil.which("python3")
8677
if interpreter:
8778
out = subprocess.run(
8879
[interpreter, "-c", "import site; print(site.getsitepackages()[0])"],

0 commit comments

Comments
 (0)