packaging: Python tools use the system python not venv python

This commit is contained in:
Andrew Hamilton 2025-06-09 17:50:57 +10:00
parent ad74f48679
commit 1a31aa838e

View file

@ -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: