Skip to content

Commit

Permalink
Merge branch 'Merge-typeshed-return-annotations' of https://github.co…
Browse files Browse the repository at this point in the history
…m/Avasam/setuptools into Merge-typeshed-return-annotations
  • Loading branch information
Avasam committed Nov 19, 2024
2 parents fb5487b + 46fde28 commit 747bb74
Show file tree
Hide file tree
Showing 38 changed files with 1,365 additions and 296 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 = 75.3.0
current_version = 75.5.0
commit = True
tag = True

Expand Down
44 changes: 44 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
v75.5.0
=======

Features
--------

- Removed support for ``SETUPTOOLS_DANGEROUSLY_SKIP_PYPROJECT_VALIDATION``, as it
is deemed prone to errors. (#4746)


v75.4.0
=======

Features
--------

- Added support for the environment variable
``SETUPTOOLS_DANGEROUSLY_SKIP_PYPROJECT_VALIDATION=true``, allowing users to bypass
the validation of ``pyproject.toml``.
This option should be used only as a last resort when resolving dependency
issues, as it may lead to improper functioning.
Users who enable this setting are responsible for ensuring that ``pyproject.toml``
complies with setuptools requirements. (#4611)

.. attention::
This environment variable was removed in a later version of ``setuptools``.

- Require Python 3.9 or later. (#4718)
- Remove dependency on ``importlib_resources``
and the vendored copy of the library.
Instead, ``setuptools`` consistently rely on stdlib's ``importlib.resources``
(available on Python 3.9+). (#4718)
- Setuptools' ``bdist_wheel`` implementation no longer produces wheels with
the ``m`` SOABI flag (pymalloc-related).
This flag was removed on Python 3.8+ (see :obj:`sys.abiflags`). (#4718)
- Updated vendored packaging version to 24.2. (#4740)


Bugfixes
--------

- Merge with pypa/distutils@251797602, including fix for dirutil.mkpath handling in pypa/distutils#304.


v75.3.0
=======

Expand Down
1 change: 0 additions & 1 deletion newsfragments/4718.feature.1.rst

This file was deleted.

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

This file was deleted.

3 changes: 0 additions & 3 deletions newsfragments/4718.feature.3.rst

This file was deleted.

12 changes: 6 additions & 6 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 = "75.3.0"
version = "75.5.0"
authors = [
{ name = "Python Packaging Authority", email = "distutils-sig@python.org" },
]
Expand Down Expand Up @@ -41,7 +41,7 @@ test = [
"virtualenv>=13.0.0",
"wheel>=0.44.0", # Consistent requirement normalisation in METADATA (see #4547)
"pip>=19.1", # For proper file:// URLs support.
"packaging>=23.2",
"packaging>=24.2",
"jaraco.envs>=2.2",
"pytest-xdist>=3", # Dropped dependency on pytest-fork and py
"jaraco.path>=3.2.0",
Expand Down Expand Up @@ -90,7 +90,7 @@ doc = [
ssl = []
certs = []
core = [
"packaging>=24",
"packaging>=24.2",
"more_itertools>=8.8",
"jaraco.text>=3.7",
"importlib_metadata>=6; python_version < '3.10'",
Expand All @@ -102,7 +102,7 @@ core = [

# for distutils
"jaraco.collections",
"jaraco.functools",
"jaraco.functools>=4",
"packaging",
"more_itertools",
]
Expand Down Expand Up @@ -134,8 +134,8 @@ type = [

# pin mypy version so a new version doesn't suddenly cause the CI to fail,
# until types-setuptools is removed from typeshed.
# For help with static-typing issues, or mypy update, ping @Avasam
"mypy==1.12.*",
# For help with static-typing issues, or mypy update, ping @Avasam
"mypy>=1.12,<1.14",
# Typing fixes in version newer than we require at runtime
"importlib_metadata>=7.0.2; python_version < '3.10'",
# Imported unconditionally in tools/finalize.py
Expand Down
11 changes: 3 additions & 8 deletions setuptools/_distutils/dir_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ def wrap(self, func):
def wrapper(path, *args, **kwargs):
if path.absolute() in self:
return
result = func(path, *args, **kwargs)
self.add(path.absolute())
return func(path, *args, **kwargs)
return result

return wrapper

Expand All @@ -44,29 +45,23 @@ def wrapper(path, *args, **kwargs):

@functools.singledispatch
@wrapper
def mkpath(name: pathlib.Path, mode=0o777, verbose=True, dry_run=False):
def mkpath(name: pathlib.Path, mode=0o777, verbose=True, dry_run=False) -> None:
"""Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do nothing.
Raise DistutilsFileError if unable to create some directory along the way
(eg. some sub-path exists, but is a file rather than a directory).
If 'verbose' is true, log the directory created.
Return the list of directories actually created.
"""
if verbose and not name.is_dir():
log.info("creating %s", name)

ancestry = itertools.chain((name,), name.parents)
missing = (path for path in ancestry if not path.is_dir())

try:
dry_run or name.mkdir(mode=mode, parents=True, exist_ok=True)
except OSError as exc:
raise DistutilsFileError(f"could not create '{name}': {exc.args[-1]}")

return list(map(str, missing))


@mkpath.register
def _(name: str, *args, **kwargs):
Expand Down
22 changes: 22 additions & 0 deletions setuptools/_distutils/tests/test_dir_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for distutils.dir_util."""

import os
import pathlib
import stat
import unittest.mock as mock
from distutils import dir_util, errors
Expand Down Expand Up @@ -110,3 +111,24 @@ def test_copy_tree_exception_in_listdir(self):
):
src = self.tempdirs[-1]
dir_util.copy_tree(src, None)

def test_mkpath_exception_uncached(self, monkeypatch, tmp_path):
"""
Caching should not remember failed attempts.
pypa/distutils#304
"""

class FailPath(pathlib.Path):
def mkdir(self, *args, **kwargs):
raise OSError("Failed to create directory")

target = tmp_path / 'foodir'

with pytest.raises(errors.DistutilsFileError):
mkpath(FailPath(target))

assert not target.exists()

mkpath(target)
assert target.exists()
53 changes: 53 additions & 0 deletions setuptools/_shutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""Convenience layer on top of stdlib's shutil and os"""

import os
import stat
from typing import Callable, TypeVar

from .compat import py311

from distutils import log

try:
from os import chmod # pyright: ignore[reportAssignmentType]
# Losing type-safety w/ pyright, but that's ok
except ImportError: # pragma: no cover
# Jython compatibility
def chmod(*args: object, **kwargs: object) -> None: # type: ignore[misc] # Mypy reuses the imported definition anyway
pass


_T = TypeVar("_T")


def attempt_chmod_verbose(path, mode):
log.debug("changing mode of %s to %o", path, mode)
try:
chmod(path, mode)
except OSError as e: # pragma: no cover
log.debug("chmod failed: %s", e)


# Must match shutil._OnExcCallback
def _auto_chmod(
func: Callable[..., _T], arg: str, exc: BaseException
) -> _T: # pragma: no cover
"""shutils onexc callback to automatically call chmod for certain functions."""
# Only retry for scenarios known to have an issue
if func in [os.unlink, os.remove] and os.name == 'nt':
attempt_chmod_verbose(arg, stat.S_IWRITE)
return func(arg)
raise exc


def rmtree(path, ignore_errors=False, onexc=_auto_chmod):
"""
Similar to ``shutil.rmtree`` but automatically executes ``chmod``
for well know Windows failure scenarios.
"""
return py311.shutil_rmtree(path, ignore_errors, onexc)


def rmdir(path, **opts):
if os.path.isdir(path):
rmtree(path, **opts)
1 change: 0 additions & 1 deletion setuptools/_vendor/packaging-24.1.dist-info/INSTALLER

This file was deleted.

37 changes: 0 additions & 37 deletions setuptools/_vendor/packaging-24.1.dist-info/RECORD

This file was deleted.

1 change: 1 addition & 0 deletions setuptools/_vendor/packaging-24.2.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Metadata-Version: 2.3
Name: packaging
Version: 24.1
Version: 24.2
Summary: Core utilities for Python packages
Author-email: Donald Stufft <donald@stufft.io>
Requires-Python: >=3.8
Expand Down
25 changes: 25 additions & 0 deletions setuptools/_vendor/packaging-24.2.dist-info/RECORD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
packaging-24.2.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
packaging-24.2.dist-info/LICENSE,sha256=ytHvW9NA1z4HS6YU0m996spceUDD2MNIUuZcSQlobEg,197
packaging-24.2.dist-info/LICENSE.APACHE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
packaging-24.2.dist-info/LICENSE.BSD,sha256=tw5-m3QvHMb5SLNMFqo5_-zpQZY2S8iP8NIYDwAo-sU,1344
packaging-24.2.dist-info/METADATA,sha256=ohH86s6k5mIfQxY2TS0LcSfADeOFa4BiCC-bxZV-pNs,3204
packaging-24.2.dist-info/RECORD,,
packaging-24.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
packaging-24.2.dist-info/WHEEL,sha256=CpUCUxeHQbRN5UGRQHYRJorO5Af-Qy_fHMctcQ8DSGI,82
packaging/__init__.py,sha256=dk4Ta_vmdVJxYHDcfyhvQNw8V3PgSBomKNXqg-D2JDY,494
packaging/_elffile.py,sha256=cflAQAkE25tzhYmq_aCi72QfbT_tn891tPzfpbeHOwE,3306
packaging/_manylinux.py,sha256=vl5OCoz4kx80H5rwXKeXWjl9WNISGmr4ZgTpTP9lU9c,9612
packaging/_musllinux.py,sha256=p9ZqNYiOItGee8KcZFeHF_YcdhVwGHdK6r-8lgixvGQ,2694
packaging/_parser.py,sha256=s_TvTvDNK0NrM2QB3VKThdWFM4Nc0P6JnkObkl3MjpM,10236
packaging/_structures.py,sha256=q3eVNmbWJGG_S0Dit_S3Ao8qQqz_5PYTXFAKBZe5yr4,1431
packaging/_tokenizer.py,sha256=J6v5H7Jzvb-g81xp_2QACKwO7LxHQA6ikryMU7zXwN8,5273
packaging/licenses/__init__.py,sha256=1x5M1nEYjcgwEbLt0dXwz2ukjr18DiCzC0sraQqJ-Ww,5715
packaging/licenses/_spdx.py,sha256=oAm1ztPFwlsmCKe7lAAsv_OIOfS1cWDu9bNBkeu-2ns,48398
packaging/markers.py,sha256=c89TNzB7ZdGYhkovm6PYmqGyHxXlYVaLW591PHUNKD8,10561
packaging/metadata.py,sha256=YJibM7GYe4re8-0a3OlXmGS-XDgTEoO4tlBt2q25Bng,34762
packaging/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
packaging/requirements.py,sha256=gYyRSAdbrIyKDY66ugIDUQjRMvxkH2ALioTmX3tnL6o,2947
packaging/specifiers.py,sha256=GG1wPNMcL0fMJO68vF53wKMdwnfehDcaI-r9NpTfilA,40074
packaging/tags.py,sha256=CFqrJzAzc2XNGexerH__T-Y5Iwq7WbsYXsiLERLWxY0,21014
packaging/utils.py,sha256=0F3Hh9OFuRgrhTgGZUl5K22Fv1YP2tZl1z_2gO6kJiA,5050
packaging/version.py,sha256=olfyuk_DPbflNkJ4wBWetXQ17c74x3DB501degUv7DY,16676
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Wheel-Version: 1.0
Generator: flit 3.9.0
Generator: flit 3.10.1
Root-Is-Purelib: true
Tag: py3-none-any
4 changes: 2 additions & 2 deletions setuptools/_vendor/packaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
__summary__ = "Core utilities for Python packages"
__uri__ = "https://github.com/pypa/packaging"

__version__ = "24.1"
__version__ = "24.2"

__author__ = "Donald Stufft and individual contributors"
__email__ = "donald@stufft.io"

__license__ = "BSD-2-Clause or Apache-2.0"
__copyright__ = "2014 %s" % __author__
__copyright__ = f"2014 {__author__}"
8 changes: 4 additions & 4 deletions setuptools/_vendor/packaging/_elffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def __init__(self, f: IO[bytes]) -> None:

try:
ident = self._read("16B")
except struct.error:
raise ELFInvalid("unable to parse identification")
except struct.error as e:
raise ELFInvalid("unable to parse identification") from e
magic = bytes(ident[:4])
if magic != b"\x7fELF":
raise ELFInvalid(f"invalid magic: {magic!r}")
Expand All @@ -67,11 +67,11 @@ def __init__(self, f: IO[bytes]) -> None:
(2, 1): ("<HHIQQQIHHH", "<IIQQQQQQ", (0, 2, 5)), # 64-bit LSB.
(2, 2): (">HHIQQQIHHH", ">IIQQQQQQ", (0, 2, 5)), # 64-bit MSB.
}[(self.capacity, self.encoding)]
except KeyError:
except KeyError as e:
raise ELFInvalid(
f"unrecognized capacity ({self.capacity}) or "
f"encoding ({self.encoding})"
)
) from e

try:
(
Expand Down
1 change: 1 addition & 0 deletions setuptools/_vendor/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def _parse_glibc_version(version_str: str) -> tuple[int, int]:
f"Expected glibc version with 2 components major.minor,"
f" got: {version_str}",
RuntimeWarning,
stacklevel=2,
)
return -1, -1
return int(m.group("major")), int(m.group("minor"))
Expand Down
Loading

0 comments on commit 747bb74

Please sign in to comment.