From 1a31aa838e5cb2b5fad43ab5eeb8119e8efa8e76 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Mon, 9 Jun 2025 17:50:57 +1000 Subject: [PATCH] packaging: Python tools use the system python not venv python --- eris/tools.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/eris/tools.py b/eris/tools.py index 08a3be4..a292637 100755 --- a/eris/tools.py +++ b/eris/tools.py @@ -35,8 +35,7 @@ import tomllib import eris -PYTHON_VERSION = "3.11" -PYTHON_EXECUTABLE = "python" + PYTHON_VERSION +PYTHON_EXECUTABLE = "/usr/bin/python3" CACHE_PATH = ".eris" @@ -654,13 +653,16 @@ def splitext(path): return root, ext +def python_has_module(python_path, module_name): + one_liner = ("import importlib, sys; " + f"sys.exit(importlib.util.find_spec('{module_name}') is not None)") + return bool(subprocess.call([python_path, "-c", one_liner])) + + @functools.cache def is_tool_available(tool): if (hasattr(tool, "command") and tool.command.startswith(f"{PYTHON_EXECUTABLE} -m ")): - try: - return importlib.util.find_spec(tool.command.split()[2]) is not None - except ModuleNotFoundError: - return False + return python_has_module(PYTHON_EXECUTABLE, tool.command.split()[2]) try: return all(shutil.which(executable) for executable in tool.executables) except AttributeError: