From 71e6138c9a31fa4d6ba67f143b6ddf80ba69d1c5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 16 May 2026 06:40:19 -0500 Subject: [PATCH 1/2] tests(cli[sync_sigint]) Anchor subprocess import path to vcspull's resolved location why: Distro packagers (e.g. Arch Linux) test built wheels by staging them into a directory like ``tmp_install/usr/lib/python3.14/site-packages`` and pointing pytest at it via a *relative* ``PYTHONPATH`` entry from the source tree. The root conftest's autouse ``cwd_default`` fixture chdirs every test into a per-test ``tmp_path``, which the subprocess launched by ``test_exit_on_sigint_produces_wifsignaled_sigint`` inherits as its CWD. The child then resolves the relative ``PYTHONPATH`` against the tmp dir, where the staged wheel does not exist, and the test fails with ``ModuleNotFoundError: No module named 'vcspull'``. ``uv run pytest`` masks the bug because the venv exposes ``vcspull`` via absolute site-packages. what: - Locate ``vcspull``'s parent directory via ``importlib.util.find_spec`` and prepend it (absolute) to the child interpreter's ``PYTHONPATH``. - Preserve any incoming ``PYTHONPATH`` entry so other build setups remain unaffected. - Use ``find_spec`` rather than a bare ``import vcspull`` to keep ``mypy --strict`` quiet about the missing ``py.typed`` marker. --- tests/cli/test_sync_sigint.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/cli/test_sync_sigint.py b/tests/cli/test_sync_sigint.py index 1e3c9955f..569d1dd5c 100644 --- a/tests/cli/test_sync_sigint.py +++ b/tests/cli/test_sync_sigint.py @@ -2,7 +2,9 @@ from __future__ import annotations +import importlib.util import os +import pathlib import signal import subprocess import sys @@ -55,7 +57,24 @@ def test_exit_on_sigint_produces_wifsignaled_sigint() -> None: " _exit_on_sigint()\n" ) - env = {**os.environ, "PYTHONDONTWRITEBYTECODE": "1"} + # Pin the child's import path to wherever the parent loaded vcspull from. + # The root conftest's autouse ``cwd_default`` chdirs every test into a + # per-test ``tmp_path``, which the subprocess inherits as its CWD. Build + # environments that hand vcspull to pytest via a *relative* ``PYTHONPATH`` + # entry (e.g. Arch's ``tmp_install/usr/lib/pythonX.Y/site-packages``) + # would then resolve that entry against the tmp dir and fail to import + # vcspull. Prepending the parent's resolved package dir keeps the child + # importable regardless of the surrounding install style. + vcspull_spec = importlib.util.find_spec("vcspull") + assert vcspull_spec is not None and vcspull_spec.origin is not None + vcspull_parent = str(pathlib.Path(vcspull_spec.origin).resolve().parent.parent) + env = { + **os.environ, + "PYTHONDONTWRITEBYTECODE": "1", + "PYTHONPATH": os.pathsep.join( + p for p in (vcspull_parent, os.environ.get("PYTHONPATH", "")) if p + ), + } proc = subprocess.run( [sys.executable, "-c", runner], From ffd1308f360fea6216f6c39a7b853c260706b297 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 16 May 2026 06:44:28 -0500 Subject: [PATCH 2/2] docs(CHANGES) note distro relative-PYTHONPATH test fix why: Capture the packager-visible behaviour change so distros can see in the release notes that vcspull's test suite once again runs end to end under staged-install plus relative ``PYTHONPATH``. --- CHANGES | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES b/CHANGES index 970b2bd1c..2a9554eb5 100644 --- a/CHANGES +++ b/CHANGES @@ -37,6 +37,15 @@ $ uvx --from 'vcspull' --prerelease allow vcspull _Notes on upcoming releases will be added here_ +### Development + +#### Test suite works under distro relative-`PYTHONPATH` builds (#549) + +Distributions that test built wheels by staging them into a directory +and pointing pytest at that directory via a relative `PYTHONPATH` entry +from the source tree (the common Arch Linux PKGBUILD pattern) can now +run vcspull's full test suite end to end. + ## vcspull v1.60.0 (2026-05-18) vcspull v1.60.0 is a maintenance release for the May 2026 docs and