Skip to content

Commit 1c889e2

Browse files
committed
better wheel search
1 parent 148282c commit 1c889e2

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Project components:
2525
### Compatibility shim (`pyontoenv-shim/`)
2626
- From `pyontoenv-shim/`, run `uv build --wheel` to produce the `pyontoenv` wheel that re-exports the bindings.
2727
- `uv run python -m unittest discover -s tests` (inside `pyontoenv-shim/`) validates the shim and its aliasing behavior.
28-
- `uv run python scripts/test_pyontoenv.py` (run from `pyontoenv-shim/`) installs the freshly built wheels into a throwaway virtualenv and sanity-checks imports and the CLI.
28+
- `uv run python scripts/test_pyontoenv.py` (run from `pyontoenv-shim/`) installs the freshly built wheels into a throwaway virtualenv and sanity-checks imports and the CLI; it reads the ontoenv wheel from `../python/target/wheels/` by default.
2929
- The helper `./version <new-version>` bumps the workspace version and refreshes related manifests for both Rust and Python packages.
3030

3131
## Overview

pyontoenv-shim/scripts/test_pyontoenv.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,24 @@
1515
import tempfile
1616
from pathlib import Path
1717

18-
ROOT = Path(__file__).resolve().parents[2]
19-
20-
21-
def pick_wheel(path: Path, pattern: str) -> Path:
22-
matches = sorted(path.glob(pattern))
23-
if not matches:
24-
raise SystemExit(f"no wheels match '{pattern}' under {path}")
25-
return matches[-1]
18+
SCRIPT_PATH = Path(__file__).resolve()
19+
SHIM_DIR = SCRIPT_PATH.parents[1]
20+
REPO_ROOT = SCRIPT_PATH.parents[2]
21+
PYTHON_WHEEL_DIRS = [
22+
SHIM_DIR.parent / "python" / "target" / "wheels",
23+
SHIM_DIR.parent / "python" / "target" / "release",
24+
REPO_ROOT / "target" / "wheels",
25+
]
26+
SHIM_WHEEL_DIR = SHIM_DIR / "dist"
27+
28+
29+
def pick_wheel(pattern: str, search_paths: list[Path]) -> Path:
30+
for base in search_paths:
31+
matches = sorted(base.glob(pattern))
32+
if matches:
33+
return matches[-1]
34+
joined = ", ".join(str(path) for path in search_paths)
35+
raise SystemExit(f"no wheels match '{pattern}' under any of: {joined}")
2636

2737

2838
def run(cmd: list[str], **kwargs) -> None:
@@ -39,13 +49,13 @@ def main() -> None:
3949
ontoenv_wheel = (
4050
args.ontoenv_wheel
4151
if args.ontoenv_wheel
42-
else pick_wheel(ROOT / "python" / "target" / "wheels", "ontoenv-*.whl")
43-
)
52+
else pick_wheel("ontoenv-*.whl", PYTHON_WHEEL_DIRS)
53+
).resolve()
4454
shim_wheel = (
4555
args.shim_wheel
4656
if args.shim_wheel
47-
else pick_wheel(ROOT / "pyontoenv-shim" / "dist", "pyontoenv-*.whl")
48-
)
57+
else pick_wheel("pyontoenv-*.whl", [SHIM_WHEEL_DIR])
58+
).resolve()
4959

5060
with tempfile.TemporaryDirectory(prefix="pyontoenv-test-") as tmp:
5161
venv_dir = Path(tmp) / "venv"

0 commit comments

Comments
 (0)