umpirix/adapters/python/.github/scripts/check_distributions.py
caelum0x 4847e35451 OpenJev: open-source typed decision service
Typed decision/classification service with an in-process gte-small ONNX
embedding engine and lexical fallback, JS/Python SDKs, adapters, and the
otsone model family. Apache-2.0 (sub-packages keep their MIT licenses).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 00:12:36 +03:00

51 lines
1.8 KiB
Python

"""Smoke-test wheel and sdist installations."""
# ruff: noqa: INP001, S603, S607 - Standalone helper using explicit uv arguments.
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
def check_distributions(distributions: Path, version: str) -> None:
"""Check both distributions in isolated environments."""
wheels, sdists = list(distributions.glob("*.whl")), list(distributions.glob("*.tar.gz"))
if len(wheels) != 1 or len(sdists) != 1:
raise ValueError("Expected exactly one wheel and one source distribution")
with tempfile.TemporaryDirectory(prefix="openjev-adapters-distributions-") as temporary:
consumer = Path(temporary)
installation_check = consumer / "check_installed_distribution.py"
shutil.copyfile(Path(__file__).with_name("check_installed_distribution.py"), installation_check)
subprocess.run(
["uv", "build", "--wheel", str(sdists[0].resolve()), "--out-dir", str(consumer / "rebuilt")],
cwd=consumer,
check=True,
)
rebuilt = list((consumer / "rebuilt").glob("*.whl"))
if len(rebuilt) != 1:
raise ValueError("Expected one wheel rebuilt from the source distribution")
for wheel in [wheels[0].resolve(), rebuilt[0]]:
subprocess.run(
[
"uv",
"run",
"--isolated",
"--no-project",
"--python",
sys.executable,
"--with",
str(wheel),
"python",
str(installation_check),
version,
],
cwd=consumer,
check=True,
)
if __name__ == "__main__":
check_distributions(Path(sys.argv[1]), sys.argv[2])