]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use system python if python binary is interpreter is not in /usr
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 27 Aug 2024 15:05:03 +0000 (17:05 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 27 Aug 2024 17:57:51 +0000 (19:57 +0200)
Same fix as #2982, but for the python_binary() function.

mkosi/__init__.py

index 9cce8e88c2825763c633b8c2e75915f259232cf5..cc8482c43db5686fad6af5957f7c259b9a736d8a 100644 (file)
@@ -2058,7 +2058,7 @@ def join_initrds(initrds: Sequence[Path], output: Path) -> Path:
     return output
 
 
-def python_binary(config: Config, *, binary: Optional[PathString]) -> str:
+def python_binary(config: Config, *, binary: Optional[PathString]) -> PathString:
     tools = (
         not binary or
         not (path := config.find_binary(binary)) or
@@ -2067,7 +2067,8 @@ def python_binary(config: Config, *, binary: Optional[PathString]) -> str:
 
     # If there's no tools tree, prefer the interpreter from MKOSI_INTERPRETER. If there is a tools
     # tree, just use the default python3 interpreter.
-    return "python3" if tools and config.tools_tree else sys.executable
+    exe = Path(sys.executable)
+    return "python3" if (tools and config.tools_tree) or not exe.is_relative_to("/usr") else exe
 
 
 def extract_pe_section(context: Context, binary: Path, section: str, output: Path) -> Path: