Skip to content

Commit 5fb38a1

Browse files
committed
Merge branch 'main' into add-mingw-support
2 parents bbe7b64 + 32a906d commit 5fb38a1

File tree

143 files changed

+7047
-1937
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+7047
-1937
lines changed

.coveragerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
omit =
33
# leading `*/` for pytest-dev/pytest-cov#456
44
*/.tox/*
5+
6+
# local
7+
*/compat/*
8+
*/distutils/_vendor/*
59
disable_warnings =
610
couldnt-parse
711

812
[report]
913
show_missing = True
14+
exclude_also =
15+
# jaraco/skeleton#97
16+
@overload
17+
if TYPE_CHECKING:

.github/workflows/main.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ on:
44
merge_group:
55
push:
66
branches-ignore:
7-
# disabled for jaraco/skeleton#103
8-
# - gh-readonly-queue/** # Temporary merge queue-related GH-made branches
7+
# temporary GH branches relating to merge queues (jaraco/skeleton#93)
8+
- gh-readonly-queue/**
9+
tags:
10+
# required if branches-ignore is supplied (jaraco/skeleton#103)
11+
- '**'
912
pull_request:
1013

1114
concurrency:
@@ -34,10 +37,10 @@ env:
3437
jobs:
3538
test:
3639
strategy:
40+
# https://blog.jaraco.com/efficient-use-of-ci-resources/
3741
matrix:
3842
python:
3943
- "3.8"
40-
- "3.11"
4144
- "3.12"
4245
platform:
4346
- ubuntu-latest
@@ -48,6 +51,8 @@ jobs:
4851
platform: ubuntu-latest
4952
- python: "3.10"
5053
platform: ubuntu-latest
54+
- python: "3.11"
55+
platform: ubuntu-latest
5156
- python: pypy3.10
5257
platform: ubuntu-latest
5358
runs-on: ${{ matrix.platform }}
@@ -145,9 +150,9 @@ jobs:
145150
source venv/bin/activate
146151
147152
# python-ruff doesn't work without rust
148-
sed -i '/pytest-ruff/d' setup.cfg
153+
sed -i '/pytest-ruff/d' pyproject.toml
149154
150-
pip install -e .[testing]
155+
pip install -e .[test]
151156
- name: Run tests
152157
shell: msys2 {0}
153158
run: |
@@ -156,7 +161,6 @@ jobs:
156161
157162
ci_setuptools:
158163
# Integration testing with setuptools
159-
if: ${{ false }} # disabled for deprecation warnings
160164
strategy:
161165
matrix:
162166
python:

.readthedocs.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ python:
33
install:
44
- path: .
55
extra_requirements:
6-
- docs
6+
- doc
77

88
# required boilerplate readthedocs/readthedocs.org#10401
99
build:
10-
os: ubuntu-22.04
10+
os: ubuntu-lts-latest
1111
tools:
12-
python: "3"
12+
python: latest
13+
# post-checkout job to ensure the clone isn't shallow jaraco/skeleton#114
14+
jobs:
15+
post_checkout:
16+
- git fetch --unshallow || true

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@
1919

2020
Python Module Distribution Utilities extracted from the Python Standard Library
2121

22-
Synchronizing
23-
=============
22+
This package is unsupported except as integrated into and exposed by Setuptools.
2423

25-
This project is no longer kept in sync with the code still in stdlib, which is deprecated and scheduled for removal.
26-
27-
To Setuptools
28-
-------------
24+
Integration
25+
-----------
2926

3027
Simply merge the changes directly into setuptools' repo.

conftest.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1+
import logging
12
import os
2-
import sys
3-
import platform
43
import pathlib
5-
import logging
4+
import platform
5+
import sys
66

7-
import pytest
87
import path
9-
8+
import pytest
109

1110
collect_ignore = []
1211

1312

1413
if platform.system() != 'Windows':
15-
collect_ignore.extend(
16-
[
17-
'distutils/msvc9compiler.py',
18-
]
19-
)
14+
collect_ignore.extend([
15+
'distutils/msvc9compiler.py',
16+
])
17+
18+
19+
collect_ignore_glob = [
20+
'distutils/_vendor/**/*',
21+
]
2022

2123

2224
@pytest.fixture
@@ -59,7 +61,7 @@ def _save_cwd():
5961

6062
@pytest.fixture
6163
def distutils_managed_tempdir(request):
62-
from distutils.tests import py38compat as os_helper
64+
from distutils.tests.compat import py38 as os_helper
6365

6466
self = request.instance
6567
self.tempdirs = []
@@ -95,8 +97,7 @@ def temp_cwd(tmp_path):
9597

9698
@pytest.fixture
9799
def pypirc(request, save_env, distutils_managed_tempdir):
98-
from distutils.core import PyPIRCCommand
99-
from distutils.core import Distribution
100+
from distutils.core import Distribution, PyPIRCCommand
100101

