diff --git a/.work-item.toml b/.work-item.toml index 3ad1bcf..3aa3c0e 100644 --- a/.work-item.toml +++ b/.work-item.toml @@ -8,7 +8,7 @@ main_branch = "main" [workflow] branch_prefix = "us" require_ci = false -required_tests = ["python3 -m unittest discover -s tests -v"] +required_tests = ["scripts/python -m unittest discover -s tests -v"] [safety] max_file_bytes = 5000000 diff --git a/README.md b/README.md index 12213b2..d7c6b3b 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Requirements: Python 3.11+, Git, and an authenticated `tea` login named `domvers scripts/work-item next scripts/work-item claim scripts/work-item status -scripts/work-item submit --test "python3 -m unittest discover -s tests -v" -scripts/work-item submit --test "python3 -m unittest discover -s tests -v" --yes +scripts/work-item submit --test "scripts/python -m unittest discover -s tests -v" +scripts/work-item submit --test "scripts/python -m unittest discover -s tests -v" --yes scripts/work-item complete --merge scripts/work-item block --reason "precise blocking condition" ``` @@ -28,5 +28,5 @@ machine-readable source of truth; the Gitea Project board is the visual view. ## Tests ```bash -python3 -m unittest discover -s tests -v +scripts/python -m unittest discover -s tests -v ``` diff --git a/scripts/python b/scripts/python new file mode 100755 index 0000000..d9bca48 --- /dev/null +++ b/scripts/python @@ -0,0 +1,11 @@ +#!/bin/sh +set -eu + +for python in python3.13 python3.12 python3.11; do + if command -v "$python" >/dev/null 2>&1; then + exec "$python" "$@" + fi +done + +echo "photoanalyzer: Python 3.11 or newer is required" >&2 +exit 2 diff --git a/scripts/work-item b/scripts/work-item index b9a0888..86d29d4 100755 --- a/scripts/work-item +++ b/scripts/work-item @@ -1,11 +1,5 @@ #!/bin/sh set -eu -for python in python3.13 python3.12 python3.11; do - if command -v "$python" >/dev/null 2>&1; then - exec "$python" -m work_item "$@" - fi -done - -echo "work-item: Python 3.11 or newer is required" >&2 -exit 2 +SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +exec "$SCRIPT_DIR/python" -m work_item "$@" diff --git a/tests/test_cli_e2e.py b/tests/test_cli_e2e.py index 8a12b99..7db1478 100644 --- a/tests/test_cli_e2e.py +++ b/tests/test_cli_e2e.py @@ -219,5 +219,16 @@ class CliEndToEndTests(unittest.TestCase): self.assertIn("Provider fixture unavailable", self.state()["comments"][-1]["body"]) +class InterpreterWrapperTests(unittest.TestCase): + def test_wrapper_selects_supported_python(self) -> None: + result = run( + [str(SOURCE_ROOT / "scripts" / "python"), "-c", "import sys; print(sys.version_info[:2])"], + cwd=SOURCE_ROOT, + ) + major, minor = eval(result.stdout.strip(), {"__builtins__": {}}) + self.assertEqual(major, 3) + self.assertGreaterEqual(minor, 11) + + if __name__ == "__main__": unittest.main()