Skip to content

Commit 4702d9f

Browse files
Merge branch 'release/2.2.0'
2 parents 1381ae8 + d678c3a commit 4702d9f

76 files changed

Lines changed: 14275 additions & 2397 deletions

File tree

Some content is hidden

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

.github/workflows/build-test-release.yml

Lines changed: 213 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
tags:
88
- "[0-9]+.[0-9]+.[0-9]+"
99
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
10-
- "[0-9]+.[0-9]+.[0-9]+dev[0-9]+"
10+
- "[0-9]+.[0-9]+.[0-9]+.dev[0-9]+"
1111

1212
jobs:
1313
test_linux:
@@ -30,17 +30,19 @@ jobs:
3030
- pypy-3.11
3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v3
33+
uses: actions/checkout@v6
3434
- name: Setup Python ${{ matrix.python-version }}
35-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v6
3636
with:
3737
python-version: ${{ matrix.python-version }}
3838
- name: Update pip
3939
run: python -m pip install -U pip wheel setuptools
4040
- name: Install tox
4141
run: python -m pip install tox tox-gh-actions
4242
- name: Install mypy
43-
run: python -m pip install "mypy==1.19.1; python_version >= '3.9'"
43+
run: |
44+
python -m pip install "mypy==1.19.1; python_version == '3.9'"
45+
python -m pip install "mypy==1.20.1; python_version >= '3.10'"
4446
- name: Test with tox
4547
run: python -m tox
4648

@@ -79,10 +81,10 @@ jobs:
7981
}
8082
steps:
8183
- name: Checkout code
82-
uses: actions/checkout@v5
84+
uses: actions/checkout@v6
8385

8486
- name: Setup docker/setup-qemu-action
85-
uses: docker/setup-qemu-action@v3
87+
uses: docker/setup-qemu-action@v4
8688

8789
- name: start python_rv64
8890
run: docker run --platform linux/riscv64 -d --name python_rv64 -v ./:/src python:${{ matrix.python-version.python_image }} bash -c "while true; do sleep 30; done"
@@ -97,7 +99,9 @@ jobs:
9799
- name: Install tox
98100
run: docker exec python_rv64 bash -c "source /src/venv/bin/activate && python -m pip install 'tox<4.0.0' 'tox-gh-actions<3.0.0'"
99101
- name: Install mypy
100-
run: docker exec python_rv64 bash -c "source /src/venv/bin/activate && python -m pip install 'mypy==1.19.1'"
102+
run: |
103+
docker exec python_rv64 bash -c "source /src/venv/bin/activate && python -m pip install 'mypy==1.19.1; python_version == \"3.9\"'"
104+
docker exec python_rv64 bash -c "source /src/venv/bin/activate && python -m pip install 'mypy==1.20.1; python_version >= \"3.10\"'"
101105
- name: Test with tox
102106
run: docker exec python_rv64 bash -c "source /src/venv/bin/activate && cd /src && python -m tox -e '${{ matrix.python-version.tox_e }}'"
103107

@@ -114,7 +118,7 @@ jobs:
114118
- 3.15-dev
115119
steps:
116120
- name: Checkout code
117-
uses: actions/checkout@v2
121+
uses: actions/checkout@v6
118122
- name: Setup Python ${{ matrix.python-version }}
119123
uses: deadsnakes/action@v3.2.0
120124
with:
@@ -125,7 +129,9 @@ jobs:
125129
- name: Install tox
126130
run: python -m pip install tox tox-gh-actions
127131
- name: Install mypy
128-
run: python -m pip install "mypy==1.19.1; python_version >= '3.9'"
132+
run: |
133+
python -m pip install "mypy==1.19.1; python_version == '3.9'"
134+
python -m pip install "mypy==1.20.1; python_version >= '3.10'"
129135
- name: Test with tox
130136
run: python -m tox
131137

@@ -149,17 +155,19 @@ jobs:
149155
- pypy-3.11
150156
steps:
151157
- name: Checkout code
152-
uses: actions/checkout@v3
158+
uses: actions/checkout@v6
153159
- name: Setup Python ${{ matrix.python-version }}
154-
uses: actions/setup-python@v4
160+
uses: actions/setup-python@v6
155161
with:
156162
python-version: ${{ matrix.python-version }}
157163
- name: Update pip
158164
run: python -m pip install -U pip wheel setuptools
159165
- name: Install tox
160166
run: python -m pip install tox tox-gh-actions
161167
- name: Install mypy
162-
run: python -m pip install "mypy==1.19.1; python_version >= '3.9'"
168+
run: |
169+
python -m pip install "mypy==1.19.1; python_version == '3.9'"
170+
python -m pip install "mypy==1.20.1; python_version >= '3.10'"
163171
- name: Test with tox
164172
run: python -m tox
165173

