Skip to content

Commit d7581eb

Browse files
authored
build: raise the setuptools floor to 69.0.0 so wheels ship py.typed (#2062) (#2064)
A wheel built at the old floor, 62.3.0, without build isolation left out pcapkit/py.typed: nothing declares it, and setuptools packages it unasked only from 69.0.0 (pypa/setuptools#3136). Per the owner's ruling, bump the floor rather than add a package-data entry. - pyproject.toml: [build-system] requires "setuptools>=69.0.0"; the comment gives the reason and keeps #1814's "**" glob rationale. - conda/pypcapkit/meta.yaml: build and host pins match. - tests/project/test_setuptools_floor_2062.py pins the floor at or above 69.0.0 and the conda pins to it; fails on main. - 1.5.0 changelog entry; CHANGELOG.md regenerated. Wheels measured on 3.8 and 3.14 at 69.0.0 ship py.typed, file list identical to 84.2.1's. Related project tests pass, run one by one.
1 parent f8ade1b commit d7581eb

5 files changed

Lines changed: 93 additions & 7 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ This resolves [#548](https://github.com/JarryShaw/PyPCAPKit/issues/548), which r
437437
- the API reference renders what the code declares. `Extractor._vfunc` keeps its annotation ([#1839](https://github.com/JarryShaw/PyPCAPKit/issues/1839), [#1867](https://github.com/JarryShaw/PyPCAPKit/pull/1867)), and the HTTP/2 frame schemas' and the engine classes' annotations resolve ([#1857](https://github.com/JarryShaw/PyPCAPKit/issues/1857), [#1870](https://github.com/JarryShaw/PyPCAPKit/pull/1870)). Under the pinned sphinx-autodoc-typehints 3.15.0 ([#1856](https://github.com/JarryShaw/PyPCAPKit/issues/1856), [#1877](https://github.com/JarryShaw/PyPCAPKit/pull/1877)), `conf.py` renders an `aenum` base as such, keeps a default as written (`byteorder=sys.byteorder` rather than the build host's value), gives a class the parameters of the `__init__` its `__new__` hides and an enumeration `(*values)`, keeps table ids unique, and stops the source index linking a missing page ([#1858](https://github.com/JarryShaw/PyPCAPKit/issues/1858) to [#1863](https://github.com/JarryShaw/PyPCAPKit/issues/1863), [#1881](https://github.com/JarryShaw/PyPCAPKit/pull/1881)). The generated const tables carry no version directives; each note is on the module's hand-written page instead ([#1884](https://github.com/JarryShaw/PyPCAPKit/issues/1884), [#1895](https://github.com/JarryShaw/PyPCAPKit/pull/1895)).
438438
- `pcapkit-cli`'s help strings say what each option does: `-o` describes the output rather than the input, an extension is appended only under `--auto-extension`, and each format flag names the flags that take precedence over it ([#1796](https://github.com/JarryShaw/PyPCAPKit/issues/1796), [#1810](https://github.com/JarryShaw/PyPCAPKit/pull/1810)).
439439
- the Conda package: its vendored dependencies are the package's `dependencies` and its `all` extra, with their requirements, shipped with their data files rather than as `.py` files only ([#1814](https://github.com/JarryShaw/PyPCAPKit/issues/1814), [#1821](https://github.com/JarryShaw/PyPCAPKit/pull/1821)); the `osx-64` package is built on an Intel runner, where converting the arm64 build shipped arm64 binaries ([#1822](https://github.com/JarryShaw/PyPCAPKit/issues/1822), [#1825](https://github.com/JarryShaw/PyPCAPKit/pull/1825)); and on Intel macOS it pins `cryptography` 48.0.1, which has a wheel for that platform where the newer pin has none ([#1827](https://github.com/JarryShaw/PyPCAPKit/issues/1827), [#1828](https://github.com/JarryShaw/PyPCAPKit/pull/1828)). `util/conda_vendor.py --check` reports a package pinned differently under one marker ([#1852](https://github.com/JarryShaw/PyPCAPKit/issues/1852), [#1865](https://github.com/JarryShaw/PyPCAPKit/pull/1865)); the platform pins move to `conda/platform-pins.toml`, each with a review-by date, and Conda Update moves them up ([#1851](https://github.com/JarryShaw/PyPCAPKit/issues/1851), [#1885](https://github.com/JarryShaw/PyPCAPKit/pull/1885)); and the release's conda leg installs none of pcapkit's extras and smoke-tests the package before uploading it ([#1854](https://github.com/JarryShaw/PyPCAPKit/issues/1854), [#1855](https://github.com/JarryShaw/PyPCAPKit/issues/1855), [#1868](https://github.com/JarryShaw/PyPCAPKit/pull/1868)).
440+
- a wheel built with the oldest setuptools `[build-system] requires` allowed, without build isolation, left out `pcapkit/py.typed`, so type checkers read the installed package as untyped. Nothing declares the file, and setuptools ships it unasked only from 69.0.0, so that is the floor now, in `pyproject.toml` and the Conda recipe alike ([#2062](https://github.com/JarryShaw/PyPCAPKit/issues/2062), [#2064](https://github.com/JarryShaw/PyPCAPKit/pull/2064)).
440441

441442
---
442443

‎conda/pypcapkit/meta.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ requirements:
2424
- git
2525
- python
2626
- pip
27-
- setuptools>=62.3.0
27+
- setuptools>=69.0.0
2828

2929
# - dictdumper~=0.8.0 # for formatted output
3030
# - chardet # for bytes decode
@@ -43,7 +43,7 @@ requirements:
4343
host:
4444
- python
4545
- pip
46-
- setuptools>=62.3.0
46+
- setuptools>=69.0.0
4747

4848
# - dictdumper~=0.8.0 # for formatted output
4949
# - chardet # for bytes decode

‎docs/source/changelog/1.5.0.rst‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,3 +3371,8 @@ Fixed
33713371
them up (:issue:`1851`, :pr:`1885`); and the release's conda leg installs none of
33723372
pcapkit's extras and smoke-tests the package before uploading it (:issue:`1854`,
33733373
:issue:`1855`, :pr:`1868`).
3374+
* a wheel built with the oldest setuptools ``[build-system] requires`` allowed,
3375+
without build isolation, left out ``pcapkit/py.typed``, so type checkers read the
3376+
installed package as untyped. Nothing declares the file, and setuptools ships it
3377+
unasked only from 69.0.0, so that is the floor now, in ``pyproject.toml`` and the
3378+
Conda recipe alike (:issue:`2062`, :pr:`2064`).

‎pyproject.toml‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[build-system]
22
requires = [
3-
# 62.3.0 is the first release whose ``package-data`` globs read ``**`` as any
4-
# depth, which the ``pcapkit._extern`` entry below needs (#1814). Measured:
5-
# 61.0.0 and 62.2.0 read it as ``*``, and ship only the files one directory
6-
# down from it.
7-
"setuptools>=62.3.0",
3+
# 69.0.0 is the first release that ships ``pcapkit/py.typed`` unasked
4+
# (pypa/setuptools#3136, in its NEWS.rst): nothing here declares the file, so
5+
# a wheel built with 68.2.2 or older leaves it out and type checkers read the
6+
# package as untyped (#2062). Measured on both sides of the bump. It also
7+
# keeps what the earlier floor of 62.3.0 was for: ``package-data`` globs that
8+
# read ``**`` as any depth, which the ``pcapkit._extern`` entry below needs
9+
# (#1814) -- 61.0.0 and 62.2.0 read it as ``*``, measured. 69.0.0 still
10+
# supports Python 3.8, the ``requires-python`` floor.
11+
"setuptools>=69.0.0",
812
]
913
build-backend = "setuptools.build_meta"
1014

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# -*- coding: utf-8 -*-
2+
"""#2062: the setuptools floor is one that ships ``pcapkit/py.typed``.
3+
4+
Nothing declares ``py.typed``: :file:`MANIFEST.in` includes ``*.py`` alone, and
5+
:file:`pyproject.toml` has no ``package-data`` entry for ``pcapkit``. setuptools
6+
69.0.0 is the first release that packages it regardless (pypa/setuptools#3136,
7+
in that release's ``NEWS.rst``), measured: a wheel built with 68.2.2 leaves it
8+
out, and one built with 69.0.0 has it. Pinned here:
9+
10+
* ``[build-system] requires`` floors setuptools at 69.0.0 or later;
11+
* every setuptools pin in :file:`conda/pypcapkit/meta.yaml` matches that floor.
12+
13+
These read the declarations, not a built wheel: they catch the floor being
14+
lowered again, not a later setuptools release dropping the behaviour.
15+
16+
"""
17+
18+
from __future__ import annotations
19+
20+
import pathlib
21+
import re
22+
import unittest
23+
24+
try:
25+
import tomllib
26+
except ImportError: # pragma: no cover
27+
tomllib = None # type: ignore[assignment]
28+
29+
#: Test tier (#1958): reads pyproject.toml and the conda recipe, the same on every leg.
30+
__tier__ = 'LATEST'
31+
32+
ROOT = pathlib.Path(__file__).resolve().parents[2]
33+
34+
#: The first setuptools that packages ``py.typed`` without being told to (#2062).
35+
FIRST_WITH_PY_TYPED = (69, 0, 0)
36+
37+
#: A ``setuptools>=X.Y.Z`` requirement, as either file spells it.
38+
FLOOR = re.compile(r'^\s*(?:-\s*)?setuptools\s*>=\s*(\d+)\.(\d+)\.(\d+)\s*$')
39+
40+
41+
def floors(lines: 'list[str]') -> 'list[tuple[int, int, int]]':
42+
"""Every ``setuptools>=`` floor in ``lines``."""
43+
return [tuple(int(part) for part in match.groups()) # type: ignore[misc]
44+
for match in map(FLOOR.match, lines) if match]
45+
46+
47+
class SetuptoolsFloorTests(unittest.TestCase):
48+
"""The build floor packages ``py.typed``, and conda agrees with it."""
49+
50+
def setUp(self) -> None:
51+
if tomllib is None: # pragma: no cover
52+
self.skipTest('tomllib needs Python 3.11')
53+
pyproject = tomllib.loads((ROOT / 'pyproject.toml').read_text(encoding='utf-8'))
54+
requires = pyproject['build-system']['requires']
55+
self.assertEqual([text for text in requires if text.startswith('setuptools')],
56+
[text for text in requires if FLOOR.match(text)],
57+
'every setuptools requirement should be a plain ">=" floor')
58+
self.floors = floors(requires)
59+
60+
def test_build_floor_ships_py_typed(self) -> None:
61+
self.assertEqual(len(self.floors), 1, self.floors)
62+
self.assertGreaterEqual(self.floors[0], FIRST_WITH_PY_TYPED,
63+
'setuptools older than 69.0.0 builds wheels without pcapkit/py.typed')
64+
65+
def test_conda_pins_match_the_build_floor(self) -> None:
66+
lines = (ROOT / 'conda' / 'pypcapkit' / 'meta.yaml').read_text(encoding='utf-8').splitlines()
67+
pins = floors(lines)
68+
self.assertTrue(pins, 'the conda recipe pins no setuptools floor')
69+
self.assertEqual(set(pins), set(self.floors))
70+
71+
def test_py_typed_exists(self) -> None:
72+
self.assertTrue((ROOT / 'pcapkit' / 'py.typed').is_file())
73+
74+
75+
if __name__ == '__main__':
76+
unittest.main()

0 commit comments

Comments
 (0)