aman/tests/test_packaging_metadata.py
Thales Maciel c6fc61c885
Some checks failed
ci / Unit Matrix (3.10) (push) Has been cancelled
ci / Unit Matrix (3.11) (push) Has been cancelled
ci / Unit Matrix (3.12) (push) Has been cancelled
ci / Portable Ubuntu Smoke (push) Has been cancelled
ci / Package Artifacts (push) Has been cancelled
Normalize native dependency ownership and split config UI
Make distro packages the single source of truth for GTK/X11 Python bindings instead of advertising them as wheel-managed runtime dependencies. Update the uv, CI, and packaging workflows to use system site packages, regenerate uv.lock, and keep portable and Arch metadata aligned with that contract.

Pull runtime policy, audio probing, and page builders out of config_ui.py so the settings window becomes a coordinator instead of a single large mixed-concern module. Rename the config serialization and logging helpers, and stop startup logging from exposing raw vocabulary entries or custom model paths.

Remove stale helper aliases and add regression coverage for safe startup logging, packaging metadata and module drift, portable requirements, and the extracted audio helper behavior.

Validated with uv lock, python3 -m compileall -q src tests, python3 -m unittest discover -s tests -p 'test_*.py', make build, and make package-arch.
2026-03-15 11:27:54 -03:00

55 lines
2 KiB
Python

import ast
import re
import subprocess
import tempfile
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def _parse_toml_string_array(text: str, key: str) -> list[str]:
match = re.search(rf"(?ms)^\s*{re.escape(key)}\s*=\s*\[(.*?)^\s*\]", text)
if not match:
raise AssertionError(f"{key} array not found")
return ast.literal_eval("[" + match.group(1) + "]")
class PackagingMetadataTests(unittest.TestCase):
def test_py_modules_matches_top_level_src_modules(self):
text = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
py_modules = sorted(_parse_toml_string_array(text, "py-modules"))
discovered = sorted(path.stem for path in (ROOT / "src").glob("*.py"))
self.assertEqual(py_modules, discovered)
def test_project_dependencies_exclude_native_gui_bindings(self):
text = (ROOT / "pyproject.toml").read_text(encoding="utf-8")
dependencies = _parse_toml_string_array(text, "dependencies")
self.assertNotIn("PyGObject", dependencies)
self.assertNotIn("python-xlib", dependencies)
def test_runtime_requirements_follow_project_dependency_contract(self):
with tempfile.TemporaryDirectory() as td:
output_path = Path(td) / "requirements.txt"
script = (
f'source "{ROOT / "scripts" / "package_common.sh"}"\n'
f'write_runtime_requirements "{output_path}"\n'
)
subprocess.run(
["bash", "-lc", script],
cwd=ROOT,
text=True,
capture_output=True,
check=True,
)
requirements = output_path.read_text(encoding="utf-8").splitlines()
self.assertIn("faster-whisper", requirements)
self.assertIn("llama-cpp-python", requirements)
self.assertNotIn("PyGObject", requirements)
self.assertNotIn("python-xlib", requirements)
if __name__ == "__main__":
unittest.main()