101102
self = request.instance
102103
self.tmp_dir = self.mkdtemp()
@@ -154,3 +155,10 @@ def temp_home(tmp_path, monkeypatch):
154155
def fake_home(fs, monkeypatch):
155156
home = fs.create_dir('/fakehome')
156157
return _set_home(monkeypatch, pathlib.Path(home.path))
158+
159+
160+
@pytest.fixture
161+
def disable_macos_customization(monkeypatch):
162+
from distutils import sysconfig
163+
164+
monkeypatch.setattr(sysconfig, '_customize_macos', lambda: None)

distutils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import importlib
2+
import sys
33

44
__version__, _, _ = sys.version.partition(' ')
55

distutils/_collections.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
from __future__ import annotations
2+
13
import collections
24
import functools
35
import itertools
46
import operator
7+
from collections.abc import Mapping
8+
from typing import Any
59

610

711
# from jaraco.collections 3.5.1
@@ -58,7 +62,7 @@ def __len__(self):
5862
return len(list(iter(self)))
5963

6064

61-
# from jaraco.collections 3.7
65+
# from jaraco.collections 5.0.1
6266
class RangeMap(dict):
6367
"""
6468
A dictionary-like object that uses the keys as bounds for a range.
@@ -70,7 +74,7 @@ class RangeMap(dict):
7074
One may supply keyword parameters to be passed to the sort function used
7175
to sort keys (i.e. key, reverse) as sort_params.
7276
73-
Let's create a map that maps 1-3 -> 'a', 4-6 -> 'b'
77+
Create a map that maps 1-3 -> 'a', 4-6 -> 'b'
7478
7579
>>> r = RangeMap({3: 'a', 6: 'b'}) # boy, that was easy
7680
>>> r[1], r[2], r[3], r[4], r[5], r[6]
@@ -82,7 +86,7 @@ class RangeMap(dict):
8286
>>> r[4.5]
8387
'b'
8488
85-
But you'll notice that the way rangemap is defined, it must be open-ended
89+
Notice that the way rangemap is defined, it must be open-ended
8690
on one side.
8791
8892
>>> r[0]
@@ -140,7 +144,12 @@ class RangeMap(dict):
140144
141145
"""
142146

143-
def __init__(self, source, sort_params={}, key_match_comparator=operator.le):
147+
def __init__(
148+
self,
149+
source,
150+
sort_params: Mapping[str, Any] = {},
151+
key_match_comparator=operator.le,
152+
):
144153
dict.__init__(self, source)
145154
self.sort_params = sort_params
146155
self.match = key_match_comparator

distutils/_itertools.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# from more_itertools 10.2
2+
def always_iterable(obj, base_type=(str, bytes)):
3+
"""If *obj* is iterable, return an iterator over its items::
4+
5+
>>> obj = (1, 2, 3)
6+
>>> list(always_iterable(obj))
7+
[1, 2, 3]
8+
9+
If *obj* is not iterable, return a one-item iterable containing *obj*::
10+
11+
>>> obj = 1
12+
>>> list(always_iterable(obj))
13+
[1]
14+
15+
If *obj* is ``None``, return an empty iterable:
16+
17+
>>> obj = None
18+
>>> list(always_iterable(None))
19+
[]
20+
21+
By default, binary and text strings are not considered iterable::
22+
23+
>>> obj = 'foo'
24+
>>> list(always_iterable(obj))
25+
['foo']
26+
27+
If *base_type* is set, objects for which ``isinstance(obj, base_type)``
28+
returns ``True`` won't be considered iterable.
29+
30+
>>> obj = {'a': 1}
31+
>>> list(always_iterable(obj)) # Iterate over the dict's keys
32+
['a']
33+
>>> list(always_iterable(obj, base_type=dict)) # Treat dicts as a unit
34+
[{'a': 1}]
35+
36+
Set *base_type* to ``None`` to avoid any special handling and treat objects
37+
Python considers iterable as iterable:
38+
39+
>>> obj = 'foo'
40+
>>> list(always_iterable(obj, base_type=None))
41+
['f', 'o', 'o']
42+
"""
43+
if obj is None:
44+
return iter(())
45+
46+
if (base_type is not None) and isinstance(obj, base_type):
47+
return iter((obj,))
48+
49+
try:
50+
return iter(obj)
51+
except TypeError:
52+
return iter((obj,))

distutils/_log.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
import logging
22

3-
43
log = logging.getLogger()

distutils/_macos_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import importlib
2+
import sys
33

44

55
def bypass_compiler_fixup(cmd, args):

distutils/_modified.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import functools
44
import os.path
55

6-
from .errors import DistutilsFileError
7-
from .py39compat import zip_strict
86
from ._functools import splat
7+
from .compat.py39 import zip_strict
8+
from .errors import DistutilsFileError
99

1010

1111
def _newer(source, target):
@@ -24,7 +24,7 @@ def newer(source, target):
2424
Raises DistutilsFileError if 'source' does not exist.
2525
"""
2626
if not os.path.exists(source):
27-
raise DistutilsFileError("file '%s' does not exist" % os.path.abspath(source))
27+
raise DistutilsFileError(f"file '{os.path.abspath(source)}' does not exist")
2828

2929
return _newer(source, target)
3030

0 commit comments

Comments
 (0)