Imported Upstream version 58.5.0 upstream/58.5.0
authorJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:37 +0000 (17:02 +0900)
committerJinWang An <jinwang.an@samsung.com>
Mon, 27 Mar 2023 08:02:37 +0000 (17:02 +0900)
.bumpversion.cfg
CHANGES.rst
bootstrap.egg-info/entry_points.txt
setup.cfg
setuptools/command/build_py.py
setuptools/command/egg_info.py
setuptools/command/sdist.py
setuptools/tests/test_sdist.py

index 095e606fcea57a946bea8c4cc2be1328014826a1..1f0b2d3d7d4a72cbc61e0aeadf2b8d8d6b959e77 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 58.4.0
+current_version = 58.5.0
 commit = True
 tag = True
 
index 89e525c454181dc10f3521c31f1e9cd4c356031e..26b8d67594d0d8d89653c8ac8acef5a1d8c7f1e7 100644 (file)
@@ -1,3 +1,14 @@
+v58.5.0
+-------
+
+
+Changes
+^^^^^^^
+* #1461: Fix inconsistency with ``include_package_data`` and ``packages_data`` in sdist
+  by replacing the loop breaking mechanism between the ``sdist`` and
+  ``egg_info`` commands -- by :user:`abravalheri`
+
+
 v58.4.0
 -------
 
@@ -8,9 +19,9 @@ Changes
 
 Documentation changes
 ^^^^^^^^^^^^^^^^^^^^^
-* #2932: Removed the deprecated ``data_files`` option from the example in the
+* #2832: Removed the deprecated ``data_files`` option from the example in the
   declarative configuration docs -- by :user:`abravalheri`
-* #2932: Change type of ``data_files`` option from ``dict`` to ``section`` in
+* #2832: Change type of ``data_files`` option from ``dict`` to ``section`` in
   declarative configuration docs (to match previous example) -- by
   :user:`abravalheri`
 
@@ -21,7 +32,7 @@ v58.3.0
 
 Changes
 ^^^^^^^
-* #917: ``setup.py install`` and ``easy_install`` commands are now officially deprecated. Use other standards-based installers (like pip) and builders (like build). Workloads reliant on this behavior should pin to this major version of Setuptools.
+* #917: ``setup.py install`` and ``easy_install`` commands are now officially deprecated. Use other standards-based installers (like pip) and builders (like build). Workloads reliant on this behavior should pin to this major version of Setuptools. See `Why you shouldn't invoke setup.py directly <https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html>`_ for more background.
 * #1988: Deprecated the ``bdist_rpm`` command. Binary packages should be built as wheels instead.
   -- by :user:`hugovk`
 * #2785: Replace ``configparser``'s ``readfp`` with ``read_file``, deprecated since Python 3.2.
index 834d674e57a2712d4185c6608a9b9953ee64112a..c00d1d3a0241c01d073be1309ee66be0da645e1e 100644 (file)
@@ -1,11 +1,15 @@
 [distutils.commands]
 egg_info = setuptools.command.egg_info:egg_info
+build_py = setuptools.command.build_py:build_py
+sdist = setuptools.command.sdist:sdist
 
 [distutils.setup_keywords]
 include_package_data = setuptools.dist:assert_bool
 install_requires = setuptools.dist:check_requirements
 extras_require = setuptools.dist:check_extras
 entry_points = setuptools.dist:check_entry_points
+exclude_package_data = setuptools.dist:check_package_data
+namespace_packages = setuptools.dist:check_nsp
 
 [egg_info.writers]
 PKG-INFO = setuptools.command.egg_info:write_pkg_info
index 50622ccf69a57eca7962b60900d82fe45733a3cf..6ce5448557bbda89693d637a26f3769067e41741 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
 [metadata]
 name = setuptools
-version = 58.4.0
+version = 58.5.0
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
 description = Easily download, build, install, upgrade, and uninstall Python packages
index 6a61543342ce1dc9f0aa4f6176754a433f15bf74..c3fdc0927c551fa7b15f73355e30ae436f8ccd7a 100644 (file)
@@ -67,6 +67,16 @@ class build_py(orig.build_py):
         self.analyze_manifest()
         return list(map(self._get_pkg_data_files, self.packages or ()))
 
+    def get_data_files_without_manifest(self):
+        """
+        Generate list of ``(package,src_dir,build_dir,filenames)`` tuples,
+        but without triggering any attempt to analyze or build the manifest.
+        """
+        # Prevent eventual errors from unset `manifest_files`
+        # (that would otherwise be set by `analyze_manifest`)
+        self.__dict__.setdefault('manifest_files', {})
+        return list(map(self._get_pkg_data_files, self.packages or ()))
+
     def _get_pkg_data_files(self, package):
         # Locate package source directory
         src_dir = self.get_package_dir(package)
index 18b81340a7f74b2762db3b2db6b1ab1414df01ca..4165c35e9f6553d6f456f0d91fcdb5154bf5778b 100644 (file)
@@ -608,6 +608,18 @@ class manifest_maker(sdist):
         self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep,
                                       is_regex=1)
 
+    def _safe_data_files(self, build_py):
+        """
+        The parent class implementation of this method
+        (``sdist``) will try to include data files, which
+        might cause recursion problems when
+        ``include_package_data=True``.
+
+        Therefore, avoid triggering any attempt of
+        analyzing/building the manifest again.
+        """
+        return build_py.get_data_files_without_manifest()
+
 
 def write_file(filename, contents):
     """Create a file with the specified name and write 'contents' (a
index e8062f2e41830cb70902d9971df670c1f5a550f6..0285b690fc7417198d21cb71f67ce22d48514e8a 100644 (file)
@@ -114,12 +114,15 @@ class sdist(sdist_add_defaults, orig.sdist):
 
     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.
+        Since the ``sdist`` class is also used to compute the MANIFEST
+        (via :obj:`setuptools.command.egg_info.manifest_maker`),
+        there might be recursion problems when trying to obtain the list of
+        data_files and ``include_package_data=True`` (which in turn depends on
+        the files included in the MANIFEST).
+
+        To avoid that, ``manifest_maker`` should be able to overwrite this
+        method and avoid recursive attempts to build/analyze the MANIFEST.
         """
-        if self.distribution.include_package_data:
-            return ()
         return build_py.data_files
 
     def _add_data_files(self, data_files):
index 049fdcc05a38f2a43f03ef51ef88dd1ab6494d71..34c32bb010f7c85b9ec2bfcb708d34140cb702ee 100644 (file)
@@ -126,6 +126,28 @@ class TestSdistTest:
         assert os.path.join('sdist_test', 'c.rst') not in manifest
         assert os.path.join('d', 'e.dat') in manifest
 
+    def test_package_data_and_include_package_data_in_sdist(self):
+        """
+        Ensure package_data and include_package_data work
+        together.
+        """
+        setup_attrs = {**SETUP_ATTRS, 'include_package_data': True}
+        assert setup_attrs['package_data']
+
+        dist = Distribution(setup_attrs)
+        dist.script_name = 'setup.py'
+        cmd = sdist(dist)
+        cmd.ensure_finalized()
+
+        with quiet():
+            cmd.run()
+
+        manifest = cmd.filelist.files
+        assert os.path.join('sdist_test', 'a.txt') in manifest
+        assert os.path.join('sdist_test', 'b.txt') in manifest
+        assert os.path.join('sdist_test', 'c.rst') not in manifest
+        assert os.path.join('d', 'e.dat') in manifest
+
     def test_setup_py_exists(self):
         dist = Distribution(SETUP_ATTRS)
         dist.script_name = 'foo.py'