Skip to content

Commit af23e4c

Browse files
authored
Merge branch 'main' into pkg_resoruces-typign-fixes-for-annotations
2 parents 0d8c01f + dcfc833 commit af23e4c

38 files changed

+439
-234
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ jobs:
6161
- platform: ubuntu-latest
6262
python: "3.10"
6363
distutils: stdlib
64+
# Python 3.8, 3.9 are on macos-13 but not macos-latest (macos-14-arm64)
65+
# https://github.com/actions/setup-python/issues/850
66+
# https://github.com/actions/setup-python/issues/696#issuecomment-1637587760
67+
- {python: "3.8", platform: "macos-13"}
68+
exclude:
69+
- {python: "3.8", platform: "macos-latest"}
6470
runs-on: ${{ matrix.platform }}
6571
continue-on-error: ${{ matrix.python == '3.13' }}
6672
env:
@@ -89,7 +95,8 @@ jobs:
8995
shell: bash
9096
run: |
9197
rm -rf dist
92-
pipx run build
98+
# workaround for pypa/setuptools#4333
99+
pipx run --pip-args 'pyproject-hooks!=1.1' build
93100
echo "PRE_BUILT_SETUPTOOLS_SDIST=$(ls dist/*.tar.gz)" >> $GITHUB_ENV
94101
echo "PRE_BUILT_SETUPTOOLS_WHEEL=$(ls dist/*.whl)" >> $GITHUB_ENV
95102
rm -rf setuptools.egg-info # Avoid interfering with the other tests
@@ -122,6 +129,7 @@ jobs:
122129
job:
123130
- diffcov
124131
- docs
132+
- check-extern
125133
runs-on: ubuntu-latest
126134
steps:
127135
- uses: actions/checkout@v4

NEWS.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ Improved Documentation
119119
----------------------
120120

