53 lines
1.9 KiB
Python
53 lines
1.9 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""Check whether the current Python can run Nexus backend tests.
|
||
|
|
|
||
|
|
Nexus production images currently use Python 3.12. The pinned backend
|
||
|
|
requirements include native wheels (notably pydantic-core) that are not
|
||
|
|
compatible with Python 3.14 in this snapshot. Run this before installing
|
||
|
|
requirements or invoking pytest on a new machine.
|
||
|
|
"""
|
||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import importlib.util
|
||
|
|
import platform
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
SUPPORTED_MIN = (3, 12)
|
||
|
|
SUPPORTED_MAX_EXCLUSIVE = (3, 14)
|
||
|
|
REQUIRED_MODULES = ("pytest", "sqlalchemy", "pydantic", "fastapi")
|
||
|
|
|
||
|
|
|
||
|
|
def main() -> int:
|
||
|
|
version = sys.version_info[:3]
|
||
|
|
executable = Path(sys.executable)
|
||
|
|
print(f"Python executable: {executable}")
|
||
|
|
print(f"Python version: {platform.python_version()}")
|
||
|
|
|
||
|
|
if version < SUPPORTED_MIN or version >= SUPPORTED_MAX_EXCLUSIVE:
|
||
|
|
print(
|
||
|
|
"ERROR: Nexus backend tests should be run with Python 3.12 or 3.13. "
|
||
|
|
"Python 3.14 is currently incompatible with pinned pydantic-core/PyO3 dependencies.",
|
||
|
|
file=sys.stderr,
|
||
|
|
)
|
||
|
|
print("Recommended:", file=sys.stderr)
|
||
|
|
print(" py -3.12 -m venv .venv-py312", file=sys.stderr)
|
||
|
|
print(" .venv-py312\\Scripts\\python.exe -m pip install -r requirements.txt -r requirements-dev.txt", file=sys.stderr)
|
||
|
|
print(" .venv-py312\\Scripts\\python.exe -m pytest tests/test_btpanel_*.py -q", file=sys.stderr)
|
||
|
|
return 2
|
||
|
|
|
||
|
|
missing = [name for name in REQUIRED_MODULES if importlib.util.find_spec(name) is None]
|
||
|
|
if missing:
|
||
|
|
print("ERROR: Missing backend test dependencies: " + ", ".join(missing), file=sys.stderr)
|
||
|
|
print("Install with:", file=sys.stderr)
|
||
|
|
print(" python -m pip install -r requirements.txt -r requirements-dev.txt", file=sys.stderr)
|
||
|
|
return 3
|
||
|
|
|
||
|
|
print("OK: Python version and key backend test dependencies look usable.")
|
||
|
|
return 0
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
raise SystemExit(main())
|