Skip to content

Commit

Permalink
Support for Python 3.13. (#319)
Browse files Browse the repository at this point in the history
A continuation of the wonderful work by @kpfleming in #264

Adds initial support for Python 3.13 using CPython 3.13.0rc1.

There are a few caveats and interesting details:

- BOLT is disabled. There's a segmentation fault in the tests with the BOLT instrumented binaries. The BOLT optimizations are not critical, so we'll follow up on this separately. [See more context](zanieb#6 (comment)).
- `mpdecimal` is now built from source on Windows. We already did this in Unix builds, but in Windows we were still using the bundled library. The bundled library is no longer used upstream and it seemed prudent to switch though it will remain available until 3.15. [See more context](zanieb#6 (comment)).
- Apple cross-compilation is not available. I have a patch that adds support, but need to test it and it's not needed for these builds. [See more context](zanieb@447fb86).
- `run_tests.py` was removed upstream. We provide a compatibility script that calls the appropriate command still so that our distributions are stable. We may want to change how `run_tests.py` is declared in the distribution metadata though. [See more context](#319 (comment)) .
  • Loading branch information
zanieb committed Sep 6, 2024
1 parent b064e44 commit 483e6a4
Show file tree
Hide file tree
Showing 20 changed files with 587 additions and 32 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ jobs:
py: 'cpython-3.12'
optimizations: 'pgo+lto'

- target_triple: 'aarch64-apple-darwin'
runner: macos-14
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'aarch64-apple-darwin'
runner: macos-14
py: 'cpython-3.13'
optimizations: 'pgo'
- target_triple: 'aarch64-apple-darwin'
runner: macos-14
py: 'cpython-3.13'
optimizations: 'pgo+lto'

# macOS on Intel hardware. This is pretty straightforward. We exclude
# noopt because it doesn't provide any compelling advantages over PGO
# or LTO builds.
Expand Down Expand Up @@ -181,6 +194,19 @@ jobs:
runner: macos-13
py: 'cpython-3.12'
optimizations: 'pgo+lto'

- target_triple: 'x86_64-apple-darwin'
runner: macos-13
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'x86_64-apple-darwin'
runner: macos-13
py: 'cpython-3.13'
optimizations: 'pgo'
- target_triple: 'x86_64-apple-darwin'
runner: macos-13
py: 'cpython-3.13'
optimizations: 'pgo+lto'
needs:
- pythonbuild
runs-on: ${{ matrix.build.runner }}
Expand Down
168 changes: 168 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'aarch64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.9'
Expand Down Expand Up @@ -216,6 +226,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'armv7-unknown-linux-gnueabi'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.9'
Expand Down Expand Up @@ -257,6 +277,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'armv7-unknown-linux-gnueabihf'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -298,6 +328,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'mips-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -339,6 +379,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'mipsel-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -380,6 +430,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 's390x-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# Cross-compiles can't do PGO and require Python 3.9.
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -421,6 +481,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'ppc64le-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# We don't publish noopt builds when PGO is available.
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.8'
Expand Down Expand Up @@ -487,6 +557,19 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -539,6 +622,19 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64_v2-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -591,6 +687,19 @@ jobs:
optimizations: 'pgo+lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo'
run: true
- target_triple: 'x86_64_v3-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'pgo+lto'
run: true

# GitHub Actions runners don't support x86-64-v4 so we can't PGO.
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.9'
Expand Down Expand Up @@ -633,6 +742,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'x86_64_v4-unknown-linux-gnu'
py: 'cpython-3.13'
optimizations: 'lto'

# musl doesn't support PGO.
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.8'
Expand Down Expand Up @@ -699,6 +818,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -751,6 +883,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64_v2-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -803,6 +948,19 @@ jobs:
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'debug'
run: true
- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'noopt'
run: true
- target_triple: 'x86_64_v3-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'lto'
run: true

- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.9'
optimizations: 'debug'
Expand Down Expand Up @@ -843,6 +1001,16 @@ jobs:
py: 'cpython-3.12'
optimizations: 'lto'

- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'debug'
- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'noopt'
- target_triple: 'x86_64_v4-unknown-linux-musl'
py: 'cpython-3.13'
optimizations: 'lto'

needs:
- pythonbuild
- image
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
- 'cpython-3.10'
- 'cpython-3.11'
- 'cpython-3.12'
- 'cpython-3.13'
vcvars:
- 'vcvars32.bat'
- 'vcvars64.bat'
Expand Down
5 changes: 5 additions & 0 deletions cpython-unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ $(OUTDIR)/cpython-3.11-$(CPYTHON_3.11_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HO
$(OUTDIR)/cpython-3.12-$(CPYTHON_3.12_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HOST_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.12-host

$(OUTDIR)/cpython-3.13-$(CPYTHON_3.13_VERSION)-$(HOST_PLATFORM).tar: $(PYTHON_HOST_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.13-host

PYTHON_DEPENDS := \
$(PYTHON_SUPPORT_FILES) \
Expand Down Expand Up @@ -318,3 +320,6 @@ $(OUTDIR)/cpython-$(CPYTHON_3.11_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DE

$(OUTDIR)/cpython-$(CPYTHON_3.12_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.12

$(OUTDIR)/cpython-$(CPYTHON_3.13_VERSION)-$(PACKAGE_SUFFIX).tar: $(ALL_PYTHON_DEPENDS)
$(RUN_BUILD) --docker-image $(DOCKER_IMAGE_BUILD) cpython-3.13
9 changes: 8 additions & 1 deletion cpython-unix/build-cpython-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ pushd "Python-${PYTHON_VERSION}"
# configure. This is reported as https://bugs.python.org/issue45405. We nerf the
# check since we know what we're doing.
if [ "${CC}" = "clang" ]; then
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_9}" ]; then
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then
patch -p1 -i ${ROOT}/patch-disable-multiarch-13.patch
elif [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_9}" ]; then
patch -p1 -i ${ROOT}/patch-disable-multiarch.patch
else
patch -p1 -i ${ROOT}/patch-disable-multiarch-legacy.patch
fi
elif [ "${CC}" = "musl-clang" ]; then
# Similarly, this is a problem for musl Clang on Python 3.13+
if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then
patch -p1 -i ${ROOT}/patch-disable-multiarch-13.patch
fi
fi

autoconf
Expand Down
Loading

0 comments on commit 483e6a4

Please sign in to comment.