Skip to content

Skip in-tree directory links so sdist keeps the real package - #2388

Open
Kayforkind wants to merge 3 commits into
pypa:masterfrom
Kayforkind:fix/1197-in-tree-dir-symlink
Open

Skip in-tree directory links so sdist keeps the real package#2388
Kayforkind wants to merge 3 commits into
pypa:masterfrom
Kayforkind:fix/1197-in-tree-dir-symlink

Conversation

@Kayforkind

Copy link
Copy Markdown

Summary

  • safe_walk follows directory links and records (st_dev, st_ino) to stop cycles. A junction or symlink whose name sorts before its target (barfoo) was marking foo's inode as already seen, so the real package was never walked.
  • In-tree directory symlinks and Windows junctions are now skipped so the real path is packed. Out-of-tree links are still followed. Cycle detection is unchanged.
  • exclude of the alias no longer drops the real package's files.

Fixes #1197.
Fixes #2008.

Test plan

AI disclosure

Assisted by Cursor. I directed the change, reviewed inode first-seen-wins vs cycle detection, and verified the tests above. No Co-authored-by LLM trailer.

Made with Cursor

A junction or symlink that sorts before its target was marking the target inode as seen, which dropped packages from sdists.
Comment thread backend/src/hatchling/builders/utils.py Outdated
identifier = stat.st_dev, stat.st_ino
# An in-tree directory symlink/junction that sorts before its target
# would otherwise mark the target inode as seen and skip the real
# directory (issues #1197, #2008). Skip the alias so the real path is

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not include issue links or reference numbers in comments. And comments should explain things that are not clearly explainable by reading the code itself.

Comment on lines +172 to +173
https://github.com/pypa/hatch/issues/1197
https://github.com/pypa/hatch/issues/2008

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove issue links from comments

Kayforkind and others added 2 commits August 18, 2026 20:20
Review asked that comments explain only the inode first-seen-wins trap, without ticket links.
@Kayforkind

Copy link
Copy Markdown
Author

@cjames23 thanks for the master sync. Comment cleanup in �ackend/src/hatchling/builders/utils.py and ests/backend/builders/plugin/test_interface.py is in ef34209 — issue links dropped, comment kept to the inode first-seen-wins trap that isn't obvious from the code. CI is green on the merged HEAD. Ready when you are for another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent/surprising symlink handling during sdist build? Junctions/symbolic links can cause directories to be missing from source distributions

2 participants