Skip to content

Commit fdc5b7c

Browse files
codexByron
authored andcommitted
Add IPython completion to interactive release sessions
Launch IPython with gix imported when run-release receives no Python arguments. Install IPython only into uv's isolated interactive environment, and skip IPython configuration/startup files. Keep script and -c arguments on isolated ordinary Python without adding the interactive dependency. Validation: helper tests cover both version selections and preserve Python argument boundaries; just formatting and git diff --check pass. An explicit Python command still runs offline against the local wheel. The live IPython prompt could not be tested offline because IPython is not cached; no package-index installation was performed.
1 parent d29fb83 commit fdc5b7c

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎DEVELOPMENT.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ The package test also verifies importing the extension keeps the GIL disabled.
8585

8686
## Try a published release
8787

88-
With uv installed, open a Python prompt with `gix` already imported, or run a command:
88+
With uv installed, open an IPython prompt with `gix` already imported and Tab
89+
completion available, or run a Python command:
8990

9091
```sh
9192
just run-release
@@ -99,6 +100,9 @@ into an isolated uv virtualenv. It refreshes release resolution on each invocati
99100
uses the installed `PYTHON` interpreter, and requires a matching binary wheel;
100101
it does not build sources or install build tools. Python runs in isolated mode
101102
so inherited `PYTHONPATH` and the checkout's extension cannot shadow the release.
103+
Interactive sessions also install IPython into that virtualenv and skip loading
104+
IPython startup files and configuration. Script and `-c` arguments continue to
105+
use ordinary Python without installing IPython.
102106
Pass `latest` before any Python arguments; set `PYTHON` to an installed
103107
free-threaded interpreter to try its wheel. These commands read PyPI when invoked.
104108
Development builds continue using the local selection described above.

‎etc/test_justfile.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ def test_release_selection_and_python_arguments(self):
2121
stub.chmod(0o755)
2222
env = dict(os.environ, PATH=directory + os.pathsep + os.environ["PATH"], PYTHON=sys.executable,
2323
PYTHONPATH=str(root / "python"))
24+
interactive = ["--with", "ipython", "python", "-I", "-m", "IPython", "--quick", "-i", "-c",
25+
'import gix; print("GixPython", gix.__version__)']
2426
for arguments, package, python_args in (
25-
([], "GixPython", ["-i", "-c", 'import gix; print("GixPython", gix.__version__)']),
27+
([], "GixPython", interactive),
28+
(["0.1.0"], "GixPython==0.1.0", interactive),
2629
(["0.1.0", "-c", "import gix; print(gix.__version__)"], "GixPython==0.1.0",
27-
["-c", "import gix; print(gix.__version__)"]),
30+
["python", "-I", "-c", "import gix; print(gix.__version__)"]),
2831
(["latest", "script with spaces.py", "argument with spaces"], "GixPython",
29-
["script with spaces.py", "argument with spaces"]),
32+
["python", "-I", "script with spaces.py", "argument with spaces"]),
3033
):
3134
with self.subTest(arguments=arguments):
3235
result = subprocess.run(["just", "--justfile", str(root / "justfile"), "run-release", *arguments],
3336
cwd=root, env=env, check=True, capture_output=True, text=True)
3437
command = json.loads(result.stdout)
3538
self.assertEqual(command, ["run", "--no-project", "--isolated", "--no-python-downloads",
3639
"--python", sys.executable, "--no-build", "--upgrade-package",
37-
"GixPython", "--with", package, "python", "-I", *python_args])
40+
"GixPython", "--with", package, *python_args])
3841

3942

4043
if __name__ == "__main__":

‎justfile‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ artifacts *args:
5959
maturin build --sdist --release --locked --out dist --interpreter {{ quote(python) }} "$@"
6060
{{ quote(python) }} etc/check_artifact.py dist/*.tar.gz dist/*.whl
6161

62-
# Run the latest or a specified release in an isolated uv virtualenv (requires a wheel).
62+
# Explore a release in IPython with completion, or run Python arguments in an isolated uv virtualenv.
6363
[group('Releases')]
6464
[positional-arguments]
6565
run-release version='latest' *args:
6666
version="$1"; shift; \
6767
package=GixPython; \
6868
if [ "$version" != latest ]; then package="GixPython==$version"; fi; \
69-
if [ "$#" -eq 0 ]; then set -- -i -c 'import gix; print("GixPython", gix.__version__)'; fi; \
69+
if [ "$#" -eq 0 ]; then \
70+
set -- --with ipython python -I -m IPython --quick -i -c 'import gix; print("GixPython", gix.__version__)'; \
71+
else set -- python -I "$@"; fi; \
7072
uv run --no-project --isolated --no-python-downloads --python {{ quote(python) }} \
71-
--no-build --upgrade-package GixPython --with "$package" python -I "$@"
73+
--no-build --upgrade-package GixPython --with "$package" "$@"

0 commit comments

Comments
 (0)