Skip to content

Commit 0a69f1c

Browse files
Merge branch '3.12' into backport-a3327db-3.12
2 parents b5f9839 + c57a33d commit 0a69f1c

File tree

174 files changed

+4045
-4486
lines changed

Some content is hidden

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

174 files changed

+4045
-4486
lines changed

.azure-pipelines/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
trigger: ['main', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7']
1+
trigger: ['main', '3.13', '3.12', '3.11', '3.10', '3.9', '3.8']
22

33
jobs:
44
- job: Prebuild

.github/workflows/build.yml

Lines changed: 40 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Tests
22

3-
# gh-84728: "paths-ignore" is not used to skip documentation-only PRs, because
4-
# it prevents to mark a job as mandatory. A PR cannot be merged if a job is
5-
# mandatory but not scheduled because of "paths-ignore".
63
on:
74
workflow_dispatch:
85
push:
@@ -31,105 +28,19 @@ concurrency:
3128

3229
jobs:
3330
check_source:
34-
name: 'Check for source changes'
35-
runs-on: ubuntu-latest
36-
timeout-minutes: 10
37-
outputs:
38-
# Some of the referenced steps set outputs conditionally and there may be
39-
# cases when referencing them evaluates to empty strings. It is nice to
40-
# work with proper booleans so they have to be evaluated through JSON
41-
# conversion in the expressions. However, empty strings used like that
42-
# may trigger all sorts of undefined and hard-to-debug behaviors in
43-
# GitHub Actions CI/CD. To help with this, all of the outputs set here
44-
# that are meant to be used as boolean flags (and not arbitrary strings),
45-
# MUST have fallbacks with default values set. A common pattern would be
46-
# to add ` || false` to all such expressions here, in the output
47-
# definitions. They can then later be safely used through the following
48-
# idiom in job conditionals and other expressions. Here's some examples:
49-
#
50-
# if: fromJSON(needs.check_source.outputs.run-docs)
51-
#
52-
# ${{
53-
# fromJSON(needs.check_source.outputs.run_tests)
54-
# && 'truthy-branch'
55-
# || 'falsy-branch'
56-
# }}
57-
#
58-
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
59-
run-win-msi: ${{ steps.win-msi-changes.outputs.run-win-msi || false }}
60-
run_tests: ${{ steps.check.outputs.run_tests || false }}
61-
run_hypothesis: ${{ steps.check.outputs.run_hypothesis || false }}
62-
config_hash: ${{ steps.config_hash.outputs.hash }} # str
63-
steps:
64-
- uses: actions/checkout@v4
65-
- name: Check for source changes
66-
id: check
67-
run: |
68-
if [ -z "$GITHUB_BASE_REF" ]; then
69-
echo "run_tests=true" >> $GITHUB_OUTPUT
70-
else
71-
git fetch origin $GITHUB_BASE_REF --depth=1
72-
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
73-
# reliable than git diff "origin/$GITHUB_BASE_REF.." (2 dots),
74-
# but it requires to download more commits (this job uses
75-
# "git fetch --depth=1").
76-
#
77-
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) works with Git
78-
# 2.26, but Git 2.28 is stricter and fails with "no merge base".
79-
#
80-
# git diff "origin/$GITHUB_BASE_REF.." (2 dots) should be enough on
81-
# GitHub, since GitHub starts by merging origin/$GITHUB_BASE_REF
82-
# into the PR branch anyway.
83-
#
84-
# https://github.com/python/core-workflow/issues/373
85-
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$|\.md$|mypy\.ini$)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
86-
fi
87-
88-
# Check if we should run hypothesis tests
89-
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
90-
echo $GIT_BRANCH
91-
if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then
92-
echo "Branch too old for hypothesis tests"
93-
echo "run_hypothesis=false" >> $GITHUB_OUTPUT
94-
else
95-
echo "Run hypothesis tests"
96-
echo "run_hypothesis=true" >> $GITHUB_OUTPUT
97-
fi
98-
- name: Compute hash for config cache key
99-
id: config_hash
100-
run: |
101-
echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> $GITHUB_OUTPUT
102-
- name: Get a list of the changed documentation-related files
103-
if: github.event_name == 'pull_request'
104-
id: changed-docs-files
105-
uses: Ana06/[email protected]
106-
with:
107-
filter: |
108-
Doc/**
109-
Misc/**
110-
.github/workflows/reusable-docs.yml
111-
format: csv # works for paths with spaces
112-
- name: Check for docs changes
113-
if: >-
114-
github.event_name == 'pull_request'
115-
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
116-
id: docs-changes
117-
run: |
118-
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
119-
- name: Get a list of the MSI installer-related files
120-
id: changed-win-msi-files
121-
uses: Ana06/[email protected]
122-
with:
123-
filter: |
124-
Tools/msi/**
125-
.github/workflows/reusable-windows-msi.yml
126-
format: csv # works for paths with spaces
127-
- name: Check for changes in MSI installer-related files
128-
if: >-
129-
steps.changed-win-msi-files.outputs.added_modified_renamed != ''
130-
id: win-msi-changes
131-
run: |
132-
echo "run-win-msi=true" >> "${GITHUB_OUTPUT}"
31+
name: Change detection
32+
# To use boolean outputs from this job, parse them as JSON.
33+
# Here's some examples:
34+
#
35+
# if: fromJSON(needs.check_source.outputs.run-docs)
36+
#
37+
# ${{
38+
# fromJSON(needs.check_source.outputs.run_tests)
39+
# && 'truthy-branch'
40+
# || 'falsy-branch'
41+
# }}
42+
#
43+
uses: ./.github/workflows/reusable-change-detection.yml
13344

13445
check-docs:
13546
name: Docs
@@ -286,15 +197,38 @@ jobs:
286197
arch: ${{ matrix.arch }}
287198

288199
build_macos:
289-
name: 'macOS'
200+
name: >-
201+
macOS
202+
${{ fromJSON(matrix.free-threading) && '(free-threading)' || '' }}
290203
needs: check_source
291204
if: needs.check_source.outputs.run_tests == 'true'
205+
strategy:
206+
fail-fast: false
207+
matrix:
208+
# Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
209+
# macOS 13 only runs tests against the GIL-enabled CPython.
210+
# Cirrus used for upstream, macos-14 for forks.
211+
os:
212+
- ghcr.io/cirruslabs/macos-runner:sonoma
213+
- macos-14
214+
- macos-13
215+
is-fork: # only used for the exclusion trick
216+
- ${{ github.repository_owner != 'python' }}
217+
free-threading:
218+
- false
219+
# - true
220+
exclude:
221+
- os: ghcr.io/cirruslabs/macos-runner:sonoma
222+
is-fork: true
223+
- os: macos-14
224+
is-fork: false
225+
- os: macos-13
226+
free-threading: true
292227
uses: ./.github/workflows/reusable-macos.yml
293228
with:
294229
config_hash: ${{ needs.check_source.outputs.config_hash }}
295-
# Cirrus and macos-14 are M1, macos-13 is default GHA Intel.
296-
# Cirrus used for upstream, macos-14 for forks.
297-
os-matrix: '["ghcr.io/cirruslabs/macos-runner:sonoma", "macos-14", "macos-13"]'
230+
free-threading: ${{ matrix.free-threading }}
231+
os: ${{ matrix.os }}
298232

299233
build_ubuntu:
300234
name: >-
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
3+
name: Change detection
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_call:
7+
outputs:
8+
# Some of the referenced steps set outputs conditionally and there may be
9+
# cases when referencing them evaluates to empty strings. It is nice to
10+
# work with proper booleans so they have to be evaluated through JSON
11+
# conversion in the expressions. However, empty strings used like that
12+
# may trigger all sorts of undefined and hard-to-debug behaviors in
13+
# GitHub Actions CI/CD. To help with this, all of the outputs set here
14+
# that are meant to be used as boolean flags (and not arbitrary strings),
15+
# MUST have fallbacks with default values set. A common pattern would be
16+
# to add ` || false` to all such expressions here, in the output
17+
# definitions. They can then later be safely used through the following
18+
# idiom in job conditionals and other expressions. Here's some examples:
19+
#
20+
# if: fromJSON(needs.change-detection.outputs.run-docs)
21+
#
22+
# ${{
23+
# fromJSON(needs.change-detection.outputs.run-tests)
24+
# && 'truthy-branch'
25+
# || 'falsy-branch'
26+
# }}
27+
#
28+
config_hash:
29+
description: Config hash value for use in cache keys
30+
value: ${{ jobs.compute-changes.outputs.config-hash }} # str
31+
run-docs:
32+
description: Whether to build the docs
33+
value: ${{ jobs.compute-changes.outputs.run-docs || false }} # bool
34+
run_tests:
35+
description: Whether to run the regular tests
36+
value: ${{ jobs.compute-changes.outputs.run-tests || false }} # bool
37+
run-win-msi:
38+
description: Whether to run the MSI installer smoke tests
39+
value: >- # bool
40+
${{ jobs.compute-changes.outputs.run-win-msi || false }}
41+
run_hypothesis:
42+
description: Whether to run the Hypothesis tests
43+
value: >- # bool
44+
${{ jobs.compute-changes.outputs.run-hypothesis || false }}
45+
run_cifuzz:
46+
description: Whether to run the CIFuzz job
47+
value: >- # bool
48+
${{ jobs.compute-changes.outputs.run-cifuzz || false }}
49+
50+
jobs:
51+
compute-changes:
52+
name: Compute changed files
53+
runs-on: ubuntu-latest
54+
timeout-minutes: 10
55+
outputs:
56+
config-hash: ${{ steps.config-hash.outputs.hash }}
57+
run-cifuzz: ${{ steps.check.outputs.run-cifuzz }}
58+
run-docs: ${{ steps.docs-changes.outputs.run-docs }}
59+
run-hypothesis: ${{ steps.check.outputs.run-hypothesis }}
60+
run-tests: ${{ steps.check.outputs.run-tests }}
61+
run-win-msi: ${{ steps.win-msi-changes.outputs.run-win-msi }}
62+
steps:
63+
- run: >-
64+
echo '${{ github.event_name }}'
65+
- uses: actions/checkout@v4
66+
- name: Check for source changes
67+
id: check
68+
run: |
69+
if [ -z "$GITHUB_BASE_REF" ]; then
70+
echo "run-tests=true" >> $GITHUB_OUTPUT
71+
else
72+
git fetch origin $GITHUB_BASE_REF --depth=1
73+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
74+
# reliable than git diff "origin/$GITHUB_BASE_REF.." (2 dots),
75+
# but it requires to download more commits (this job uses
76+
# "git fetch --depth=1").
77+
#
78+
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) works with Git
79+
# 2.26, but Git 2.28 is stricter and fails with "no merge base".
80+
#
81+
# git diff "origin/$GITHUB_BASE_REF.." (2 dots) should be enough on
82+
# GitHub, since GitHub starts by merging origin/$GITHUB_BASE_REF
83+
# into the PR branch anyway.
84+
#
85+
# https://github.com/python/core-workflow/issues/373
86+
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc|^\.pre-commit-config\.yaml$|\.ruff\.toml$|\.md$|mypy\.ini$)' && echo "run-tests=true" >> $GITHUB_OUTPUT || true
87+
fi
88+
89+
# Check if we should run hypothesis tests
90+
GIT_BRANCH=${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}
91+
echo $GIT_BRANCH
92+
if $(echo "$GIT_BRANCH" | grep -q -w '3\.\(8\|9\|10\|11\)'); then
93+
echo "Branch too old for hypothesis tests"
94+
echo "run-hypothesis=false" >> $GITHUB_OUTPUT
95+
else
96+
echo "Run hypothesis tests"
97+
echo "run-hypothesis=true" >> $GITHUB_OUTPUT
98+
fi
99+
100+
# oss-fuzz maintains a configuration for fuzzing the main branch of
101+
# CPython, so CIFuzz should be run only for code that is likely to be
102+
# merged into the main branch; compatibility with older branches may
103+
# be broken.
104+
FUZZ_RELEVANT_FILES='(\.c$|\.h$|\.cpp$|^configure$|^\.github/workflows/build\.yml$|^Modules/_xxtestfuzz)'
105+
if [ "$GITHUB_BASE_REF" = "main" ] && [ "$(git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE $FUZZ_RELEVANT_FILES; echo $?)" -eq 0 ]; then
106+
# The tests are pretty slow so they are executed only for PRs
107+
# changing relevant files.
108+
echo "Run CIFuzz tests"
109+
echo "run-cifuzz=true" >> $GITHUB_OUTPUT
110+
else
111+
echo "Branch too old for CIFuzz tests; or no C files were changed"
112+
echo "run-cifuzz=false" >> $GITHUB_OUTPUT
113+
fi
114+
- name: Compute hash for config cache key
115+
id: config-hash
116+
run: |
117+
echo "hash=${{ hashFiles('configure', 'configure.ac', '.github/workflows/build.yml') }}" >> $GITHUB_OUTPUT
118+
- name: Get a list of the changed documentation-related files
119+
if: github.event_name == 'pull_request'
120+
id: changed-docs-files
121+
uses: Ana06/[email protected]
122+
with:
123+
filter: |
124+
Doc/**
125+
Misc/**
126+
.github/workflows/reusable-docs.yml
127+
format: csv # works for paths with spaces
128+
- name: Check for docs changes
129+
if: >-
130+
github.event_name == 'pull_request'
131+
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
132+
id: docs-changes
133+
run: |
134+
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
135+
- name: Get a list of the MSI installer-related files
136+
id: changed-win-msi-files
137+
uses: Ana06/[email protected]
138+
with:
139+
filter: |
140+
Tools/msi/**
141+
.github/workflows/reusable-windows-msi.yml
142+
format: csv # works for paths with spaces
143+
- name: Check for changes in MSI installer-related files
144+
if: >-
145+
steps.changed-win-msi-files.outputs.added_modified_renamed != ''
146+
id: win-msi-changes
147+
run: |
148+
echo "run-win-msi=true" >> "${GITHUB_OUTPUT}"
149+
150+
...

.github/workflows/reusable-macos.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,22 @@ on:
88
required: false
99
type: boolean
1010
default: false
11-
os-matrix:
12-
required: false
11+
os:
12+
description: OS to run the job
13+
required: true
1314
type: string
1415

1516
jobs:
1617
build_macos:
17-
name: build and test (${{ matrix.os }})
18+
name: build and test (${{ inputs.os }})
1819
timeout-minutes: 60
1920
env:
2021
HOMEBREW_NO_ANALYTICS: 1
2122
HOMEBREW_NO_AUTO_UPDATE: 1
2223
HOMEBREW_NO_INSTALL_CLEANUP: 1
2324
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
2425
PYTHONSTRICTEXTENSIONBUILD: 1
25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
os: ${{fromJson(inputs.os-matrix)}}
29-
is-fork:
30-
- ${{ github.repository_owner != 'python' }}
31-
exclude:
32-
- os: "ghcr.io/cirruslabs/macos-runner:sonoma"
33-
is-fork: true
34-
- os: "macos-14"
35-
is-fork: false
36-
runs-on: ${{ matrix.os }}
26+
runs-on: ${{ inputs.os }}
3727
steps:
3828
- uses: actions/checkout@v4
3929
- name: Runner image version
@@ -42,7 +32,7 @@ jobs:
4232
uses: actions/cache@v4
4333
with:
4434
path: config.cache
45-
key: ${{ github.job }}-${{ matrix.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
35+
key: ${{ github.job }}-${{ inputs.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}
4636
- name: Install Homebrew dependencies
4737
run: brew install pkg-config [email protected] xz gdbm tcl-tk
4838
- name: Configure CPython

.readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sphinx:
88
configuration: Doc/conf.py
99

1010
build:
11-
os: ubuntu-22.04
11+
os: ubuntu-24.04
1212
tools:
1313
python: "3"
1414

0 commit comments

Comments
 (0)