diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2019-12-21 22:04:09 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2019-12-21 22:23:20 -0500 |
commit | 3910bbb8d57a8f811ce863e9e1d09ae631cfe353 (patch) | |
tree | 083f34c7864d9798551e2f72378a3cd2ccc88bf3 /setuptools/command/sdist.py | |
parent | 1d03fdc94c3676a5b675ec7d818d48c6a772fb49 (diff) | |
download | python-setuptools-git-3910bbb8d57a8f811ce863e9e1d09ae631cfe353.tar.gz |
Extract methods to separate _safe_data_files behavior and _add_data_files.
Diffstat (limited to 'setuptools/command/sdist.py')
-rw-r--r-- | setuptools/command/sdist.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 55ecdd97..eebdfd19 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -126,14 +126,27 @@ class sdist(sdist_add_defaults, orig.sdist): if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) - # This functionality is incompatible with include_package_data, and - # will in fact create an infinite recursion if include_package_data - # is True. Use of include_package_data will imply that - # distutils-style automatic handling of package_data is disabled - if not self.distribution.include_package_data: - for _, src_dir, _, filenames in build_py.data_files: - self.filelist.extend([os.path.join(src_dir, filename) - for filename in filenames]) + self._add_data_files(self._safe_data_files(build_py)) + + def _safe_data_files(self, build_py): + """ + Extracting data_files from build_py is known to cause + infinite recursion errors when `include_package_data` + is enabled, so suppress it in that case. + """ + if self.distribution.include_package_data: + return () + return build_py.data_files + + def _add_data_files(self, data_files): + """ + Add data files as found in build_py.data_files. + """ + self.filelist.extend( + os.path.join(src_dir, name) + for _, src_dir, _, filenames in data_files + for name in filenames + ) def _add_defaults_data_files(self): try: |