Skip to content

filelist: keep original path when a directory symlink points inside the tree - #429

Open
r3wretrhy wants to merge 1 commit into
pypa:mainfrom
r3wretrhy:filelist-keep-original-dir-path
Open

r3wretrhy wants to merge 1 commit into
pypa:mainfrom
r3wretrhy:filelist-keep-original-dir-path

Conversation

@r3wretrhy

Copy link
Copy Markdown

_UniqueDirs keys os.walk(..., followlinks=True) entries on (st_dev, st_ino). A directory and a symlink to it therefore collapse to one path, and whichever name is visited first is the one that appears in the file list. Creating the symlink after the directory can make foo/a disappear and leave the contents under foo/b.

Skip directory symlinks whose target is already inside the walk root so the original path is kept. A symlink that points outside the tree is still followed.

This is the distutils-side fix for pypa/setuptools#4937 (redirected from pypa/setuptools#5324).

Tests:

  • pytest distutils/tests/test_filelist.py — 13 passed, 4 skipped (Windows host without symlink privilege; mocked walk-order cases pass)

…he tree

Directory symlinks and their targets share an inode, so _UniqueDirs collapsed them and walk order decided which path landed in the file list. Skip in-tree directory symlinks so the original path is kept.
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.

1 participant