From 89173d2f8e88e9fc735806a237215f50df72e962 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 11:33:49 +0100 Subject: [PATCH 1/6] Improve warning message for _IncludePackageDataAbuse --- setuptools/command/build_py.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 91f4741670..f3d43c561f 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -256,6 +256,7 @@ class _IncludePackageDataAbuse: """Inform users that package or module is included as 'data file'""" MESSAGE = """\ + Installing {importable!r} as data is deprecated, please list it as `package`. !!\n\n ############################ # Package would be ignored # @@ -266,7 +267,9 @@ class _IncludePackageDataAbuse: therefore is considered deprecated). Please make sure that {importable!r} is included as a package by using - setuptools' `packages` configuration field or the proper discovery methods. + setuptools' `packages` configuration field or the proper discovery methods + (for example by using `find_namespace_packages(...)`/`find_namespace:` + instead of `find_packages(...)`/`find:`). You can read more about "package discovery" and "data files" on setuptools documentation page. From 97b4f2d959a12387d9a9b57e7c7e3ce2894a5844 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 11:57:24 +0100 Subject: [PATCH 2/6] Improve warning message for _WouldIgnoreField --- setuptools/config/_apply_pyprojecttoml.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py index 4b4ed9dff1..3bf8cc2b23 100644 --- a/setuptools/config/_apply_pyprojecttoml.py +++ b/setuptools/config/_apply_pyprojecttoml.py @@ -341,7 +341,10 @@ def _acessor(obj): class _WouldIgnoreField(UserWarning): - """Inform users that ``pyproject.toml`` would overwrite previously defined metadata: + """Inform users that ``pyproject.toml`` would overwrite previous metadata.""" + + MESSAGE = """\ + {field!r} defined outside of `pyproject.toml` would be ignored. !!\n\n ########################################################################## # configuration would be ignored/result in error due to `pyproject.toml` # @@ -369,5 +372,4 @@ class _WouldIgnoreField(UserWarning): @classmethod def message(cls, field, value): from inspect import cleandoc - msg = "\n".join(cls.__doc__.splitlines()[1:]) - return cleandoc(msg.format(field=field, value=value)) + return cleandoc(cls.MESSAGE.format(field=field, value=value)) From 81c944b60b81c9c2d25a38be050355d891101588 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 11:59:49 +0100 Subject: [PATCH 3/6] Improve warning message for dist_info._version --- setuptools/command/dist_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setuptools/command/dist_info.py b/setuptools/command/dist_info.py index 8b8509f3df..ca540ad119 100644 --- a/setuptools/command/dist_info.py +++ b/setuptools/command/dist_info.py @@ -54,7 +54,8 @@ def _version(version: str) -> str: try: return str(packaging.version.Version(v)).replace("-", "_") except packaging.version.InvalidVersion: - msg = f"""!!\n\n + msg = f"""Invalid version: {version!r}. + !!\n\n ################### # Invalid version # ################### From c255ed8a6b3f5b1f81096a19072619b4ea045380 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 12:03:50 +0100 Subject: [PATCH 4/6] Improve warning message for _InvalidFile --- setuptools/config/pyprojecttoml.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/setuptools/config/pyprojecttoml.py b/setuptools/config/pyprojecttoml.py index be812142e0..976eb0634c 100644 --- a/setuptools/config/pyprojecttoml.py +++ b/setuptools/config/pyprojecttoml.py @@ -418,7 +418,7 @@ class _ExperimentalProjectMetadata(UserWarning): class _InvalidFile(UserWarning): - """Inform users that the given `pyproject.toml` is experimental: + """The given `pyproject.toml` file is invalid and would be ignored. !!\n\n ############################ # Invalid `pyproject.toml` # @@ -436,5 +436,4 @@ class _InvalidFile(UserWarning): @classmethod def message(cls): from inspect import cleandoc - msg = "\n".join(cls.__doc__.splitlines()[1:]) - return cleandoc(msg) + return cleandoc(cls.__doc__) From 531cea627e2410ea19d371679eee720f26f7d0f9 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 12:28:54 +0100 Subject: [PATCH 5/6] Add news fragment --- changelog.d/3328.misc.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/3328.misc.rst diff --git a/changelog.d/3328.misc.rst b/changelog.d/3328.misc.rst new file mode 100644 index 0000000000..8027c57dc2 --- /dev/null +++ b/changelog.d/3328.misc.rst @@ -0,0 +1 @@ +Include a first line summary to some of the existing multi-line warnings. From 3eba1cb02fba0d00ef65a653a3a729e5a524d771 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Wed, 18 May 2022 14:34:41 +0100 Subject: [PATCH 6/6] Update setuptools/command/build_py.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Górny --- setuptools/command/build_py.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index f3d43c561f..d2ccb514df 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -256,7 +256,7 @@ class _IncludePackageDataAbuse: """Inform users that package or module is included as 'data file'""" MESSAGE = """\ - Installing {importable!r} as data is deprecated, please list it as `package`. + Installing {importable!r} as data is deprecated, please list it in `packages`. !!\n\n ############################ # Package would be ignored #