Imported Upstream version 43.0.0 upstream/43.0.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 28 Dec 2020 02:27:55 +0000 (11:27 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 28 Dec 2020 02:27:55 +0000 (11:27 +0900)
.bumpversion.cfg
CHANGES.rst
pyproject.toml
setup.cfg
setuptools/command/sdist.py
setuptools/tests/test_build_meta.py
setuptools/tests/test_sdist.py
tools/tox_pip.py

index 8a9f443..25093b8 100644 (file)
@@ -1,5 +1,5 @@
 [bumpversion]
-current_version = 42.0.2
+current_version = 43.0.0
 commit = True
 tag = True
 
index 81abbe5..817f816 100644 (file)
@@ -1,3 +1,10 @@
+v43.0.0
+-------
+
+* #1634: Include ``pyproject.toml`` in source distribution by default. Projects relying on the previous behavior where ``pyproject.toml`` was excluded by default should stop relying on that behavior or add ``exclude pyproject.toml`` to their MANIFEST.in file.
+* #1927: Setuptools once again declares 'setuptools' in the ``build-system.requires`` and adds PEP 517 build support by declaring itself as the ``build-backend``. It additionally specifies ``build-system.backend-path`` to rely on itself for those builders that support it.
+
+
 v42.0.2
 -------
 
index 07c23bb..f0fd852 100644 (file)
@@ -1,5 +1,7 @@
 [build-system]
-requires = ["wheel"]
+requires = ["setuptools >= 40.8", "wheel"]
+build-backend = "setuptools.build_meta"
+backend-path = ["."]
 
 [tool.towncrier]
     package = "setuptools"
index 68b49d7..a9a9b50 100644 (file)
--- a/setup.cfg
+++ b/setup.cfg
@@ -19,7 +19,7 @@ universal = 1
 
 [metadata]
 name = setuptools
-version = 42.0.2
+version = 43.0.0
 description = Easily download, build, install, upgrade, and uninstall Python packages
 author = Python Packaging Authority
 author_email = distutils-sig@python.org
index 55ecdd9..a851453 100644 (file)
@@ -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:
index e1efe56..326b4f5 100644 (file)
@@ -262,6 +262,27 @@ class TestBuildMetaBackend:
         assert os.path.isfile(
             os.path.join(os.path.abspath("out_sdist"), sdist_name))
 
+    def test_build_sdist_pyproject_toml_exists(self, tmpdir_cwd):
+        files = {
+            'setup.py': DALS("""
+                __import__('setuptools').setup(
+                    name='foo',
+                    version='0.0.0',
+                    py_modules=['hello']
+                )"""),
+            'hello.py': '',
+            'pyproject.toml': DALS("""
+                [build-system]
+                requires = ["setuptools", "wheel"]
+                build-backend = "setuptools.build_meta
+                """),
+        }
+        build_files(files)
+        build_backend = self.get_build_backend()
+        targz_path = build_backend.build_sdist("temp")
+        with tarfile.open(os.path.join("temp", targz_path)) as tar:
+            assert any('pyproject.toml' in name for name in tar.getnames())
+
     def test_build_sdist_setup_py_exists(self, tmpdir_cwd):
         # If build_sdist is called from a script other than setup.py,
         # ensure setup.py is included
index d2c4e0c..b27c4a8 100644 (file)
@@ -1,6 +1,8 @@
 # -*- coding: utf-8 -*-
 """sdist tests"""
 
+from __future__ import print_function
+
 import os
 import shutil
 import sys
@@ -449,6 +451,36 @@ class TestSdistTest:
             except UnicodeDecodeError:
                 filename not in cmd.filelist.files
 
+    def test_pyproject_toml_in_sdist(self):
+        """
+        Check if pyproject.toml is included in source distribution if present
+        """
+        open(os.path.join(self.temp_dir, 'pyproject.toml'), 'w').close()
+        dist = Distribution(SETUP_ATTRS)
+        dist.script_name = 'setup.py'
+        cmd = sdist(dist)
+        cmd.ensure_finalized()
+        with quiet():
+            cmd.run()
+        manifest = cmd.filelist.files
+        assert 'pyproject.toml' in manifest
+
+    def test_pyproject_toml_excluded(self):
+        """
+        Check that pyproject.toml can excluded even if present
+        """
+        open(os.path.join(self.temp_dir, 'pyproject.toml'), 'w').close()
+        with open('MANIFEST.in', 'w') as mts:
+            print('exclude pyproject.toml', file=mts)
+        dist = Distribution(SETUP_ATTRS)
+        dist.script_name = 'setup.py'
+        cmd = sdist(dist)
+        cmd.ensure_finalized()
+        with quiet():
+            cmd.run()
+        manifest = cmd.filelist.files
+        assert 'pyproject.toml' not in manifest
+
 
 def test_default_revctrl():
     """
index 5aeca80..63518f9 100644 (file)
@@ -21,12 +21,6 @@ def pip(args):
     pypath = pypath.split(os.pathsep) if pypath is not None else []
     pypath.insert(0, TOX_PIP_DIR)
     os.environ['PYTHONPATH'] = os.pathsep.join(pypath)
-    # Disable PEP 517 support when using editable installs.
-    for n, a in enumerate(args):
-        if not a.startswith('-'):
-            if a in 'install' and '-e' in args[n:]:
-                args.insert(n + 1, '--no-use-pep517')
-            break
     # Fix call for setuptools editable install.
     for n, a in enumerate(args):
         if a == '.':