121121
- Updated documentation referencing obsolete Python 3.7 code. -- by :user:`Avasam` (#4096)
122-
- Changed ``versionadded`` for "Type information included by default" feature from ``v68.3.0`` to ``v69.0.0`` -- by :user:Avasam` (#4182)
122+
- Changed ``versionadded`` for "Type information included by default" feature from ``v68.3.0`` to ``v69.0.0`` -- by :user:`Avasam` (#4182)
123123
- Described the auto-generated files -- by :user:`VladimirFokow` (#4198)
124124
- Updated "Quickstart" to describe the current status of ``setup.cfg`` and ``pyproject.toml`` -- by :user:`VladimirFokow` (#4200)
125125

README.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
.. image:: https://img.shields.io/pypi/v/setuptools.svg
1+
.. |pypi-version| image:: https://img.shields.io/pypi/v/setuptools.svg
22
:target: https://pypi.org/project/setuptools
33

4-
.. image:: https://img.shields.io/pypi/pyversions/setuptools.svg
4+
.. |py-version| image:: https://img.shields.io/pypi/pyversions/setuptools.svg
55

6-
.. image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg
6+
.. |test-badge| image:: https://github.com/pypa/setuptools/actions/workflows/main.yml/badge.svg
77
:target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22tests%22
88
:alt: tests
99

10-
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json
11-
:target: https://github.com/astral-sh/ruff
12-
:alt: Ruff
10+
.. |ruff-badge| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json
11+
:target: https://github.com/astral-sh/ruff
12+
:alt: Ruff
1313

14-
.. image:: https://img.shields.io/readthedocs/setuptools/latest.svg
15-
:target: https://setuptools.pypa.io
14+
.. |docs-badge| image:: https://img.shields.io/readthedocs/setuptools/latest.svg
15+
:target: https://setuptools.pypa.io
1616

17-
.. image:: https://img.shields.io/badge/skeleton-2024-informational
17+
.. |skeleton-badge| image:: https://img.shields.io/badge/skeleton-2024-informational
1818
:target: https://blog.jaraco.com/skeleton
1919

20-
.. image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white
20+
.. |codecov-badge| image:: https://img.shields.io/codecov/c/github/pypa/setuptools/master.svg?logo=codecov&logoColor=white
2121
:target: https://codecov.io/gh/pypa/setuptools
2222

23-
.. image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat
23+
.. |tidelift-badge| image:: https://tidelift.com/badges/github/pypa/setuptools?style=flat
2424
:target: https://tidelift.com/subscription/pkg/pypi-setuptools?utm_source=pypi-setuptools&utm_medium=readme
2525

26-
.. image:: https://img.shields.io/discord/803025117553754132
26+
.. |discord-badge| image:: https://img.shields.io/discord/803025117553754132
2727
:target: https://discord.com/channels/803025117553754132/815945031150993468
2828
:alt: Discord
2929

30+
|pypi-version| |py-version| |test-badge| |ruff-badge| |docs-badge| |skeleton-badge| |codecov-badge| |discord-badge|
31+
3032
See the `Quickstart <https://setuptools.pypa.io/en/latest/userguide/quickstart.html>`_
3133
and the `User's Guide <https://setuptools.pypa.io/en/latest/userguide/>`_ for
3234
instructions on how to use Setuptools.

newsfragments/4255.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Treat ``EncodingWarning``s as errors in tests. -- by :user:`Avasam`

newsfragments/4309.removal.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Further adoption of UTF-8 in ``setuptools``.
2+
This change regards mostly files produced and consumed during the build process
3+
(e.g. metadata files, script wrappers, automatically updated config files, etc..)
4+
Although precautions were taken to minimize disruptions, some edge cases might
5+
be subject to backwards incompatibility.
6+
7+
Support for ``"locale"`` encoding is now **deprecated**.

newsfragments/4312.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Uses RST substitution to put badges in 1 line.

newsfragments/4332.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modernized and refactored VCS handling in package_index.

pkg_resources/__init__.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,8 +1524,7 @@ def run_script(self, script_name, namespace):
15241524
script_filename = self._fn(self.egg_info, script)
15251525
namespace['__file__'] = script_filename
15261526
if os.path.exists(script_filename):
1527-
with open(script_filename) as fid:
1528-
source = fid.read()
1527+
source = _read_utf8_with_fallback(script_filename)
15291528
code = compile(source, script_filename, 'exec')
15301529
exec(code, namespace, namespace)
15311530
else:
@@ -2175,11 +2174,10 @@ def non_empty_lines(path):
21752174
"""
21762175
Yield non-empty lines from file at path
21772176
"""
2178-
with open(path) as f:
2179-
for line in f:
2180-
line = line.strip()
2181-
if line:
2182-
yield line
2177+
for line in _read_utf8_with_fallback(path).splitlines():
2178+
line = line.strip()
2179+
if line:
2180+
yield line
21832181

21842182

21852183
def resolve_egg_link(path):
@@ -3322,3 +3320,35 @@ def _initialize_master_working_set():
33223320
# match order
33233321
list(map(working_set.add_entry, sys.path))
33243322
globals().update(locals())
3323+
3324+
3325+
# ---- Ported from ``setuptools`` to avoid introducing an import inter-dependency ----
3326+
LOCALE_ENCODING = "locale" if sys.version_info >= (3, 10) else None
3327+
3328+
3329+
def _read_utf8_with_fallback(file: str, fallback_encoding=LOCALE_ENCODING) -> str:
3330+
"""See setuptools.unicode_utils._read_utf8_with_fallback"""
3331+
try:
3332+
with open(file, "r", encoding="utf-8") as f:
3333+
return f.read()
3334+
except UnicodeDecodeError: # pragma: no cover
3335+
msg = f"""\
3336+
********************************************************************************
3337+
`encoding="utf-8"` fails with {file!r}, trying `encoding={fallback_encoding!r}`.
3338+
3339+
This fallback behaviour is considered **deprecated** and future versions of
3340+
`setuptools/pkg_resources` may not implement it.
3341+
3342+
Please encode {file!r} with "utf-8" to ensure future builds will succeed.
3343+
3344+
If this file was produced by `setuptools` itself, cleaning up the cached files
3345+
and re-building/re-installing the package with a newer version of `setuptools`
3346+
(e.g. by updating `build-system.requires` in its `pyproject.toml`)
3347+
might solve the problem.
3348+
********************************************************************************
3349+
"""
3350+
# TODO: Add a deadline?
3351+
# See comment in setuptools.unicode_utils._Utf8EncodingNeeded
3352+
warnings.warns(msg, PkgResourcesDeprecationWarning, stacklevel=2)
3353+
with open(file, "r", encoding=fallback_encoding) as f:
3354+
return f.read()

pkg_resources/_vendor/vendored.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ jaraco.text==3.7.0
99
importlib_resources==5.10.2
1010
# required for importlib_resources on older Pythons
1111
zipp==3.7.0
12+
# required for jaraco.functools
13+
more_itertools==10.2.0
1214
# required for jaraco.context on older Pythons
1315
backports.tarfile

pkg_resources/extern/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,21 @@ def install(self):
7070
sys.meta_path.append(self)
7171

7272

73+
# [[[cog
74+
# import cog
75+
# from tools.vendored import yield_root_package
76+
# names = "\n".join(f" {x!r}," for x in yield_root_package('pkg_resources'))
77+
# cog.outl(f"names = (\n{names}\n)")
78+
# ]]]
7379
names = (
7480
'packaging',
7581
'platformdirs',
82+
'typing_extensions',
7683
'jaraco',
7784
'importlib_resources',
85+
'zipp',
7886
'more_itertools',
7987
'backports',
8088
)
89+
# [[[end]]]
8190
VendorImporter(__name__, names).install()

0 commit comments

Comments
 (0)