Skip to content

Commit fa1843d

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, the test fails with "Could not find a version that satisfies the requirement setuptools>=40.8.0 (from versions: none)", locally and in the weekly `tox` workflow alike. 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 ce16309 commit fa1843d

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

‎doc/gix-backend.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,14 @@ access. Cleanup of these isolated directories is best-effort, so a locked
187187
leftover cannot change pytest's exit status. Tests use local repositories,
188188
including the tutorial example. The suite needs loopback sockets for its Git daemon and
189189
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.
190+
server. By default, missing local tags or packages are errors, not invitations
191+
to download.
192+
193+
The runner keeps `PIP_NO_INDEX` if it is already set, and pip treats `0` as
194+
allowing the package index. `tox -e gix` sets it to `0` unless it is set, so
195+
its installation test can download build dependencies. To run that
196+
environment offline, set `PIP_NO_INDEX=1`, which tox also applies when
197+
installing the environment, and point `PIP_FIND_LINKS` at the wheels.
191198

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

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ set_env = { CLICOLOR_FORCE = "1" } # Set NO_COLOR to override this.
219219
commands = [["ruff", "check", "."]]
220220

221221
[tool.tox.env.gix]
222-
set_env = { GIT_PYTHON_BACKEND = "gix" }
222+
# Let tests download packages, as `test/run-local.py` otherwise forbids, unless PIP_NO_INDEX is already set.
223+
set_env = { GIT_PYTHON_BACKEND = "gix", PIP_NO_INDEX = { replace = "env", name = "PIP_NO_INDEX", default = "0" } }
223224
description = "Run the suite with released GixPython and CLI fallback"
224225
base_python = ["python3"]
225226
package_env = ".pkg-gix"

‎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",

0 commit comments

Comments
 (0)