From: DongHun Kwak Date: Mon, 28 Dec 2020 02:27:55 +0000 (+0900) Subject: Imported Upstream version 43.0.0 X-Git-Tag: upstream/43.0.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e47ae3b1e8ddcf89cb4f82cbe6b284c5a6566925;p=platform%2Fupstream%2Fpython3-setuptools.git Imported Upstream version 43.0.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 8a9f443..25093b8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 42.0.2 +current_version = 43.0.0 commit = True tag = True diff --git a/CHANGES.rst b/CHANGES.rst index 81abbe5..817f816 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 ------- diff --git a/pyproject.toml b/pyproject.toml index 07c23bb..f0fd852 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,7 @@ [build-system] -requires = ["wheel"] +requires = ["setuptools >= 40.8", "wheel"] +build-backend = "setuptools.build_meta" +backend-path = ["."] [tool.towncrier] package = "setuptools" diff --git a/setup.cfg b/setup.cfg index 68b49d7..a9a9b50 100644 --- 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 diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 55ecdd9..a851453 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: diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index e1efe56..326b4f5 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -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 diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index d2c4e0c..b27c4a8 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 @@ -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(): """ diff --git a/tools/tox_pip.py b/tools/tox_pip.py index 5aeca80..63518f9 100644 --- a/tools/tox_pip.py +++ b/tools/tox_pip.py @@ -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 == '.':