diff --git a/setup.py b/setup.py index 85228bd37ae..881ff49ab84 100644 --- a/setup.py +++ b/setup.py @@ -684,6 +684,21 @@ class CustomBuildPy(build_py): a file to a different relative location under the output package directory. """ + def analyze_manifest(self): + super().analyze_manifest() + # Recent versions of setuptools may include bare directory symlinks from version + # control (e.g. src/executorch/{backends,codegen,data,...} -> + # ../../) 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. + if not self.editable_mode: + _root = os.path.dirname(os.path.abspath(__file__)) + for _pkg in list(self.manifest_files): + self.manifest_files[_pkg] = [ + _f for _f in self.manifest_files[_pkg] + if os.path.isfile(os.path.join(_root, _f)) + ] + def run(self): # Copy python files to the output directory. This set of files is # defined by the py_module list and package_data patterns.