Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pypa/setuptools into typesh…
Browse files Browse the repository at this point in the history
…ed-overload-and-typevar
  • Loading branch information
Avasam committed Jun 21, 2024
2 parents 807d7c1 + 2adbd4f commit 82145bc
Show file tree
Hide file tree
Showing 14 changed files with 137 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 70.0.0
current_version = 70.1.0
commit = True
tag = True

Expand Down
44 changes: 43 additions & 1 deletion NEWS.rst
Original file line number Diff line number Diff line change
@@ -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
=======

Expand Down Expand Up @@ -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 <https://packaging.python.org/en/latest/specifications/source-distribution-format/#source-distribution-file-name>`_.
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
Expand Down
1 change: 0 additions & 1 deletion newsfragments/1386.feature.rst

This file was deleted.

4 changes: 0 additions & 4 deletions newsfragments/4246.feature.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/4310.feature.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/4365.misc.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/4382.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/4403.bugfix.rst

This file was deleted.

2 changes: 0 additions & 2 deletions newsfragments/4405.bugfix.rst

This file was deleted.

1 change: 0 additions & 1 deletion newsfragments/4411.bugfix.rst

This file was deleted.

64 changes: 32 additions & 32 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
54 changes: 54 additions & 0 deletions pkg_resources/tests/test_integration_zope_interface.py
Original file line number Diff line number Diff line change
@@ -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
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ backend-path = ["."]

[project]
name = "setuptools"
version = "70.0.0"
version = "70.1.0"
authors = [
{ name = "Python Packaging Authority", email = "[email protected]" },
]
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions setuptools/command/bdist_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82145bc

Please sign in to comment.