CLI and library for diffing ALT Linux binary packages between branches. Fetches both branches in parallel with retries and outputs JSON, human-readable summaries, or GitHub-ready Markdown.
- JSON, summary, and Markdown outputs;
--limitkeeps human output compact (set0for unlimited). - Filters: architectures (
--arch), regex by package name (--filter), and name-only comparison (--ignore-arch). - CI-friendly:
--fail-on-diffexits with code1when differences are found. - Resilient HTTP client with retries, timeouts, and customizable
--user-agent(honored even with custom sessions). - New CLI alias
altpkg-diff(keepspackage-comparisonfor compatibility). - Cleaner CLI errors: short messages by default;
--debugshows tracebacks. Exit code2for missing branches,1for other failures.
python -m pip install -e .[dev] && make ciЗапускает линтеры и тесты. Для простого использования без разработки можно установить пакетом:
pip install git+https://github.com/Raphailinc/altpkg-diff.git# defaults: sisyphus vs p10, JSON to stdout
package-comparison
# same tool via shorter alias
altpkg-diff sisyphus p10 --format summary
# GitHub-ready Markdown report (first 25 rows shown) saved to file
package-comparison sisyphus p10 --format markdown --limit 25 -o report.md
# CI mode: fail on any differences, ignore arch suffixes, filter only nginx packages
package-comparison p10 sisyphus --ignore-arch --filter nginx --fail-on-diffKey options:
--format json|summary|markdown|text– choose output format (JSON honors--pretty/--no-pretty).--filter REGEX– repeatable regex for package names (case-insensitive).--arch ARCH– repeatable arch filter;--ignore-archcompares by name only.--limit N– limit rows in human-readable formats (Markdown/summary);0shows everything.--fail-on-diff– exit with code1when differences exist (useful for CI/pipelines).--timeout,--user-agent,--debug– tune HTTP behavior and verbosity on errors.
from package_comparison_tool.compare import compare_packages
result = compare_packages(
"sisyphus",
"p10",
ignore_arch=False,
arches={"x86_64", "noarch"},
name_patterns=None,
)
print(result["stats"])
# {'only_in_branch1': ..., 'differences': ...}# JSON diff (first 5 rows)
altpkg-diff p10 sisyphus --format json --limit 5 | head
# Markdown report, name-only comparison
altpkg-diff sisyphus p10 --ignore-arch --format markdown -o report.md
# CI pipeline example (GitHub Actions step)
pip install -e .[dev]
pytest --cov=package_comparison_tool- Built-in retries for timeouts/connection errors/5xx with exponential backoff; per-request timeouts (
--timeout) and per-call user agent override (--user-agent). - Sessions created internally are closed automatically; caller-provided sessions are never closed.
- Header precedence (per request): explicit
headers>user_agentvalue >session.headers(so custom UAs are honored even with custom sessions). - Parallel fetches by default; if you supply a session, calls run sequentially for safety. Provide
session_factoryorallow_concurrency_with_session=Trueto fetch with two cloned/independent sessions.
package_comparison_tool/compare.py— основная логика скачивания/сравнения RPM списков.cli.py/api.py— CLI и FastAPI-lite интерфейс.examples/— примеры готовых отчётов и конфигов.tests/— unit-тесты на респонсы/фильтры.
- Форматирование/линт:
ruff check . - Тесты:
pytest - CI: GitHub Actions (
ci.yml) — линтер + тесты на Python 3.11.
- Run tests:
pytest - Lint:
ruff check .
MIT – see LICENSE.