|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Pack → install the BUILT wheel into a fresh venv → documented smoke + pytest. |
| 3 | +# |
| 4 | +# The working tree is not the artifact. `python -m build` produces the sdist/wheel |
| 5 | +# that would be published; this script installs THAT wheel (not `pip install -e .`) |
| 6 | +# and imports the public entry (`from coderifts import CodeRifts` — README Quick start). |
| 7 | +# Pytest then runs against the installed package from a cwd that is not the source tree, |
| 8 | +# so local ./coderifts cannot shadow site-packages. |
| 9 | +set -euo pipefail |
| 10 | + |
| 11 | +ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
| 12 | +TMP="$(mktemp -d "${TMPDIR:-/tmp}/py-sdk-pack-XXXX")" |
| 13 | +cleanup() { rm -rf "$TMP"; } |
| 14 | +trap cleanup EXIT |
| 15 | + |
| 16 | +echo "build venv : $TMP/build" |
| 17 | +python3 -m venv "$TMP/build" |
| 18 | +"$TMP/build/bin/python" -m pip install -U pip build >/dev/null |
| 19 | +"$TMP/build/bin/python" -m build --outdir "$TMP/dist" "$ROOT" |
| 20 | + |
| 21 | +WHEEL="$(ls "$TMP/dist"/coderifts_sdk-*.whl)" |
| 22 | +SDIST="$(ls "$TMP/dist"/coderifts_sdk-*.tar.gz)" |
| 23 | +echo "wheel : $(basename "$WHEEL") ($(wc -c < "$WHEEL" | tr -d ' ') bytes)" |
| 24 | +echo "sdist : $(basename "$SDIST") ($(wc -c < "$SDIST" | tr -d ' ') bytes)" |
| 25 | + |
| 26 | +echo "install venv : $TMP/run" |
| 27 | +python3 -m venv "$TMP/run" |
| 28 | +"$TMP/run/bin/python" -m pip install -U pip >/dev/null |
| 29 | +"$TMP/run/bin/python" -m pip install "$WHEEL" |
| 30 | + |
| 31 | +# Documented public entry (README Quick start). The PyPI name is coderifts-sdk; |
| 32 | +# the import is coderifts — not coderifts_sdk. |
| 33 | +"$TMP/run/bin/python" -c " |
| 34 | +from coderifts import CodeRifts, read_decision, CodeRiftsError |
| 35 | +assert callable(CodeRifts) |
| 36 | +assert callable(read_decision) |
| 37 | +print('ok import coderifts CodeRifts,read_decision') |
| 38 | +" |
| 39 | + |
| 40 | +# Pytest against the installed wheel. Cwd is TMP so the source tree is not on |
| 41 | +# sys.path as a first-party package; tests live in ROOT/tests. |
| 42 | +"$TMP/run/bin/python" -m pip install 'pytest>=7' >/dev/null |
| 43 | +(cd "$TMP" && "$TMP/run/bin/python" -m pytest "$ROOT/tests" -q) |
| 44 | + |
| 45 | +echo "packed install smoke: OK" |
0 commit comments