diff options
| author | Johannes Reiff <mail@jreiff.de> | 2020-01-25 14:17:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-25 14:17:40 +0100 |
| commit | 6ee1a1ce60c6d039c63def3c2aeba7e0f39e7507 (patch) | |
| tree | 254243b04be614ee4ea346ccb7c25fb9deb11f5f /setuptools/command/sdist.py | |
| parent | ec270f9e13fcc32a2a861273219ebfeba17838df (diff) | |
| parent | 73376585065bbf28395c71fe15137c19a712d4f3 (diff) | |
| download | external_python_setuptools-6ee1a1ce60c6d039c63def3c2aeba7e0f39e7507.tar.gz external_python_setuptools-6ee1a1ce60c6d039c63def3c2aeba7e0f39e7507.tar.bz2 external_python_setuptools-6ee1a1ce60c6d039c63def3c2aeba7e0f39e7507.zip | |
Merge branch 'master' into pr-easyinstall
Diffstat (limited to 'setuptools/command/sdist.py')
| -rw-r--r-- | setuptools/command/sdist.py | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 55ecdd97..8c3438ea 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -121,19 +121,40 @@ class sdist(sdist_add_defaults, orig.sdist): if has_leaky_handle: read_template = __read_template_hack + def _add_defaults_optional(self): + if six.PY2: + sdist_add_defaults._add_defaults_optional(self) + else: + super()._add_defaults_optional() + if os.path.isfile('pyproject.toml'): + self.filelist.append('pyproject.toml') + def _add_defaults_python(self): """getting python files""" 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: @@ -186,7 +207,7 @@ class sdist(sdist_add_defaults, orig.sdist): manifest = open(self.manifest, 'rb') for line in manifest: # The manifest must contain UTF-8. See #303. - if six.PY3: + if not six.PY2: try: line = line.decode('UTF-8') except UnicodeDecodeError: |
