Initial release: full Arma 3 mod management toolchain
Pipeline: parse HTML presets, compare modlists, download from Caddy file server, create junctions/symlinks to Arma 3 Server directory. Includes update/sync flows, missing-mod reporting, OS compat layer, shared config, dep checker, comprehensive test suite (71 tests). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
92
check_deps.py
Normal file
92
check_deps.py
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Verify Python version, OS, and required packages before running the toolchain.
|
||||
|
||||
Usage:
|
||||
python check_deps.py
|
||||
"""
|
||||
|
||||
import importlib.metadata
|
||||
import sys
|
||||
|
||||
# Must not import arma_modlist_tools here — that's what we're checking FOR.
|
||||
|
||||
MIN_PYTHON = (3, 11)
|
||||
REQUIRED_PACKAGES = ["requests", "tqdm"]
|
||||
|
||||
|
||||
def _python_ok() -> bool:
|
||||
return sys.version_info >= MIN_PYTHON
|
||||
|
||||
|
||||
def _get_os_label() -> str:
|
||||
"""Inline OS detection — avoids importing compat before deps are confirmed."""
|
||||
import platform
|
||||
if sys.platform == "win32":
|
||||
if "Server" in platform.version() or "Server" in platform.uname().version:
|
||||
return "Windows Server"
|
||||
return "Windows"
|
||||
if sys.platform == "linux":
|
||||
try:
|
||||
with open("/etc/os-release", encoding="utf-8") as f:
|
||||
text = f.read().lower()
|
||||
if "ubuntu" in text:
|
||||
import os
|
||||
headless = not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"))
|
||||
return "Ubuntu Server" if headless else "Ubuntu"
|
||||
except OSError:
|
||||
pass
|
||||
return "Linux"
|
||||
return "Unknown"
|
||||
|
||||
|
||||
def _pkg_version(name: str) -> str | None:
|
||||
try:
|
||||
return importlib.metadata.version(name)
|
||||
except importlib.metadata.PackageNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print()
|
||||
|
||||
# Python version
|
||||
ver = sys.version.split()[0]
|
||||
py_ok = _python_ok()
|
||||
status = "OK" if py_ok else f"NEED >= {MIN_PYTHON[0]}.{MIN_PYTHON[1]}"
|
||||
print(f" {'Python':<14} {ver:<12} {status}")
|
||||
|
||||
# OS
|
||||
os_label = _get_os_label()
|
||||
print(f" {'OS':<14} {os_label}")
|
||||
print()
|
||||
|
||||
# Packages
|
||||
missing = []
|
||||
for pkg in REQUIRED_PACKAGES:
|
||||
v = _pkg_version(pkg)
|
||||
if v:
|
||||
print(f" {pkg:<14} {v:<12} OK")
|
||||
else:
|
||||
print(f" {pkg:<14} {'---':<12} MISSING")
|
||||
missing.append(pkg)
|
||||
|
||||
print()
|
||||
|
||||
if not py_ok:
|
||||
print(f" Python {MIN_PYTHON[0]}.{MIN_PYTHON[1]}+ is required.")
|
||||
sys.exit(1)
|
||||
|
||||
if missing:
|
||||
print(f" {len(missing)} package(s) missing. Install with:")
|
||||
print(f" pip install {' '.join(missing)}")
|
||||
print()
|
||||
print(" Run check_deps.py again to verify.")
|
||||
sys.exit(1)
|
||||
|
||||
print(" All checks passed. Ready to run.")
|
||||
print()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user