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: