From 596d9db7e89ddc6d16142344cc19e1ba7da5b090 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 10:18:43 +0000 Subject: Capture expectation about file: directive in setup.cfg to be in the sdist --- setuptools/tests/test_sdist.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 30631c24..af5f68ea 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -498,6 +498,30 @@ class TestSdistTest: filename = filename.decode('latin-1') filename not in cmd.filelist.files + def test_add_setup_cfg_referenced_files(self, tmpdir): + touch(tmpdir / 'README.rst') + touch(tmpdir / 'USAGE.rst') + + with open(tmpdir / 'setup.cfg', 'w') as f: + f.writelines(""" + [metadata] + long_description = file: README.rst, USAGE.rst + [options] + packages = find: + """) + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + dist.parse_config_files() + + cmd = sdist(dist) + cmd.ensure_finalized() + with quiet(): + cmd.run() + + assert 'README.rst' in cmd.filelist.files + assert 'USAGE.rst' in cmd.filelist.files + def test_pyproject_toml_in_sdist(self, tmpdir): """ Check if pyproject.toml is included in source distribution if present -- cgit v1.2.1 From 4e766834d72623f3b938f1d4148547ea73af1bf5 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 10:19:31 +0000 Subject: Add files referenced by file: directive in setup.cfg to sdist --- setuptools/command/egg_info.py | 7 +++++++ setuptools/config/setupcfg.py | 15 +++++++++++---- setuptools/dist.py | 7 ++++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1885efb0..194230a9 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -565,6 +565,7 @@ class manifest_maker(sdist): if os.path.exists(self.template): self.read_template() self.add_license_files() + self._add_referenced_files() self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() @@ -622,6 +623,12 @@ class manifest_maker(sdist): pass self.filelist.extend(license_files) + def _add_referenced_files(self): + """Add files referenced by the config (e.g. `file:` directive) to filelist""" + referenced = getattr(self.distribution, '_referenced_files', []) + # ^-- fallback if dist comes from distutils or is a custom class + self.filelist.extend(referenced) + def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py index c2a974de..3df3b6e7 100644 --- a/setuptools/config/setupcfg.py +++ b/setuptools/config/setupcfg.py @@ -12,7 +12,7 @@ from collections import defaultdict from functools import partial from functools import wraps from typing import (TYPE_CHECKING, Callable, Any, Dict, Generic, Iterable, List, - Optional, Tuple, TypeVar, Union) + Optional, Set, Tuple, TypeVar, Union) from distutils.errors import DistutilsOptionError, DistutilsFileError from setuptools.extern.packaging.requirements import Requirement, InvalidRequirement @@ -172,6 +172,9 @@ def parse_configuration( distribution.src_root, ) meta.parse() + distribution._referenced_files.update( + options._referenced_files, meta._referenced_files + ) return meta, options @@ -247,6 +250,10 @@ class ConfigHandler(Generic[Target]): self.sections = sections self.set_options: List[str] = [] self.ensure_discovered = ensure_discovered + self._referenced_files: Set[str] = set() + """After parsing configurations, this property will enumerate + all files referenced by the "file:" directive. Private API for setuptools only. + """ @property def parsers(self): @@ -365,8 +372,7 @@ class ConfigHandler(Generic[Target]): return parser - @classmethod - def _parse_file(cls, value, root_dir: _Path): + def _parse_file(self, value, root_dir: _Path): """Represents value as a string, allowing including text from nearest files using `file:` directive. @@ -388,7 +394,8 @@ class ConfigHandler(Generic[Target]): return value spec = value[len(include_directive) :] - filepaths = (path.strip() for path in spec.split(',')) + filepaths = [path.strip() for path in spec.split(',')] + self._referenced_files.update(filepaths) return expand.read_files(filepaths, root_dir) def _parse_attr(self, value, package_dir, root_dir: _Path): diff --git a/setuptools/dist.py b/setuptools/dist.py index 1c71e5ee..cd34d74a 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -17,7 +17,7 @@ from distutils.fancy_getopt import translate_longopt from glob import iglob import itertools import textwrap -from typing import List, Optional, TYPE_CHECKING +from typing import List, Optional, Set, TYPE_CHECKING from pathlib import Path from collections import defaultdict @@ -481,6 +481,11 @@ class Distribution(_Distribution): }, ) + # Private API (setuptools-use only, not restricted to Distribution) + # Stores files that are referenced by the configuration and need to be in the + # sdist (e.g. `version = file: VERSION.txt`) + self._referenced_files: Set[str] = set() + # Save the original dependencies before they are processed into the egg format self._orig_extras_require = {} self._orig_install_requires = [] -- cgit v1.2.1 From 7954b85cc75d522f3436a3c24c6d7348a5cbfc0b Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 11:03:29 +0000 Subject: Capture expectation about file directive in pyproject.toml to be in the sdist --- setuptools/tests/test_sdist.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index af5f68ea..b04ae7ab 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -498,7 +498,7 @@ class TestSdistTest: filename = filename.decode('latin-1') filename not in cmd.filelist.files - def test_add_setup_cfg_referenced_files(self, tmpdir): + def test_add_files_referenced_by_setupcfg(self, tmpdir): touch(tmpdir / 'README.rst') touch(tmpdir / 'USAGE.rst') @@ -522,6 +522,32 @@ class TestSdistTest: assert 'README.rst' in cmd.filelist.files assert 'USAGE.rst' in cmd.filelist.files + def test_add_files_referenced_by_pyproject_toml(self, tmpdir): + touch(tmpdir / 'README.rst') + touch(tmpdir / 'USAGE.rst') + + with open(tmpdir / 'pyproject.toml', 'w') as f: + f.writelines(""" + [project] + name = 'testing' + version = '0.0.1' + dynamic = ['readme'] + [tool.setuptools.dynamic] + readme = {file = ["README.rst", "USAGE.rst"]} + """) + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + dist.parse_config_files() + + cmd = sdist(dist) + cmd.ensure_finalized() + with quiet(): + cmd.run() + + assert 'README.rst' in cmd.filelist.files + assert 'USAGE.rst' in cmd.filelist.files + def test_pyproject_toml_in_sdist(self, tmpdir): """ Check if pyproject.toml is included in source distribution if present -- cgit v1.2.1 From 36537a9b53bffe5b170bce2b4ebf53c369b49937 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 11:18:42 +0000 Subject: Add files referenced by 'file=' directive in pyproject.toml to sdist --- setuptools/config/pyprojecttoml.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index fee6fac6..cedf5675 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -8,7 +8,7 @@ import os import warnings from contextlib import contextmanager from functools import partial -from typing import TYPE_CHECKING, Callable, Dict, Optional, Mapping, Union +from typing import TYPE_CHECKING, Callable, Dict, Optional, Mapping, Set, Union from setuptools.errors import FileError, OptionError @@ -84,8 +84,8 @@ def read_configuration( :param Distribution|None: Distribution object to which the configuration refers. If not given a dummy object will be created and discarded after the - configuration is read. This is used for auto-discovery of packages in the case - a dynamic configuration (e.g. ``attr`` or ``cmdclass``) is expanded. + configuration is read. This is used for auto-discovery of packages and in the + case a dynamic configuration (e.g. ``attr`` or ``cmdclass``) is expanded. When ``expand=False`` this object is simply ignored. :rtype: dict @@ -211,6 +211,7 @@ class _ConfigExpander: self.dynamic_cfg = self.setuptools_cfg.get("dynamic", {}) self.ignore_option_errors = ignore_option_errors self._dist = dist + self._referenced_files: Set[str] = set() def _ensure_dist(self) -> "Distribution": from setuptools.dist import Distribution @@ -241,6 +242,7 @@ class _ConfigExpander: self._expand_cmdclass(package_dir) self._expand_all_dynamic(dist, package_dir) + dist._referenced_files.update(self._referenced_files) return self.config def _expand_packages(self): @@ -310,6 +312,7 @@ class _ConfigExpander: with _ignore_errors(self.ignore_option_errors): root_dir = self.root_dir if "file" in directive: + self._referenced_files.update(directive["file"]) return _expand.read_files(directive["file"], root_dir) if "attr" in directive: return _expand.read_attr(directive["attr"], package_dir, root_dir) -- cgit v1.2.1 From ac0a9e76438cae66b13afcc0066b46ca0458b116 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 11:29:24 +0000 Subject: Expand test to account for pyproject's readme --- setuptools/tests/test_sdist.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index b04ae7ab..385e249e 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -522,19 +522,20 @@ class TestSdistTest: assert 'README.rst' in cmd.filelist.files assert 'USAGE.rst' in cmd.filelist.files - def test_add_files_referenced_by_pyproject_toml(self, tmpdir): - touch(tmpdir / 'README.rst') - touch(tmpdir / 'USAGE.rst') - - with open(tmpdir / 'pyproject.toml', 'w') as f: - f.writelines(""" - [project] - name = 'testing' - version = '0.0.1' - dynamic = ['readme'] - [tool.setuptools.dynamic] - readme = {file = ["README.rst", "USAGE.rst"]} - """) + def test_add_files_referenced_by_pyproject_toml(self, tmp_path): + (tmp_path / 'VERSION.txt').write_text("0.0.1", encoding="utf-8") + (tmp_path / 'USAGE.rst').write_text("hello world!", encoding="utf-8") + (tmp_path / 'pyproject.toml').write_text( + """ + [project] + name = 'testing' + readme = "USAGE.rst" + dynamic = ['version'] + [tool.setuptools.dynamic] + version = {file = ["VERSION.txt"]} + """, + encoding="utf-8" + ) dist = Distribution(SETUP_ATTRS) dist.script_name = 'setup.py' @@ -545,7 +546,7 @@ class TestSdistTest: with quiet(): cmd.run() - assert 'README.rst' in cmd.filelist.files + assert 'VERSION.txt' in cmd.filelist.files assert 'USAGE.rst' in cmd.filelist.files def test_pyproject_toml_in_sdist(self, tmpdir): -- cgit v1.2.1 From 902385f5fc5774a71914c52e8edab782c354b71d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 12:01:43 +0000 Subject: Refactor tests for file directive --- setuptools/tests/test_sdist.py | 57 ++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 385e249e..076c178b 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -498,46 +498,33 @@ class TestSdistTest: filename = filename.decode('latin-1') filename not in cmd.filelist.files - def test_add_files_referenced_by_setupcfg(self, tmpdir): - touch(tmpdir / 'README.rst') - touch(tmpdir / 'USAGE.rst') - - with open(tmpdir / 'setup.cfg', 'w') as f: - f.writelines(""" - [metadata] - long_description = file: README.rst, USAGE.rst - [options] - packages = find: - """) - - dist = Distribution(SETUP_ATTRS) - dist.script_name = 'setup.py' - dist.parse_config_files() - - cmd = sdist(dist) - cmd.ensure_finalized() - with quiet(): - cmd.run() - - assert 'README.rst' in cmd.filelist.files - assert 'USAGE.rst' in cmd.filelist.files - - def test_add_files_referenced_by_pyproject_toml(self, tmp_path): - (tmp_path / 'VERSION.txt').write_text("0.0.1", encoding="utf-8") - (tmp_path / 'USAGE.rst').write_text("hello world!", encoding="utf-8") - (tmp_path / 'pyproject.toml').write_text( - """ + _EXAMPLE_DIRECTIVES = { + "setup.cfg - long_description and version": """ + [metadata] + version = file: VERSION.txt + long_description = file: README.rst, USAGE.rst + """, + "pyproject.toml - static readme file and dynamic version": """ [project] - name = 'testing' + name = "testing" readme = "USAGE.rst" - dynamic = ['version'] + dynamic = ["version"] [tool.setuptools.dynamic] version = {file = ["VERSION.txt"]} - """, - encoding="utf-8" - ) + """ + } + + @pytest.mark.parametrize("config", _EXAMPLE_DIRECTIVES.keys()) + def test_add_files_referenced_by_config_directives(self, tmp_path, config): + config_file, _, _ = config.partition(" - ") + config_text = self._EXAMPLE_DIRECTIVES[config] + (tmp_path / 'VERSION.txt').write_text("0.42", encoding="utf-8") + (tmp_path / 'README.rst').write_text("hello world!", encoding="utf-8") + (tmp_path / 'USAGE.rst').write_text("hello world!", encoding="utf-8") + (tmp_path / config_file).write_text(config_text, encoding="utf-8") - dist = Distribution(SETUP_ATTRS) + attrs = {k: v for k, v in SETUP_ATTRS.items() if k != "version"} + dist = Distribution(attrs) dist.script_name = 'setup.py' dist.parse_config_files() -- cgit v1.2.1 From 7285f004a410343a24903b4a73a7a57164bcba50 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 12:02:42 +0000 Subject: Ensure file referenced by 'readme' in pyproject.toml is added to sdist --- setuptools/config/_apply_pyprojecttoml.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 8af55616..22388e4f 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -16,7 +16,7 @@ from functools import partial, reduce from itertools import chain from types import MappingProxyType from typing import (TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple, - Type, Union) + Type, Union, cast) from setuptools._deprecation_warning import SetuptoolsDeprecationWarning @@ -142,16 +142,22 @@ def _long_description(dist: "Distribution", val: _DictOrStr, root_dir: _Path): from setuptools.config import expand if isinstance(val, str): - text = expand.read_files(val, root_dir) + file: Union[str, list] = val + text = expand.read_files(file, root_dir) ctype = _guess_content_type(val) else: - text = val.get("text") or expand.read_files(val.get("file", []), root_dir) + file = val.get("file") or [] + text = val.get("text") or expand.read_files(file, root_dir) ctype = val["content-type"] _set_config(dist, "long_description", text) + if ctype: _set_config(dist, "long_description_content_type", ctype) + if file: + dist._referenced_files.add(cast(str, file)) + def _license(dist: "Distribution", val: dict, root_dir: _Path): from setuptools.config import expand -- cgit v1.2.1 From bad92728cfa4f608bc4c47d9a64ffa9cc225e93d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 12:20:18 +0000 Subject: Capture expectations about 'project.license.file' in pyproject.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … to be automatically added to the sdist --- setuptools/tests/test_sdist.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 076c178b..11de75c7 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -501,13 +501,16 @@ class TestSdistTest: _EXAMPLE_DIRECTIVES = { "setup.cfg - long_description and version": """ [metadata] + name = testing version = file: VERSION.txt + license_files = DOWHATYOUWANT long_description = file: README.rst, USAGE.rst """, - "pyproject.toml - static readme file and dynamic version": """ + "pyproject.toml - static readme/license files and dynamic version": """ [project] name = "testing" readme = "USAGE.rst" + license = {file = "DOWHATYOUWANT"} dynamic = ["version"] [tool.setuptools.dynamic] version = {file = ["VERSION.txt"]} @@ -521,10 +524,10 @@ class TestSdistTest: (tmp_path / 'VERSION.txt').write_text("0.42", encoding="utf-8") (tmp_path / 'README.rst').write_text("hello world!", encoding="utf-8") (tmp_path / 'USAGE.rst').write_text("hello world!", encoding="utf-8") + (tmp_path / 'DOWHATYOUWANT').write_text("hello world!", encoding="utf-8") (tmp_path / config_file).write_text(config_text, encoding="utf-8") - attrs = {k: v for k, v in SETUP_ATTRS.items() if k != "version"} - dist = Distribution(attrs) + dist = Distribution({"packages": []}) dist.script_name = 'setup.py' dist.parse_config_files() @@ -535,6 +538,7 @@ class TestSdistTest: assert 'VERSION.txt' in cmd.filelist.files assert 'USAGE.rst' in cmd.filelist.files + assert 'DOWHATYOUWANT' in cmd.filelist.files def test_pyproject_toml_in_sdist(self, tmpdir): """ -- cgit v1.2.1 From 9b8f44fd786efc9d20280aea2234693640016404 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 12:21:01 +0000 Subject: Ensure file referenced by 'license.file' in pyproject.toml is added to sdist --- setuptools/config/_apply_pyprojecttoml.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 22388e4f..c805e639 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -164,6 +164,7 @@ def _license(dist: "Distribution", val: dict, root_dir: _Path): if "file" in val: _set_config(dist, "license", expand.read_files([val["file"]], root_dir)) + dist._referenced_files.add(val["file"]) else: _set_config(dist, "license", val["text"]) -- cgit v1.2.1 From bf9b14ce9fb02834e324fd12ebec3d0574d6222d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sinclert=20P=C3=A9rez?= Date: Thu, 12 Jan 2023 19:25:50 +0100 Subject: Update setuptools sdist docs warning --- docs/userguide/declarative_config.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/userguide/declarative_config.rst b/docs/userguide/declarative_config.rst index 6303e66f..c882d379 100644 --- a/docs/userguide/declarative_config.rst +++ b/docs/userguide/declarative_config.rst @@ -170,9 +170,9 @@ Special directives: project directory (i.e. the directory containing ``setup.cfg``/``pyproject.toml``). .. attention:: - When using the ``file:`` directive, please make sure that all necessary - files are included in the ``sdist``. You can do that via ``MANIFEST.in`` - or using plugins such as ``setuptools-scm``. + For versions prior to : When using the ``file:`` directive, + please make sure that all necessary files are included in the ``sdist``. + You can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``. Please have a look on :doc:`/userguide/miscellaneous` for more information. -- cgit v1.2.1 From b51282078fb09a7ce92ba65dfe8bd94dc465a26f Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 19:07:42 +0000 Subject: Adapt note about file directive and MANIFEST.in --- docs/userguide/declarative_config.rst | 15 ++++++++++----- docs/userguide/pyproject_config.rst | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/docs/userguide/declarative_config.rst b/docs/userguide/declarative_config.rst index c882d379..68dd2715 100644 --- a/docs/userguide/declarative_config.rst +++ b/docs/userguide/declarative_config.rst @@ -169,11 +169,16 @@ Special directives: The ``file:`` directive is sandboxed and won't reach anything outside the project directory (i.e. the directory containing ``setup.cfg``/``pyproject.toml``). - .. attention:: - For versions prior to : When using the ``file:`` directive, - please make sure that all necessary files are included in the ``sdist``. - You can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``. - Please have a look on :doc:`/userguide/miscellaneous` for more information. + .. note:: + If you are using an old version of ``setuptools``, you might need to ensure + that all files referenced by the ``file:`` directive are included in the ``sdist`` + (you can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``, + please have a look on :doc:`/userguide/miscellaneous` for more information). + + .. TODO add versionchanged with specific version when the behavior changed + + Newer versions of ``setuptools`` will automatically add these files to + the ``sdist``. Metadata diff --git a/docs/userguide/pyproject_config.rst b/docs/userguide/pyproject_config.rst index 633f4de7..c60d44df 100644 --- a/docs/userguide/pyproject_config.rst +++ b/docs/userguide/pyproject_config.rst @@ -220,11 +220,16 @@ however please keep in mind that all non-comment lines must conform with :pep:`5 (``pip``-specify syntaxes, e.g. ``-c/-r/-e`` flags, are not supported). -.. attention:: - When using the ``file`` directive, please make sure that all necessary - files are included in the ``sdist``. You can do that via ``MANIFEST.in`` - or using plugins such as ``setuptools-scm``. - Please have a look on :doc:`/userguide/miscellaneous` for more information. +.. note:: + If you are using an old version of ``setuptools``, you might need to ensure + that all files referenced by the ``file`` directive are included in the ``sdist`` + (you can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``, + please have a look on :doc:`/userguide/miscellaneous` for more information). + + .. TODO add versionchanged with specific version when the behavior changed + + Newer versions of ``setuptools`` will automatically add these files to + the ``sdist``. ---- -- cgit v1.2.1 From 8e0e508cb507726a814fe2a2f9bdc5f9bed20688 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 19 Jan 2023 19:19:34 +0000 Subject: Add news fragment --- changelog.d/3779.change.rst | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog.d/3779.change.rst diff --git a/changelog.d/3779.change.rst b/changelog.d/3779.change.rst new file mode 100644 index 00000000..f90dbfa4 --- /dev/null +++ b/changelog.d/3779.change.rst @@ -0,0 +1,4 @@ +Files referenced by ``file:`` in ``setup.cfg`` and by ``project.readme.file``, +``project.license.file`` or ``tool.setuptools.dynamic.*.file`` in +``pyproject.toml`` are now automatically included in the generated sdists. + -- cgit v1.2.1 From 9ad7d341aa212de171ce3e734cabf98323980eaf Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 20 Jan 2023 10:11:40 +0000 Subject: Log referenced files when logging --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 194230a9..86e99dd2 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -620,13 +620,14 @@ class manifest_maker(sdist): license_files = self.distribution.metadata.license_files or [] for lf in license_files: log.info("adding license file '%s'", lf) - pass self.filelist.extend(license_files) def _add_referenced_files(self): """Add files referenced by the config (e.g. `file:` directive) to filelist""" referenced = getattr(self.distribution, '_referenced_files', []) # ^-- fallback if dist comes from distutils or is a custom class + for rf in referenced: + log.debug("adding file referenced by config '%s'", rf) self.filelist.extend(referenced) def prune_file_list(self): -- cgit v1.2.1 From 3c6410763cf884bb8056c37a7cc72ce873802cc2 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 20 Jan 2023 10:31:12 +0000 Subject: Remove empty line in news fragment --- changelog.d/3779.change.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/changelog.d/3779.change.rst b/changelog.d/3779.change.rst index f90dbfa4..55c0fbf1 100644 --- a/changelog.d/3779.change.rst +++ b/changelog.d/3779.change.rst @@ -1,4 +1,3 @@ Files referenced by ``file:`` in ``setup.cfg`` and by ``project.readme.file``, ``project.license.file`` or ``tool.setuptools.dynamic.*.file`` in ``pyproject.toml`` are now automatically included in the generated sdists. - -- cgit v1.2.1 From 58fa95e468242d41dd8d53e0d92429e964eaeb59 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 20 Jan 2023 11:06:39 +0000 Subject: Add versionchanged note to docs --- docs/userguide/declarative_config.rst | 6 ++---- docs/userguide/pyproject_config.rst | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/userguide/declarative_config.rst b/docs/userguide/declarative_config.rst index 68dd2715..d5735166 100644 --- a/docs/userguide/declarative_config.rst +++ b/docs/userguide/declarative_config.rst @@ -175,10 +175,8 @@ Special directives: (you can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``, please have a look on :doc:`/userguide/miscellaneous` for more information). - .. TODO add versionchanged with specific version when the behavior changed - - Newer versions of ``setuptools`` will automatically add these files to - the ``sdist``. + .. versionchanged:: 66.1.0 + Newer versions of ``setuptools`` will automatically add these files to the ``sdist``. Metadata diff --git a/docs/userguide/pyproject_config.rst b/docs/userguide/pyproject_config.rst index c60d44df..c97984ba 100644 --- a/docs/userguide/pyproject_config.rst +++ b/docs/userguide/pyproject_config.rst @@ -226,10 +226,8 @@ however please keep in mind that all non-comment lines must conform with :pep:`5 (you can do that via ``MANIFEST.in`` or using plugins such as ``setuptools-scm``, please have a look on :doc:`/userguide/miscellaneous` for more information). - .. TODO add versionchanged with specific version when the behavior changed - - Newer versions of ``setuptools`` will automatically add these files to - the ``sdist``. + .. versionchanged:: 66.1.0 + Newer versions of ``setuptools`` will automatically add these files to the ``sdist``. ---- -- cgit v1.2.1