Skip to content

Commit 4b511bf

Browse files
EliahKaganclaude
andcommitted
build(tox): let the gix env's tests use the package index
`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. Give `run-local.py` an `--allow-index` option, accepted as its first argument, with which it sets neither `PIP_NO_INDEX` nor `PIP_FIND_LINKS`, and have the `gix` environment pass it. pip then follows its own configuration, from environment variables or a pip configuration file, as tox already does when installing the environment. Without the option, `run-local.py` disables the index and points `PIP_FIND_LINKS` at `.cache/gix-wheels` unless it is set, as before. The environment keeps the runner's private Git configuration, Git daemon port, and pytest temporary directory. Document this in `doc/gix-backend.md`. Having the `gix` environment set `PIP_NO_INDEX=0` would be simpler, but pip lets environment variables override its configuration files, so that would also override a `no-index` setting in a pip configuration file, both in the tests and when tox installs the environment. For the same reason, the option leaves `PIP_FIND_LINKS` unset, since its default would override a `find-links` setting. Having the environment run pytest directly, like the other test environments, would also fix this, but would change more about how it runs. Checked with tox 4.67.1: - `tox config -e gix` shows `--allow-index` before the default arguments, and before arguments given after `--`. - `tox -r -e gix -- test/test_installation.py` passed. - With `PIP_NO_INDEX=1`, and with a pip configuration file (through `PIP_CONFIG_FILE`) that sets `no-index = true`, the test failed for lack of an index, and so did tox's own installation of a new environment. - With a local directory holding the wheels it needs, the test passed offline in an existing environment, both with `no-index` and `find-links` in a pip configuration file and with `PIP_NO_INDEX=1` and `PIP_FIND_LINKS`. - Run directly with the environment's Python, `run-local.py` failed the test as before, even with `PIP_NO_INDEX=0`, and passed with `--allow-index`. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ef3e8a0 commit 4b511bf

3 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎doc/gix-backend.md‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,21 @@ 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+
With `--allow-index` as its first argument, the runner neither disables the
195+
package index nor sets `PIP_FIND_LINKS`, so pip follows its own configuration.
196+
`tox -e gix` passes that option, so that its installation test can download
197+
build dependencies. To run that environment offline, set `PIP_NO_INDEX=1` or
198+
configure pip with `no-index`, which tox also follows when installing the
199+
environment, and point `PIP_FIND_LINKS` or pip's `find-links` at the wheels.
191200

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

‎test/run-local.py‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
33
Use the Python interpreter from the installation to test, for example:
44
.tox/gix/bin/python test/run-local.py --backend-report=.cache/gix-coverage.json
5+
6+
Package-index access is disabled, and packages come from .cache/gix-wheels or PIP_FIND_LINKS,
7+
unless --allow-index is the first argument, in which case pip is left to use its own
8+
configuration.
59
"""
610

711
import os
@@ -15,6 +19,8 @@
1519

1620
def main():
1721
root = Path(__file__).resolve().parent.parent
22+
allow_index = sys.argv[1:2] == ["--allow-index"]
23+
pytest_args = sys.argv[2:] if allow_index else sys.argv[1:]
1824
sys.path.insert(0, str(root))
1925
from test.lib.fixtures import writable_fixture
2026

@@ -26,11 +32,12 @@ def main():
2632
**os.environ,
2733
"GIT_CONFIG_NOSYSTEM": "1",
2834
"GIT_CONFIG_GLOBAL": str(config),
29-
"PIP_NO_INDEX": "1",
3035
"PIP_DISABLE_PIP_VERSION_CHECK": "1",
31-
"PIP_FIND_LINKS": os.environ.get("PIP_FIND_LINKS", str(root / ".cache/gix-wheels")),
3236
"UV_OFFLINE": "1",
3337
}
38+
if not allow_index:
39+
env["PIP_NO_INDEX"] = "1"
40+
env["PIP_FIND_LINKS"] = os.environ.get("PIP_FIND_LINKS", str(root / ".cache/gix-wheels"))
3441
if sys.platform == "win32" and "GIT_PYTHON_GIT_EXECUTABLE" not in env:
3542
executable = shutil.which("git")
3643
if executable is None:
@@ -43,7 +50,7 @@ def main():
4350
listener.bind(("127.0.0.1", 0))
4451
env["GIT_PYTHON_TEST_GIT_DAEMON_PORT"] = str(listener.getsockname()[1])
4552
return subprocess.call(
46-
[sys.executable, "-m", "pytest", "--basetemp", str(temporary / "pytest"), *sys.argv[1:]],
53+
[sys.executable, "-m", "pytest", "--basetemp", str(temporary / "pytest"), *pytest_args],
4754
cwd=root,
4855
env=env,
4956
)

‎tox.ini‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ base_python = python3
3939
package_env = .pkg-gix
4040
wheel_build_env = .pkg-gix
4141
extras = test, gix
42-
commands = python test/run-local.py {posargs:--backend-report=.cache/gix-coverage.json}
42+
# Let the tests use the package index, as pip is configured to, rather than disabling it.
43+
commands = python test/run-local.py --allow-index {posargs:--backend-report=.cache/gix-coverage.json}
4344

4445
[testenv:format]
4546
description = Check formatting with Ruff

0 commit comments

Comments
 (0)