@@ -196,17 +204,19 @@ jobs:
196204
python-version: pypy-3.11
197205
steps:
198206
- name: Checkout code
199-
uses: actions/checkout@v3
207+
uses: actions/checkout@v6
200208
- name: Setup Python ${{ matrix.python-version }}
201-
uses: actions/setup-python@v4
209+
uses: actions/setup-python@v6
202210
with:
203211
python-version: ${{ matrix.python-version }}
204212
- name: Update pip
205213
run: python -m pip install -U pip wheel setuptools
206214
- name: Install tox
207215
run: python -m pip install tox tox-gh-actions
208216
- name: Install mypy
209-
run: python -m pip install "mypy==1.19.1; python_version >= '3.9'"
217+
run: |
218+
python -m pip install "mypy==1.19.1; python_version == '3.9'"
219+
python -m pip install "mypy==1.20.1; python_version >= '3.10'"
210220
- name: Test with tox
211221
run: python -m tox
212222

@@ -219,11 +229,11 @@ jobs:
219229
runs-on: ubuntu-latest
220230
steps:
221231
- name: Checkout code
222-
uses: actions/checkout@v3
232+
uses: actions/checkout@v6
223233
with:
224234
submodules: true
225235
- name: Set up Python 3.9
226-
uses: actions/setup-python@v4
236+
uses: actions/setup-python@v6
227237
with:
228238
python-version: 3.9
229239
- name: Build full source distribution as tar.gz
@@ -233,7 +243,7 @@ jobs:
233243
- name: Build pure Python source wheel
234244
run: WRAPT_INSTALL_EXTENSIONS=false python setup.py bdist_wheel
235245
- name: Store built wheels
236-
uses: actions/upload-artifact@v4
246+
uses: actions/upload-artifact@v7
237247
with:
238248
name: sdist
239249
path: dist/*
@@ -255,10 +265,10 @@ jobs:
255265
- os: ubuntu-latest
256266
arch: riscv64
257267
steps:
258-
- uses: actions/checkout@v5
268+
- uses: actions/checkout@v6
259269
- name: Set up QEMU
260270
if: ${{ matrix.arch == 'riscv64' }}
261-
uses: docker/setup-qemu-action@v3
271+
uses: docker/setup-qemu-action@v4
262272
- name: Build wheels
263273
uses: pypa/cibuildwheel@v3.3.0
264274
with:
@@ -269,7 +279,189 @@ jobs:
269279
CIBW_ARCHS: ${{ matrix.arch }}
270280
CIBW_ENABLE: cpython-freethreading
271281
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9"
272-
- uses: actions/upload-artifact@v4
282+
- uses: actions/upload-artifact@v7
273283
with:
274284
name: dist-${{ matrix.os }}-${{ matrix.arch }}
275285
path: dist/*.whl
286+
287+
release:
288+
name: Publish GitHub release
289+
runs-on: ubuntu-latest
290+
needs:
291+
- sdist
292+
- bdist_wheel
293+
if: startsWith(github.ref, 'refs/tags/')
294+
permissions:
295+
contents: write
296+
steps:
297+
- name: Checkout code
298+
uses: actions/checkout@v6
299+
300+
- name: Resolve version and prerelease status
301+
id: meta
302+
run: |
303+
TAG="${GITHUB_REF_NAME}"
304+
VERSION="${TAG}"
305+
BASE_VERSION="$(echo "$VERSION" | sed -E 's/\.?(dev|rc)[0-9]+$//')"
306+
ANCHOR="version-$(echo "$BASE_VERSION" | tr '.' '-')"
307+
if [[ "$VERSION" == *dev* || "$VERSION" == *rc* ]]; then
308+
PRERELEASE="true"
309+
else
310+
PRERELEASE="false"
311+
fi
312+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
313+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
314+
echo "base_version=$BASE_VERSION" >> "$GITHUB_OUTPUT"
315+
echo "anchor=$ANCHOR" >> "$GITHUB_OUTPUT"
316+
echo "prerelease=$PRERELEASE" >> "$GITHUB_OUTPUT"
317+
318+
- name: Verify version matches tag
319+
run: |
320+
EXPECTED="${{ steps.meta.outputs.version }}"
321+
ACTUAL="$(python <<'PY'
322+
import ast
323+
src = open('src/wrapt/__init__.py').read()
324+
tree = ast.parse(src)
325+
ns = {}
326+
for node in tree.body:
327+
if isinstance(node, ast.FunctionDef) and node.name == "_format_version":
328+
exec(compile(ast.Module(body=[node], type_ignores=[]), '<v>', 'exec'), ns)
329+
elif isinstance(node, ast.Assign):
330+
names = [t.id for t in node.targets if isinstance(t, ast.Name)]
331+
if any(n.startswith('__version') for n in names):
332+
exec(compile(ast.Module(body=[node], type_ignores=[]), '<v>', 'exec'), ns)
333+
print(ns['__version__'])
334+
PY
335+
)"
336+
if [ "$ACTUAL" != "$EXPECTED" ]; then
337+
echo "Tag version ($EXPECTED) does not match __version__ ($ACTUAL) in src/wrapt/__init__.py" >&2
338+
exit 1
339+
fi
340+
echo "Version match: $ACTUAL"
341+
342+
- name: Download all built artifacts
343+
uses: actions/download-artifact@v8
344+
with:
345+
path: dist
346+
merge-multiple: true
347+
348+
- name: List collected artifacts
349+
run: ls -las dist
350+
351+
- name: Generate SHA256SUMS
352+
run: |
353+
cd dist
354+
sha256sum * > SHA256SUMS
355+
cat SHA256SUMS
356+
357+
- name: Write release notes body
358+
run: |
359+
VERSION="${{ steps.meta.outputs.version }}"
360+
BASE_VERSION="${{ steps.meta.outputs.base_version }}"
361+
ANCHOR="${{ steps.meta.outputs.anchor }}"
362+
DOCS_URL="https://wrapt.readthedocs.io/en/latest/changes.html#${ANCHOR}"
363+
if [[ "$VERSION" == *dev* ]]; then
364+
cat > body.md <<EOF
365+
Development snapshot. Not normally published to PyPi
366+
(occasionally uploaded to exercise the release pipeline).
367+
368+
Release notes for the upcoming ${BASE_VERSION} final (work in
369+
progress): ${DOCS_URL}
370+
371+
Platform wheels and the source distribution are attached. To
372+
test against your Python install, either grab a matching wheel
373+
or build from the source distribution:
374+
375+
pip install wrapt-${VERSION}-<python>-<abi>-<platform>.whl
376+
377+
or
378+
379+
tar xf wrapt-${VERSION}.tar.gz
380+
cd wrapt-${VERSION}
381+
pip install .
382+
383+
\`SHA256SUMS\` is attached for verification of the archives.
384+
EOF
385+
elif [[ "$VERSION" == *rc* ]]; then
386+
cat > body.md <<EOF
387+
Release candidate. Release notes for the upcoming
388+
${BASE_VERSION} final (work in progress): ${DOCS_URL}
389+
390+
May be installable from PyPi:
391+
392+
pip install wrapt==${VERSION}
393+
394+
If \`pip\` reports the version is unavailable, this candidate
395+
either has not been uploaded yet or is not being published to
396+
PyPi. Use the attached wheels or build from the source
397+
distribution instead:
398+
399+
tar xf wrapt-${VERSION}.tar.gz
400+
cd wrapt-${VERSION}
401+
pip install .
402+
403+
\`SHA256SUMS\` is attached for verification of the archives.
404+
EOF
405+
else
406+
cat > body.md <<EOF
407+
Full release notes: ${DOCS_URL}
408+
409+
Install from PyPi (recommended):
410+
411+
pip install wrapt==${VERSION}
412+
413+
PyPi uploads follow each GitHub release; if \`pip\` reports the
414+
version is unavailable, the matching PyPi upload may not have
415+
happened yet.
416+
417+
Pre-built wheels are provided for a range of Python versions
418+
and platforms (Linux x86_64/aarch64/riscv64, macOS x86_64 and
419+
arm64, Windows x86_64 and arm64, plus PyPy and free-threaded
420+
builds). The source distribution is also attached together
421+
with \`SHA256SUMS\` for verification.
422+
EOF
423+
fi
424+
cat body.md
425+
426+
- name: Create GitHub release
427+
env:
428+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
429+
GH_REPO: ${{ github.repository }}
430+
run: |
431+
FLAGS=()
432+
if [[ "${{ steps.meta.outputs.prerelease }}" == "true" ]]; then
433+
FLAGS+=("--prerelease")
434+
fi
435+
gh release create "${{ steps.meta.outputs.tag }}" \
436+
--title "wrapt ${{ steps.meta.outputs.version }}" \
437+
--notes-file body.md \
438+
"${FLAGS[@]}" \
439+
dist/*
440+
441+
publish-wrapt:
442+
name: Publish wrapt to PyPi
443+
runs-on: ubuntu-latest
444+
needs:
445+
- release
446+
if: startsWith(github.ref, 'refs/tags/')
447+
environment: pypi-wrapt
448+
permissions:
449+
id-token: write
450+
steps:
451+
- name: Download all built artifacts
452+
uses: actions/download-artifact@v8
453+
with:
454+
path: dist
455+
merge-multiple: true
456+
457+
- name: Stage wrapt sdist and wheels
458+
run: |
459+
mkdir -p stage
460+
cp dist/wrapt-[0-9]*.tar.gz stage/
461+
cp dist/wrapt-[0-9]*.whl stage/
462+
ls -las stage
463+
464+
- name: Publish wrapt to PyPi
465+
uses: pypa/gh-action-pypi-publish@release/v1
466+
with:
467+
packages-dir: stage/

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.py[cod]
2+
__pycache__/
23
.venv/
34
.venv-test-tmp/
45
venv
@@ -47,6 +48,9 @@ nosetests.xml
4748
# Editor save files.
4849
.*.swp
4950

51+
# Claude Code local settings.
52+
.claude/
53+
5054
# Sphinx documentation.
5155
docs/venv
5256
docs/_build

0 commit comments

Comments
 (0)