From 0c79e4d09cf429a2aabbcb6d4cf1455ec45a0137 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 11 Jan 2019 15:29:40 +0300 Subject: [PATCH 1/8] include pyproject.toml in sdist (#1632) --- setuptools/command/py36compat.py | 2 +- setuptools/tests/test_sdist.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index 61063e7542..c256bfb855 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -76,7 +76,7 @@ def _add_defaults_standards(self): self.warn("standard file '%s' not found" % fn) def _add_defaults_optional(self): - optional = ['test/test*.py', 'setup.cfg'] + optional = ['test/test*.py', 'setup.cfg', 'pyproject.toml'] for pattern in optional: files = filter(os.path.isfile, glob(pattern)) self.filelist.extend(files) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index d2c4e0cf95..06813a003b 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -449,6 +449,20 @@ def test_sdist_with_latin1_encoded_filename(self): 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_default_revctrl(): """ From bc976ed7b9a2e0594c5822316ae63e64723a7ed6 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 11 Jan 2019 15:33:18 +0300 Subject: [PATCH 2/8] add changelog fragment --- changelog.d/1634.change.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/1634.change.rst diff --git a/changelog.d/1634.change.rst b/changelog.d/1634.change.rst new file mode 100644 index 0000000000..ab544239d6 --- /dev/null +++ b/changelog.d/1634.change.rst @@ -0,0 +1 @@ +Include ``pyproject.toml`` in source distribution by default From 1d6bcf1730a8490a2a16fe2eac73a5437f743dd2 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 11 Jan 2019 15:34:32 +0300 Subject: [PATCH 3/8] add trailing dot in changelog fragment --- changelog.d/1634.change.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.d/1634.change.rst b/changelog.d/1634.change.rst index ab544239d6..27d0a64afe 100644 --- a/changelog.d/1634.change.rst +++ b/changelog.d/1634.change.rst @@ -1 +1 @@ -Include ``pyproject.toml`` in source distribution by default +Include ``pyproject.toml`` in source distribution by default. From d53e024af2f5d8f3a4a36588c3dc004d156bc830 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 11 Jan 2019 15:57:54 +0300 Subject: [PATCH 4/8] do not change py36compat, put changes into sdist command --- setuptools/command/py36compat.py | 2 +- setuptools/command/sdist.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/setuptools/command/py36compat.py b/setuptools/command/py36compat.py index c256bfb855..61063e7542 100644 --- a/setuptools/command/py36compat.py +++ b/setuptools/command/py36compat.py @@ -76,7 +76,7 @@ def _add_defaults_standards(self): self.warn("standard file '%s' not found" % fn) def _add_defaults_optional(self): - optional = ['test/test*.py', 'setup.cfg', 'pyproject.toml'] + optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: files = filter(os.path.isfile, glob(pattern)) self.filelist.extend(files) diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index bcfae4d82f..40965a678c 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -121,6 +121,14 @@ def __read_template_hack(self): 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(): From 8a7a6272942c84a0cf59169b84f7434ea4dc4bfe Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Fri, 27 Dec 2019 16:12:40 +0800 Subject: [PATCH 5/8] Add test ensuring pyproject.toml is included during PEP 517 build. --- setuptools/tests/test_build_meta.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index e1efe5617c..326b4f5dbd 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -262,6 +262,27 @@ def test_build_sdist_version_change(self, build_backend): 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 From 589a70571a890b8113c75916325230b0b832f8c0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 29 Dec 2019 12:57:51 -0500 Subject: [PATCH 6/8] Mark the change as a breaking change. --- changelog.d/1634.breaking.rst | 1 + changelog.d/1634.change.rst | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog.d/1634.breaking.rst delete mode 100644 changelog.d/1634.change.rst diff --git a/changelog.d/1634.breaking.rst b/changelog.d/1634.breaking.rst new file mode 100644 index 0000000000..b65e5d9f40 --- /dev/null +++ b/changelog.d/1634.breaking.rst @@ -0,0 +1 @@ +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. diff --git a/changelog.d/1634.change.rst b/changelog.d/1634.change.rst deleted file mode 100644 index 27d0a64afe..0000000000 --- a/changelog.d/1634.change.rst +++ /dev/null @@ -1 +0,0 @@ -Include ``pyproject.toml`` in source distribution by default. From f171cde1505fc5df438417dc5ae48d35fa60a002 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 31 Dec 2019 12:47:46 -0500 Subject: [PATCH 7/8] Add test for exclusion expectation. Ref #1650. --- setuptools/tests/test_sdist.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 06813a003b..a413e4ede2 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -463,6 +463,22 @@ def test_pyproject_toml_in_sdist(self): 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(): """ From 2eb3ba19f3153f83eb8b2470deb8ec02d21fca52 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 31 Dec 2019 12:50:25 -0500 Subject: [PATCH 8/8] Restore Python 2.7 compatibility --- setuptools/tests/test_sdist.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index a413e4ede2..b27c4a8336 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """sdist tests""" +from __future__ import print_function + import os import shutil import sys