Skip to content

Commit 97c153f

Browse files
authored
Setuptools symlinks (pytorch#20092)
### Summary build_py: filter directory symlinks from manifest_files in non-editable mode Recent setuptools includes bare directory symlinks (e.g. src/executorch/backends -> ../../backends) from version control in manifest_files. These exist for editable mode but break regular installs: build_package_data passes them to copy_file, which calls os.path.isfile() and gets False for a symlink-to-directory. Override analyze_manifest() to filter out non-regular-file entries after the parent populates manifest_files, guarded by editable_mode. Fixes pytorch#20091 ### Test plan Run the command in the bug report with the problematic Python version as reported. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani
1 parent 92e6a4c commit 97c153f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

setup.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,22 @@ class CustomBuildPy(build_py):
684684
a file to a different relative location under the output package directory.
685685
"""
686686

687+
def analyze_manifest(self):
688+
super().analyze_manifest()
689+
# Recent versions of setuptools may include bare directory symlinks from version
690+
# control (e.g. src/executorch/{backends,codegen,data,...} ->
691+
# ../../<name>) in manifest_files. These exist for editable mode but
692+
# break regular installs: build_package_data passes them to copy_file,
693+
# which calls os.path.isfile() and gets False for a symlink-to-directory.
694+
if not self.editable_mode:
695+
_root = os.path.dirname(os.path.abspath(__file__))
696+
for _pkg in list(self.manifest_files):
697+
self.manifest_files[_pkg] = [
698+
_f
699+
for _f in self.manifest_files[_pkg]
700+
if os.path.isfile(os.path.join(_root, _f))
701+
]
702+
687703
def run(self):
688704
# Copy python files to the output directory. This set of files is
689705
# defined by the py_module list and package_data patterns.

0 commit comments

Comments
 (0)