diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 25968653ac..4856098dff 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 70.0.0 +current_version = 70.1.0 commit = True tag = True diff --git a/NEWS.rst b/NEWS.rst index 06da16714b..5c3f5b4319 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -1,3 +1,33 @@ +v70.1.0 +======= + +Features +-------- + +- Adopted the ``bdist_wheel`` command from the ``wheel`` project -- by :user:`agronholm` (#1386) +- Improve error message when ``pkg_resources.ZipProvider`` tries to extract resources with a missing Egg -- by :user:`Avasam` + + Added variables and parameter type annotations to ``pkg_resources`` to be nearly on par with typeshed.\* -- by :user:`Avasam` + \* Excluding ``TypeVar`` and ``overload``. Return types are currently inferred. (#4246) +- Migrated Setuptools' own config to pyproject.toml (#4310) + + +Bugfixes +-------- + +- Prevent a ``TypeError: 'NoneType' object is not callable`` when ``shutil_rmtree`` is called without an ``onexc`` parameter on Python<=3.11 -- by :user:`Avasam` (#4382) +- Replace use of mktemp with can_symlink from the stdlib test suite. (#4403) +- Improvement for ``attr:`` directives in configuration to handle + more edge cases related to complex ``package_dir``. (#4405) +- Fix accidental implicit string concatenation. (#4411) + + +Misc +---- + +- #4365, #4422 + + v70.0.0 ======= @@ -109,7 +139,19 @@ v69.3.0 Features -------- -- Support PEP 625 by canonicalizing package name and version in filenames. (#3593) +- Support PEP 625 by canonicalizing package name and version in filenames + per + `the spec `_. + Projects whose names contain uppercase characters, dashes, or periods will + now see their sdist names normalized to match the standard and the format + previously seen in wheels. For example: + + - ``zope.interface`` -> ``zope_interface`` + - ``CherryPy`` -> ``cherrypy`` + - ``foo-bar_baz`` -> ``foo_bar_baz`` + + Projects are encouraged to adopt this change to align with standards and + other backend build systems. (#3593) v69.2.0 diff --git a/newsfragments/1386.feature.rst b/newsfragments/1386.feature.rst deleted file mode 100644 index c8d50bc22e..0000000000 --- a/newsfragments/1386.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Adopted the ``bdist_wheel`` command from the ``wheel`` project -- by :user:`agronholm` diff --git a/newsfragments/4246.feature.rst b/newsfragments/4246.feature.rst deleted file mode 100644 index d5dd2ead98..0000000000 --- a/newsfragments/4246.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -Improve error message when ``pkg_resources.ZipProvider`` tries to extract resources with a missing Egg -- by :user:`Avasam` - -Added variables and parameter type annotations to ``pkg_resources`` to be nearly on par with typeshed.\* -- by :user:`Avasam` -\* Excluding ``TypeVar`` and ``overload``. Return types are currently inferred. diff --git a/newsfragments/4310.feature.rst b/newsfragments/4310.feature.rst deleted file mode 100644 index 2379f3f342..0000000000 --- a/newsfragments/4310.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Migrated Setuptools' own config to pyproject.toml \ No newline at end of file diff --git a/newsfragments/4365.misc.rst b/newsfragments/4365.misc.rst deleted file mode 100644 index 7badfff8f0..0000000000 --- a/newsfragments/4365.misc.rst +++ /dev/null @@ -1 +0,0 @@ -Use actual boolean parameters and variables instead of 0-1 literals. -- by :user:`Avasam` diff --git a/newsfragments/4382.bugfix.rst b/newsfragments/4382.bugfix.rst deleted file mode 100644 index 3aa9e18573..0000000000 --- a/newsfragments/4382.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Prevent a ``TypeError: 'NoneType' object is not callable`` when ``shutil_rmtree`` is called without an ``onexc`` parameter on Python<=3.11 -- by :user:`Avasam` diff --git a/newsfragments/4403.bugfix.rst b/newsfragments/4403.bugfix.rst deleted file mode 100644 index c07cd48c7e..0000000000 --- a/newsfragments/4403.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Replace use of mktemp with can_symlink from the stdlib test suite. \ No newline at end of file diff --git a/newsfragments/4405.bugfix.rst b/newsfragments/4405.bugfix.rst deleted file mode 100644 index 164ace4934..0000000000 --- a/newsfragments/4405.bugfix.rst +++ /dev/null @@ -1,2 +0,0 @@ -Improvement for ``attr:`` directives in configuration to handle -more edge cases related to complex ``package_dir``. diff --git a/newsfragments/4411.bugfix.rst b/newsfragments/4411.bugfix.rst deleted file mode 100644 index e306f3ef0a..0000000000 --- a/newsfragments/4411.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix accidental implicit string concatenation. diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 89a416dc2c..7978561e05 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -3571,6 +3571,38 @@ class PkgResourcesDeprecationWarning(Warning): """ +# Ported from ``setuptools`` to avoid introducing an import inter-dependency: +_LOCALE_ENCODING = "locale" if sys.version_info >= (3, 10) else None + + +def _read_utf8_with_fallback(file: str, fallback_encoding=_LOCALE_ENCODING) -> str: + """See setuptools.unicode_utils._read_utf8_with_fallback""" + try: + with open(file, "r", encoding="utf-8") as f: + return f.read() + except UnicodeDecodeError: # pragma: no cover + msg = f"""\ + ******************************************************************************** + `encoding="utf-8"` fails with {file!r}, trying `encoding={fallback_encoding!r}`. + + This fallback behaviour is considered **deprecated** and future versions of + `setuptools/pkg_resources` may not implement it. + + Please encode {file!r} with "utf-8" to ensure future builds will succeed. + + If this file was produced by `setuptools` itself, cleaning up the cached files + and re-building/re-installing the package with a newer version of `setuptools` + (e.g. by updating `build-system.requires` in its `pyproject.toml`) + might solve the problem. + ******************************************************************************** + """ + # TODO: Add a deadline? + # See comment in setuptools.unicode_utils._Utf8EncodingNeeded + warnings.warn(msg, PkgResourcesDeprecationWarning, stacklevel=2) + with open(file, "r", encoding=fallback_encoding) as f: + return f.read() + + # from jaraco.functools 1.3 def _call_aside(f, *args, **kwargs): f(*args, **kwargs) @@ -3643,35 +3675,3 @@ def _initialize_master_working_set(): add_activation_listener = working_set.subscribe run_script = working_set.run_script run_main = run_script - - -# ---- Ported from ``setuptools`` to avoid introducing an import inter-dependency ---- -LOCALE_ENCODING = "locale" if sys.version_info >= (3, 10) else None - - -def _read_utf8_with_fallback(file: str, fallback_encoding=LOCALE_ENCODING) -> str: - """See setuptools.unicode_utils._read_utf8_with_fallback""" - try: - with open(file, "r", encoding="utf-8") as f: - return f.read() - except UnicodeDecodeError: # pragma: no cover - msg = f"""\ - ******************************************************************************** - `encoding="utf-8"` fails with {file!r}, trying `encoding={fallback_encoding!r}`. - - This fallback behaviour is considered **deprecated** and future versions of - `setuptools/pkg_resources` may not implement it. - - Please encode {file!r} with "utf-8" to ensure future builds will succeed. - - If this file was produced by `setuptools` itself, cleaning up the cached files - and re-building/re-installing the package with a newer version of `setuptools` - (e.g. by updating `build-system.requires` in its `pyproject.toml`) - might solve the problem. - ******************************************************************************** - """ - # TODO: Add a deadline? - # See comment in setuptools.unicode_utils._Utf8EncodingNeeded - warnings.warn(msg, PkgResourcesDeprecationWarning, stacklevel=2) - with open(file, "r", encoding=fallback_encoding) as f: - return f.read() diff --git a/pkg_resources/tests/test_integration_zope_interface.py b/pkg_resources/tests/test_integration_zope_interface.py new file mode 100644 index 0000000000..4e37c3401b --- /dev/null +++ b/pkg_resources/tests/test_integration_zope_interface.py @@ -0,0 +1,54 @@ +import platform +from inspect import cleandoc + +import jaraco.path +import pytest + +pytestmark = pytest.mark.integration + + +# For the sake of simplicity this test uses fixtures defined in +# `setuptools.test.fixtures`, +# and it also exercise conditions considered deprecated... +# So if needed this test can be deleted. +@pytest.mark.skipif( + platform.system() != "Linux", + reason="only demonstrated to fail on Linux in #4399", +) +def test_interop_pkg_resources_iter_entry_points(tmp_path, venv): + """ + Importing pkg_resources.iter_entry_points on console_scripts + seems to cause trouble with zope-interface, when deprecates installation method + is used. See #4399. + """ + project = { + "pkg": { + "foo.py": cleandoc( + """ + from pkg_resources import iter_entry_points + + def bar(): + print("Print me if you can") + """ + ), + "setup.py": cleandoc( + """ + from setuptools import setup, find_packages + + setup( + install_requires=["zope-interface==6.4.post2"], + entry_points={ + "console_scripts": [ + "foo=foo:bar", + ], + }, + ) + """ + ), + } + } + jaraco.path.build(project, prefix=tmp_path) + cmd = ["pip", "install", "-e", ".", "--no-use-pep517"] + venv.run(cmd, cwd=tmp_path / "pkg") # Needs this version of pkg_resources installed + out = venv.run(["foo"]) + assert "Print me if you can" in out diff --git a/pyproject.toml b/pyproject.toml index a7d1f3e99c..712b4ee31f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ backend-path = ["."] [project] name = "setuptools" -version = "70.0.0" +version = "70.1.0" authors = [ { name = "Python Packaging Authority", email = "distutils-sig@python.org" }, ] @@ -160,15 +160,14 @@ PKG-INFO = "setuptools.command.egg_info:write_pkg_info" include-package-data = false [tool.setuptools.packages.find] +include = [ + "setuptools*", + "pkg_resources*", + "_distutils_hack*", +] exclude = [ "*.tests", "*.tests.*", - "tools*", - "debian*", - "launcher*", - "newsfragments*", - "docs", - "docs.*", ] namespaces = true diff --git a/setuptools/command/bdist_wheel.py b/setuptools/command/bdist_wheel.py index ad34539eb8..a81187598a 100644 --- a/setuptools/command/bdist_wheel.py +++ b/setuptools/command/bdist_wheel.py @@ -284,9 +284,7 @@ def finalize_options(self): wheel = self.distribution.get_option_dict("wheel") if "universal" in wheel: # please don't define this in your global configs - log.warning( - "The [wheel] section is deprecated. Use [bdist_wheel] instead.", - ) + log.warn("The [wheel] section is deprecated. Use [bdist_wheel] instead.") val = wheel["universal"][1].strip() if val.lower() in ("1", "true", "yes"): self.universal = True