Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.d/+backend-path-whitespace.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep a trailing space in the last backend path when putting it on ``PYTHONPATH``.
2 changes: 1 addition & 1 deletion src/pyproject_api/_via_fresh_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(
@contextmanager
def _send_msg(self, cmd: str, result_file: Path, msg: str) -> Generator[SubprocessCmdStatus, None, None]: # ruff:ignore[unused-method-argument]
env = os.environ.copy()
backend = os.pathsep.join(str(i) for i in self._backend_paths).strip()
backend = os.pathsep.join(str(i) for i in self._backend_paths)
if backend:
env["PYTHONPATH"] = backend
process = Popen( # ruff:ignore[subprocess-without-shell-equals-true] # fixed argv, no shell
Expand Down
12 changes: 12 additions & 0 deletions tests/test_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def get_requires_for_build_wheel(config_settings=None):
assert frontend.get_requires_for_build_wheel().requires == (Requirement("wheel"),)


@pytest.mark.skipif(sys.platform == "win32", reason="Windows drops trailing spaces from names")
def test_backend_path_with_trailing_space(tmp_path: Path) -> None: # pragma: win32 no cover
backend: Final = tmp_path / "backend "
backend.mkdir()
(backend / "build_tester.py").write_text(
"def get_requires_for_build_wheel(config_settings=None):\n return ['wheel']\n"
)
frontend: Final = SubprocessFrontend(tmp_path, (backend,), "build_tester", None, ())

assert frontend.get_requires_for_build_wheel().requires == (Requirement("wheel"),)


@pytest.mark.parametrize(
"hook",
[
Expand Down
Loading