From: Daan De Meyer Date: Tue, 27 Aug 2024 15:05:03 +0000 (+0200) Subject: Use system python if python binary is interpreter is not in /usr X-Git-Tag: v25~333 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=390deb2f6b6e714dac9bb10b58e0e188878943ae;p=thirdparty%2Fmkosi.git Use system python if python binary is interpreter is not in /usr Same fix as #2982, but for the python_binary() function. --- diff --git a/mkosi/__init__.py b/mkosi/__init__.py index 9cce8e88c..cc8482c43 100644 --- a/mkosi/__init__.py +++ b/mkosi/__init__.py @@ -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: