Skip to content

Commit d29fb83

Browse files
codexByron
authored andcommitted
Add grouped developer recipes and an isolated release runner
Group the existing justfile recipes under Development, Tests, and Releases using Gitoxide's conventions. Add Rust formatting/unit-test and build-helper check recipes, and preserve argument boundaries for build and artifact options. Provide run-release for the latest or a specified GixPython version in uv's isolated virtualenv. Require a binary wheel, use installed Python, refresh version resolution, and isolate Python imports from inherited PYTHONPATH. Open an interactive prompt by default or forward Python script/command arguments. Document usage and add an argument regression check without package-index access. Validation: just formatting and helper checks pass; latest, versioned, and default interactive release commands run offline using a local wheel and import it despite PYTHONPATH=python. No PyPI operations, pushes, or tagged-history changes.
1 parent 412820a commit d29fb83

3 files changed

Lines changed: 117 additions & 10 deletions

File tree

‎DEVELOPMENT.md‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,34 @@ cargo clippy --locked --all-targets -- -D warnings
7676
cargo test --locked --lib
7777
```
7878

79-
The `justfile` provides the same commands. Select an installed free-threaded interpreter in place of `python3` to test that ABI. Use `PYTHON_GIL=0` for free-threaded tests; the package test also verifies importing the extension keeps the GIL disabled.
79+
The `justfile` groups common commands under Development, Tests, and Releases,
80+
following Gitoxide. Run `just` to list them. `just build`, `just test`, `just check`,
81+
`just fmt`, `just unit-tests`, and `just helper-tests` cover the usual development
82+
loop. Set `PYTHON` to select an installed interpreter.
83+
`just test-free-threaded /path/to/python3.14t` builds and tests the free-threaded ABI with `PYTHON_GIL=0`.
84+
The package test also verifies importing the extension keeps the GIL disabled.
85+
86+
## Try a published release
87+
88+
With uv installed, open a Python prompt with `gix` already imported, or run a command:
89+
90+
```sh
91+
just run-release
92+
just run-release 0.1.0
93+
just run-release latest -c 'import gix; print(gix.__version__, gix.build_features())'
94+
just run-release 0.1.0 /path/to/script.py
95+
```
96+
97+
This recipe downloads the latest compatible stable release, or the given version,
98+
into an isolated uv virtualenv. It refreshes release resolution on each invocation,
99+
uses the installed `PYTHON` interpreter, and requires a matching binary wheel;
100+
it does not build sources or install build tools. Python runs in isolated mode
101+
so inherited `PYTHONPATH` and the checkout's extension cannot shadow the release.
102+
Pass `latest` before any Python arguments; set `PYTHON` to an installed
103+
free-threaded interpreter to try its wheel. These commands read PyPI when invoked.
104+
Development builds continue using the local selection described above.
105+
106+
## Integration checks
80107

81108
Each new binding should have a focused Python integration check against a disposable repository. Verify errors as well as success, both supported hash kinds, and any meaningful reduced feature configuration. Compare with Git when it provides an appropriate reference result.
82109

‎etc/test_justfile.py‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""Check release recipe arguments without downloading or installing packages."""
2+
3+
import json
4+
import os
5+
from pathlib import Path
6+
import shutil
7+
import subprocess
8+
import sys
9+
import tempfile
10+
import unittest
11+
12+
13+
@unittest.skipUnless(shutil.which("just"), "requires just")
14+
class JustfileTests(unittest.TestCase):
15+
def test_release_selection_and_python_arguments(self):
16+
root = Path(__file__).resolve().parents[1]
17+
with tempfile.TemporaryDirectory() as directory:
18+
stub = Path(directory) / "uv"
19+
# Use the selected Python to record uv's arguments instead of running it.
20+
stub.write_text('#!/bin/sh\nexec "$PYTHON" -c \'import json, sys; print(json.dumps(sys.argv[1:]))\' "$@"\n')
21+
stub.chmod(0o755)
22+
env = dict(os.environ, PATH=directory + os.pathsep + os.environ["PATH"], PYTHON=sys.executable,
23+
PYTHONPATH=str(root / "python"))
24+
for arguments, package, python_args in (
25+
([], "GixPython", ["-i", "-c", 'import gix; print("GixPython", gix.__version__)']),
26+
(["0.1.0", "-c", "import gix; print(gix.__version__)"], "GixPython==0.1.0",
27+
["-c", "import gix; print(gix.__version__)"]),
28+
(["latest", "script with spaces.py", "argument with spaces"], "GixPython",
29+
["script with spaces.py", "argument with spaces"]),
30+
):
31+
with self.subTest(arguments=arguments):
32+
result = subprocess.run(["just", "--justfile", str(root / "justfile"), "run-release", *arguments],
33+
cwd=root, env=env, check=True, capture_output=True, text=True)
34+
command = json.loads(result.stdout)
35+
self.assertEqual(command, ["run", "--no-project", "--isolated", "--no-python-downloads",
36+
"--python", sys.executable, "--no-build", "--upgrade-package",
37+
"GixPython", "--with", package, "python", "-I", *python_args])
38+
39+
40+
if __name__ == "__main__":
41+
unittest.main()

‎justfile‎

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,71 @@
11
python := env_var_or_default("PYTHON", "python3")
2+
j := quote(just_executable())
23

34
# Show the available development commands.
5+
[private]
46
default:
5-
@just --list
7+
@{{ j }} --list --unsorted
68

79
# Build for the selected installed Python without a Python package index.
10+
[group('Development')]
11+
[positional-arguments]
812
build *args:
9-
{{python}} etc/build.py {{args}}
13+
{{ quote(python) }} etc/build.py "$@"
1014

1115
# Run the Python integration checks against the local extension.
16+
[group('Tests')]
1217
test: build
13-
PYTHONPATH=python {{python}} -m unittest discover -s tests
18+
PYTHONPATH=python {{ quote(python) }} -m unittest discover -s tests
1419

1520
# Check Rust formatting and lints.
21+
[group('Development')]
1622
check:
1723
cargo fmt --all -- --check
18-
cargo clippy --all-targets -- -D warnings
24+
cargo clippy --locked --all-targets -- -D warnings
25+
26+
# Format Rust sources and the justfile.
27+
[group('Development')]
28+
fmt:
29+
cargo fmt --all
30+
{{ j }} --fmt --unstable
1931

2032
# Build an optimized local extension.
33+
[group('Development')]
2134
release:
22-
{{python}} etc/build.py --release
35+
{{ quote(python) }} etc/build.py --release
2336

2437
# Exercise the extension with an installed free-threaded Python.
38+
[group('Tests')]
2539
test-free-threaded interpreter:
26-
{{interpreter}} etc/build.py
27-
PYTHONPATH=python PYTHON_GIL=0 {{interpreter}} -m unittest discover -s tests
40+
{{ quote(interpreter) }} etc/build.py
41+
PYTHONPATH=python PYTHON_GIL=0 {{ quote(interpreter) }} -m unittest discover -s tests
42+
43+
# Run Rust unit tests against the packaged dependencies.
44+
[group('Tests')]
45+
unit-tests:
46+
cargo test --locked --lib
47+
48+
# Check the build, release, and justfile helpers without building the extension.
49+
[group('Tests')]
50+
helper-tests:
51+
{{ quote(python) }} etc/test_build.py
52+
{{ quote(python) }} etc/test_check_release.py
53+
{{ quote(python) }} etc/test_justfile.py
2854

2955
# Build review candidates from a complete source archive; never publish them.
56+
[group('Releases')]
57+
[positional-arguments]
3058
artifacts *args:
31-
maturin build --sdist --release --locked --out dist --interpreter {{python}} {{args}}
32-
{{python}} etc/check_artifact.py dist/*.tar.gz dist/*.whl
59+
maturin build --sdist --release --locked --out dist --interpreter {{ quote(python) }} "$@"
60+
{{ quote(python) }} etc/check_artifact.py dist/*.tar.gz dist/*.whl
61+
62+
# Run the latest or a specified release in an isolated uv virtualenv (requires a wheel).
63+
[group('Releases')]
64+
[positional-arguments]
65+
run-release version='latest' *args:
66+
version="$1"; shift; \
67+
package=GixPython; \
68+
if [ "$version" != latest ]; then package="GixPython==$version"; fi; \
69+
if [ "$#" -eq 0 ]; then set -- -i -c 'import gix; print("GixPython", gix.__version__)'; fi; \
70+
uv run --no-project --isolated --no-python-downloads --python {{ quote(python) }} \
71+
--no-build --upgrade-package GixPython --with "$package" python -I "$@"

0 commit comments

Comments
 (0)