fix(setup): auto-install matrix-nio during hermes setup (#3873)
Setup previously only printed a manual install hint for matrix-nio, causing the gateway to crash with 'matrix-nio not installed' after configuring Matrix. Now auto-installs matrix-nio (or matrix-nio[e2e] when E2EE is enabled) using the same uv-first/pip-fallback pattern as Daytona and Modal backends. Also adds hermes-agent[matrix] to the [all] extra in pyproject.toml and a regression test to keep it there. Co-authored-by: Gutslabs <Gutslabs@users.noreply.github.com> Co-authored-by: cutepawss <cutepawss@users.noreply.github.com>
This commit is contained in:
@@ -2709,10 +2709,38 @@ def setup_gateway(config: dict):
|
|||||||
if token or get_env_value("MATRIX_PASSWORD"):
|
if token or get_env_value("MATRIX_PASSWORD"):
|
||||||
# E2EE
|
# E2EE
|
||||||
print()
|
print()
|
||||||
if prompt_yes_no("Enable end-to-end encryption (E2EE)?", False):
|
want_e2ee = prompt_yes_no("Enable end-to-end encryption (E2EE)?", False)
|
||||||
|
if want_e2ee:
|
||||||
save_env_value("MATRIX_ENCRYPTION", "true")
|
save_env_value("MATRIX_ENCRYPTION", "true")
|
||||||
print_success("E2EE enabled")
|
print_success("E2EE enabled")
|
||||||
print_info(" Requires: pip install 'matrix-nio[e2e]'")
|
|
||||||
|
# Auto-install matrix-nio
|
||||||
|
matrix_pkg = "matrix-nio[e2e]" if want_e2ee else "matrix-nio"
|
||||||
|
try:
|
||||||
|
__import__("nio")
|
||||||
|
except ImportError:
|
||||||
|
print_info(f"Installing {matrix_pkg}...")
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
uv_bin = shutil.which("uv")
|
||||||
|
if uv_bin:
|
||||||
|
result = subprocess.run(
|
||||||
|
[uv_bin, "pip", "install", "--python", sys.executable, matrix_pkg],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
result = subprocess.run(
|
||||||
|
[sys.executable, "-m", "pip", "install", matrix_pkg],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
if result.returncode == 0:
|
||||||
|
print_success(f"{matrix_pkg} installed")
|
||||||
|
else:
|
||||||
|
print_warning(f"Install failed — run manually: pip install '{matrix_pkg}'")
|
||||||
|
if result.stderr:
|
||||||
|
print_info(f" Error: {result.stderr.strip().splitlines()[-1]}")
|
||||||
|
|
||||||
# Allowed users
|
# Allowed users
|
||||||
print()
|
print()
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ all = [
|
|||||||
"hermes-agent[modal]",
|
"hermes-agent[modal]",
|
||||||
"hermes-agent[daytona]",
|
"hermes-agent[daytona]",
|
||||||
"hermes-agent[messaging]",
|
"hermes-agent[messaging]",
|
||||||
|
"hermes-agent[matrix]",
|
||||||
"hermes-agent[cron]",
|
"hermes-agent[cron]",
|
||||||
"hermes-agent[cli]",
|
"hermes-agent[cli]",
|
||||||
"hermes-agent[dev]",
|
"hermes-agent[dev]",
|
||||||
|
|||||||
18
tests/test_project_metadata.py
Normal file
18
tests/test_project_metadata.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
"""Regression tests for packaging metadata in pyproject.toml."""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
import tomllib
|
||||||
|
|
||||||
|
|
||||||
|
def _load_optional_dependencies():
|
||||||
|
pyproject_path = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
||||||
|
with pyproject_path.open("rb") as handle:
|
||||||
|
project = tomllib.load(handle)["project"]
|
||||||
|
return project["optional-dependencies"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_all_extra_includes_matrix_dependency():
|
||||||
|
optional_dependencies = _load_optional_dependencies()
|
||||||
|
|
||||||
|
assert "matrix" in optional_dependencies
|
||||||
|
assert "hermes-agent[matrix]" in optional_dependencies["all"]
|
||||||
Reference in New Issue
Block a user