Skip to content

Commit 84ed4f2

Browse files
EliahKaganclaude
andcommitted
build(tox): let the gix env's tests download packages
`tox -e gix` runs the test suite through `test/run-local.py`, which sets `PIP_NO_INDEX=1` so that nothing is downloaded during the run, and points `PIP_FIND_LINKS` at a hand-filled `.cache/gix-wheels` directory. But `test_installation` installs `./smmap`, `./gitdb`, and GitPython into a fresh virtual environment, and pip needs `setuptools` from the package index to build them. So without that directory, as on a fresh clone, the test fails with "Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)". tox itself has already installed the environment's dependencies from the index by then, so the restriction only stops this test. The environment and the runner were added in 212573b (gitpython-developers#2274); a commit message in that PR's earlier history noted that tox was not available to run it. Have `run-local.py` keep a `PIP_NO_INDEX` that is already set, as it already does for `PIP_FIND_LINKS`, and set `PIP_NO_INDEX` to `0` in the `gix` environment unless it is already set. A set value, including an empty one, is passed on unchanged, so pip treats it as it would anywhere else; pip takes an empty value, like `0`, as allowing the index. Running `run-local.py` directly stays offline by default, and `PIP_NO_INDEX=1 tox -e gix` still runs offline, though tox then also installs the environment without the index. The environment keeps the runner's private Git configuration, Git daemon port, and pytest temporary directory. Having the environment run pytest directly, like the other test environments, would also fix this, with a smaller diff, but would change more about how the environment runs. Document the new behavior in `doc/gix-backend.md`. With tox 4.22.0 and 4.67.1, `tox config -e gix` resolves `PIP_NO_INDEX` to `0` when it is unset, `1` when it is `1`, and empty when it is empty. With tox 4.67.1: - `tox -e gix -- test/test_installation.py` passed. - With `PIP_NO_INDEX=1`, the test failed as before, and in a new environment, tox's own installation of its dependencies failed for lack of an index. - Run directly with the environment's Python, `run-local.py` failed the test as before when `PIP_NO_INDEX` was unset, and passed when it was empty. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7f50cfa commit 84ed4f2

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

‎doc/gix-backend.md‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,20 @@ the test aliases directly, matching CI without introducing config includes.
182182

183183
The runner uses local version tags, creates an isolated Git configuration,
184184
prepares the historical test fixture through cached Bash scripts, gives
185-
pytest a separate temporary root for each run, and disables package-index
186-
access. Cleanup of these isolated directories is best-effort, so a locked
187-
leftover cannot change pytest's exit status. Tests use local repositories,
188-
including the tutorial example. The suite needs loopback sockets for its Git daemon and
189-
permission to inspect its own child processes. It does not need a remote Git
190-
server. Missing local tags or packages are errors, not invitations to download.
185+
pytest a separate temporary root for each run, and by default disables
186+
package-index access. Cleanup of these isolated directories is best-effort,
187+
so a locked leftover cannot change pytest's exit status. Tests use local
188+
repositories, including the tutorial example. The suite needs loopback
189+
sockets for its Git daemon and permission to inspect its own child
190+
processes. It does not need a remote Git server. Missing local tags are
191+
errors, not invitations to download, and by default so are missing
192+
packages.
193+
194+
The runner keeps `PIP_NO_INDEX` if it is already set, and pip treats `0` as
195+
allowing the package index. `tox -e gix` sets it to `0` unless it is set, so
196+
its installation test can download build dependencies. To run that
197+
environment offline, set `PIP_NO_INDEX=1`, which tox also applies when
198+
installing the environment, and point `PIP_FIND_LINKS` at the wheels.
191199

192200
The ignored `.cache/gix-wheels` directory contains the published GixPython wheel and
193201
the build/test dependencies available on this machine. To recreate an

‎test/run-local.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def main():
2626
**os.environ,
2727
"GIT_CONFIG_NOSYSTEM": "1",
2828
"GIT_CONFIG_GLOBAL": str(config),
29-
"PIP_NO_INDEX": "1",
29+
"PIP_NO_INDEX": os.environ.get("PIP_NO_INDEX", "1"),
3030
"PIP_DISABLE_PIP_VERSION_CHECK": "1",
3131
"PIP_FIND_LINKS": os.environ.get("PIP_FIND_LINKS", str(root / ".cache/gix-wheels")),
3232
"UV_OFFLINE": "1",

‎tox.ini‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ set_env =
3333
commands = ruff check .
3434

3535
[testenv:gix]
36-
set_env = GIT_PYTHON_BACKEND=gix
36+
# Let tests download packages, as `test/run-local.py` otherwise forbids, unless `PIP_NO_INDEX` is already set.
37+
set_env =
38+
GIT_PYTHON_BACKEND=gix
39+
PIP_NO_INDEX={env:PIP_NO_INDEX:0}
3740
description = Run the suite with released GixPython and CLI fallback
3841
base_python = python3
3942
package_env = .pkg-gix

0 commit comments

Comments
 (0)