Files
2026-08-03 22:14:19 +08:00

105 lines
3.0 KiB
Python

"""Unified Orisys packaging entrypoint.
Usage (from repo root):
python build/run.py wheel [--target internal|pypi-linux] [--verify]
python build/run.py wheel-win
python build/run.py wheel-manylinux [PowerShell args...]
python build/run.py gui finger|mini|box
python build/run.py verify [wheel.whl]
python build/run.py verify --gui-dist [--product ory_finger]
See build/README.md for details.
"""
from __future__ import annotations
import argparse
import subprocess
import sys
from pathlib import Path
_BUILD_ROOT = Path(__file__).resolve().parent
_REPO_ROOT = _BUILD_ROOT.parent
if str(_BUILD_ROOT) not in sys.path:
sys.path.insert(0, str(_BUILD_ROOT))
def _run_python(script: Path, argv: list[str]) -> int:
cmd = [sys.executable, str(script), *argv]
return subprocess.call(cmd, cwd=_REPO_ROOT)
def _cmd_wheel(argv: list[str]) -> int:
return _run_python(_BUILD_ROOT / "wheel" / "build.py", argv)
def _cmd_wheel_win(argv: list[str]) -> int:
bat = _BUILD_ROOT / "wheel" / "win.bat"
return subprocess.call(["cmd", "/c", str(bat), *argv], cwd=_REPO_ROOT)
def _cmd_manylinux(argv: list[str]) -> int:
ps1 = _BUILD_ROOT / "wheel" / "docker" / "run.ps1"
cmd = [
"powershell",
"-ExecutionPolicy",
"Bypass",
"-File",
str(ps1),
*argv,
]
return subprocess.call(cmd, cwd=_REPO_ROOT)
def _cmd_gui(argv: list[str]) -> int:
parser = argparse.ArgumentParser(prog="build/run.py gui")
parser.add_argument(
"product",
choices=("finger", "mini", "box", "ory_finger", "ory_mini", "ory_box"),
help="GUI product to package",
)
args, rest = parser.parse_known_args(argv)
product = {
"finger": "ory_finger",
"mini": "ory_mini",
"box": "ory_box",
}.get(args.product, args.product)
return _run_python(_BUILD_ROOT / "gui" / product / "build.py", rest)
def _cmd_verify(argv: list[str]) -> int:
from common.verify.cli import main as verify_main
return verify_main(argv)
def main(argv: list[str] | None = None) -> int:
argv = list(sys.argv[1:] if argv is None else argv)
if not argv or argv[0] in ("-h", "--help"):
print(__doc__)
print("Commands: wheel | wheel-win | manylinux | gui | verify")
print("Examples:")
print(" python build/run.py wheel --help")
print(" python build/run.py gui finger")
print(" python build/run.py manylinux -PythonVersions 3.10")
return 0
command, rest = argv[0], argv[1:]
dispatch = {
"wheel": _cmd_wheel,
"wheel-win": _cmd_wheel_win,
"wheel-manylinux": _cmd_manylinux,
"gui": _cmd_gui,
"verify": _cmd_verify,
}
if command not in dispatch:
print(f"Unknown command: {command!r}", file=sys.stderr)
print("Choose from: wheel, wheel-win, manylinux, gui, verify", file=sys.stderr)
return 2
return dispatch[command](rest)
if __name__ == "__main__":
raise SystemExit(main())