Decouple non-UI CLI startup from config_ui
Stop aman.py from importing the GTK settings module at module load so version, init, bench, diagnostics, and top-level help can start without pulling in the UI stack.\n\nPromote PyGObject and python-xlib into main project dependencies, switch the documented source install surface to plain uv/pip commands, and teach the portable, deb, and Arch packaging flows to install filtered runtime requirements before the Aman wheel so they still rely on distro-provided GTK/X11 packages.\n\nAdd regression coverage for importing aman with config_ui blocked and for the portable bundle's new requirements payload, then rerun the focused CLI/diagnostics/portable tests plus py_compile.
This commit is contained in:
parent
b4a3d446fa
commit
721248ca26
15 changed files with 173 additions and 35 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import io
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
|
@ -242,6 +243,36 @@ class AmanCliTests(unittest.TestCase):
|
|||
self.assertEqual(exit_code, 0)
|
||||
self.assertEqual(out.getvalue().strip(), "1.2.3")
|
||||
|
||||
def test_version_command_does_not_import_config_ui(self):
|
||||
script = f"""
|
||||
import builtins
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, {str(SRC)!r})
|
||||
real_import = builtins.__import__
|
||||
|
||||
def blocked(name, globals=None, locals=None, fromlist=(), level=0):
|
||||
if name == "config_ui":
|
||||
raise ModuleNotFoundError("blocked config_ui")
|
||||
return real_import(name, globals, locals, fromlist, level)
|
||||
|
||||
builtins.__import__ = blocked
|
||||
import aman
|
||||
args = aman._parse_cli_args(["version"])
|
||||
raise SystemExit(aman._version_command(args))
|
||||
"""
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-c", script],
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
self.assertRegex(result.stdout.strip(), r"\S+")
|
||||
|
||||
def test_app_version_prefers_local_pyproject_version(self):
|
||||
pyproject_text = '[project]\nversion = "9.9.9"\n'
|
||||
|
||||
|
|
@ -600,7 +631,7 @@ class AmanCliTests(unittest.TestCase):
|
|||
with patch("aman._lock_single_instance", return_value=object()), patch(
|
||||
"aman.get_desktop_adapter", return_value=desktop
|
||||
), patch(
|
||||
"aman.run_config_ui",
|
||||
"aman._run_config_ui",
|
||||
return_value=ConfigUiResult(saved=True, config=onboard_cfg, closed_reason="saved"),
|
||||
) as config_ui_mock, patch("aman.Daemon", _FakeDaemon):
|
||||
exit_code = aman._run_command(args)
|
||||
|
|
@ -618,7 +649,7 @@ class AmanCliTests(unittest.TestCase):
|
|||
with patch("aman._lock_single_instance", return_value=object()), patch(
|
||||
"aman.get_desktop_adapter", return_value=desktop
|
||||
), patch(
|
||||
"aman.run_config_ui",
|
||||
"aman._run_config_ui",
|
||||
return_value=ConfigUiResult(saved=False, config=None, closed_reason="cancelled"),
|
||||
), patch("aman.Daemon") as daemon_cls:
|
||||
exit_code = aman._run_command(args)
|
||||
|
|
@ -640,7 +671,7 @@ class AmanCliTests(unittest.TestCase):
|
|||
with patch("aman._lock_single_instance", return_value=object()), patch(
|
||||
"aman.get_desktop_adapter", return_value=desktop
|
||||
), patch(
|
||||
"aman.run_config_ui",
|
||||
"aman._run_config_ui",
|
||||
side_effect=config_ui_results,
|
||||
), patch("aman.Daemon", _FakeDaemon):
|
||||
exit_code = aman._run_command(args)
|
||||
|
|
|
|||
|
|
@ -75,8 +75,10 @@ def _build_fake_wheel(root: Path, version: str) -> Path:
|
|||
def _bundle_dir(root: Path, version: str) -> Path:
|
||||
bundle_dir = root / f"bundle-{version}"
|
||||
(bundle_dir / "wheelhouse" / "common").mkdir(parents=True, exist_ok=True)
|
||||
(bundle_dir / "requirements").mkdir(parents=True, exist_ok=True)
|
||||
for tag in portable.SUPPORTED_PYTHON_TAGS:
|
||||
(bundle_dir / "wheelhouse" / tag).mkdir(parents=True, exist_ok=True)
|
||||
(bundle_dir / "requirements" / f"{tag}.txt").write_text("", encoding="utf-8")
|
||||
(bundle_dir / "systemd").mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(PORTABLE_DIR / "install.sh", bundle_dir / "install.sh")
|
||||
shutil.copy2(PORTABLE_DIR / "uninstall.sh", bundle_dir / "uninstall.sh")
|
||||
|
|
@ -213,6 +215,9 @@ class PortableBundleTests(unittest.TestCase):
|
|||
self.assertIn(f"{prefix}/wheelhouse/cp310", names)
|
||||
self.assertIn(f"{prefix}/wheelhouse/cp311", names)
|
||||
self.assertIn(f"{prefix}/wheelhouse/cp312", names)
|
||||
self.assertIn(f"{prefix}/requirements/cp310.txt", names)
|
||||
self.assertIn(f"{prefix}/requirements/cp311.txt", names)
|
||||
self.assertIn(f"{prefix}/requirements/cp312.txt", names)
|
||||
self.assertIn(f"{prefix}/systemd/aman.service.in", names)
|
||||
|
||||
def test_fresh_install_creates_managed_paths_and_starts_service(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue