Repository navigation
Conversation
Normalize the directory with Path before escaping it for the nested build command, so a trailing native directory separator cannot escape the closing quote of the generated --output argument.
There was a problem hiding this comment.
Hey - I've reviewed your changes and they look great!
Linked issues
#11199 publish --build --dist-dir fails when the directory ends with a separator · 1 of 1 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Write build artifacts to exactly the requested directory when --dist-dir ends with a native directory separator. | ✅ Met | The nested build output path is normalized with str(Path(dist_dir)) before quoting, and the regression test checks the artifacts are in the requested directory. |
Sourcery assessment
Needs a human reviewer. If path normalization selects the wrong output directory, the build can leave generated artifacts there; they are bounded and can be removed or rebuilt. Reverting restores the old behavior but does not remove files already created.
57b2b12 to
235abe3
Compare
agammann
left a comment
There was a problem hiding this comment.
[P3] Handle a Windows drive or UNC root ending in a separator
In publish.py, str(Path(dist_dir)) keeps the trailing backslash when dist_dir is a root such as C:\ or \\server\share\. In that case the generated quoted --output argument still ends in a backslash before its closing quote, which Cleo treats as escaped. Thus poetry publish --build --dist-dir C:\ still has the trailing-separator failure this PR addresses. Could the nested build command receive an argv list, or could this special case escape the final backslash? A Windows root-path regression case would catch it.
A Windows drive, UNC or current-drive root keeps its trailing separator after Path normalization, so the quoted --output argument still ended in a backslash and cleo's tokenizer consumed the closing quote. Append a dot component instead; Path() drops it again when the nested build command resolves the directory. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Good catch — fixed in
The only consumer is Added |
Linked issuesChecked at commit 9289c26 #11199 publish --build --dist-dir fails when the directory ends with a separator · 1 of 1 met
|
Resolves: #11199
Summary
--dist-dirwithstr(Path(dist_dir))before escaping it for the nestedpoetry buildcall. This restores the normalization described in fix(publish): keep the dist dir a single argument when building #11171 and prevents a trailing native directory separator from escaping the closing quote of the generated--output "..."argument. Before this change, a trailing native separator on Windows produced adist"build target and failed with[WinError 123].test_publish_dist_dir_with_spaces_and_build_options, parametrized with"to build/dist" + os.sep. The test asserts artifacts land in the exact requested directory and that nodist"directory is created. It drives the command withArgvInputbecauseCommandTester.execute()parses a string with cleo's tokenizer and cannot represent an argument that ends with a backslash.Testing
python -m pytest tests/console/commands/test_publish.py -k dist_dir -q: 10 passed with the fix; on Windows without the fix, 1 failed / 9 passed (the new trailing-separator case fails with[WinError 123]onto build\dist").python -m pytest tests/console/commands/test_publish.py -q: 21 passed.python -m mypy src/poetry/console/commands/publish.py: no issues.poetry publish --build --dry-run --dist-dir 'dist\'failed with[WinError 123] ... 'dist"'before the fix; after the fix it builds and uploads fromdist. The--dist-dir "my dist"control (space, no trailing separator) keeps working./already worked and is not affected by this Windows-specific path.Checklist
CHANGELOG.mdis updated at release time and the repo has no per-PR fragment convention.