Skip to content

🐛 fix(subprocess): keep PYTHONPATH when backend-path is set - #375

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
HarshJamgaonkar05:fix/backend-path-keep-pythonpath
Nov 18, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
HarshJamgaonkar05:fix/backend-path-keep-pythonpath

Conversation

@HarshJamgaonkar05

Copy link
Copy Markdown
Contributor

Fixes #374.

SubprocessFrontend set PYTHONPATH to the backend-path entries and discarded the caller's value. An in-tree backend
then could not import anything that was only reachable through PYTHONPATH, and the backend failed to start with
ModuleNotFoundError. The backend-path entries now go in front of the existing PYTHONPATH. That keeps the PEP 517
order (in-tree paths first) and leaves the caller's paths importable after them. Without backend-path, nothing changes.

Tests:

  • New test_backend_path_keeps_existing_pythonpath puts a helper module on PYTHONPATH that the in-tree backend
    imports. The same directory also holds a decoy module with the backend's name, so the test fails if PYTHONPATH ever
    ends up ahead of backend-path. The test fails on main with ModuleNotFoundError: No module named 'helper' and
    passes with this change.
  • The reproducer from SubprocessFrontend drops the caller's PYTHONPATH when build-system.backend-path is set #374 prints demo-1.0.tar.gz with this change.
  • On Windows, the full suite has the same results before and after, apart from the new test. The 18 symlink tests fail
    both before and after, because this account cannot create symlinks.

🤖 Generated with Claude Code

SubprocessFrontend replaced PYTHONPATH with the backend-path entries, so
an in-tree backend could no longer import anything the caller provided
through PYTHONPATH and failed to start with ModuleNotFoundError. The
backend-path entries now go in front of the existing value instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gaborbernat gaborbernat added the bug Something isn't working label Nov 17, 2026
@gaborbernat
gaborbernat merged commit 8bc397f into tox-dev:main Nov 18, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SubprocessFrontend drops the caller's PYTHONPATH when build-system.backend-path is set

2 participants