Skip to content

Commit a4eb9b3

Browse files
authored
Add support for Python 3.15 (#819)
1 parent 5cfcffd commit a4eb9b3

File tree

11 files changed

+161
-19
lines changed

11 files changed

+161
-19
lines changed

ci-targets.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ darwin:
1010
- "3.12"
1111
- "3.13"
1212
- "3.14"
13+
- "3.15"
1314
build_options:
1415
- debug
1516
- pgo+lto
@@ -28,6 +29,7 @@ darwin:
2829
- "3.12"
2930
- "3.13"
3031
- "3.14"
32+
- "3.15"
3133
build_options:
3234
- debug
3335
- pgo+lto
@@ -48,6 +50,7 @@ linux:
4850
- "3.12"
4951
- "3.13"
5052
- "3.14"
53+
- "3.15"
5154
build_options:
5255
- debug
5356
- pgo+lto
@@ -67,6 +70,7 @@ linux:
6770
- "3.12"
6871
- "3.13"
6972
- "3.14"
73+
- "3.15"
7074
build_options:
7175
- debug
7276
- noopt
@@ -88,6 +92,7 @@ linux:
8892
- "3.12"
8993
- "3.13"
9094
- "3.14"
95+
- "3.15"
9196
build_options:
9297
- debug
9398
- noopt
@@ -109,6 +114,7 @@ linux:
109114
- "3.12"
110115
- "3.13"
111116
- "3.14"
117+
- "3.15"
112118
build_options:
113119
- debug
114120
- noopt
@@ -130,6 +136,7 @@ linux:
130136
- "3.12"
131137
- "3.13"
132138
- "3.14"
139+
- "3.15"
133140
build_options:
134141
- debug
135142
- noopt
@@ -151,6 +158,7 @@ linux:
151158
- "3.12"
152159
- "3.13"
153160
- "3.14"
161+
- "3.15"
154162
build_options:
155163
- debug
156164
- noopt
@@ -172,6 +180,7 @@ linux:
172180
- "3.12"
173181
- "3.13"
174182
- "3.14"
183+
- "3.15"
175184
build_options:
176185
- debug
177186
- pgo+lto
@@ -193,6 +202,7 @@ linux:
193202
- "3.12"
194203
- "3.13"
195204
- "3.14"
205+
- "3.15"
196206
build_options:
197207
- debug
198208
- pgo+lto
@@ -214,6 +224,7 @@ linux:
214224
- "3.12"
215225
- "3.13"
216226
- "3.14"
227+
- "3.15"
217228
build_options:
218229
- debug
219230
- pgo+lto
@@ -235,6 +246,7 @@ linux:
235246
- "3.12"
236247
- "3.13"
237248
- "3.14"
249+
- "3.15"
238250
build_options:
239251
- debug
240252
- pgo+lto
@@ -255,6 +267,7 @@ linux:
255267
- "3.12"
256268
- "3.13"
257269
- "3.14"
270+
- "3.15"
258271
build_options:
259272
- debug+static
260273
- noopt+static
@@ -281,6 +294,7 @@ linux:
281294
- "3.12"
282295
- "3.13"
283296
- "3.14"
297+
- "3.15"
284298
build_options:
285299
- debug+static
286300
- noopt+static
@@ -307,6 +321,7 @@ linux:
307321
- "3.12"
308322
- "3.13"
309323
- "3.14"
324+
- "3.15"
310325
build_options:
311326
- debug+static
312327
- noopt+static
@@ -333,6 +348,7 @@ linux:
333348
- "3.12"
334349
- "3.13"
335350
- "3.14"
351+
- "3.15"
336352
build_options:
337353
- debug+static
338354
- noopt+static
@@ -385,6 +401,7 @@ windows:
385401
- "3.12"
386402
- "3.13"
387403
- "3.14"
404+
- "3.15"
388405
build_options:
389406
- pgo
390407
build_options_conditional:
@@ -402,6 +419,7 @@ windows:
402419
- "3.12"
403420
- "3.13"
404421
- "3.14"
422+
- "3.15"
405423
build_options:
406424
- pgo
407425
build_options_conditional:

cpython-unix/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BUILD := $(HERE)/build.py
66
NULL :=
77
SPACE := $(subst ,, )
88

9-
ALL_PYTHON_VERSIONS := 3.9 3.10 3.11 3.12 3.13 3.14
9+
ALL_PYTHON_VERSIONS := 3.9 3.10 3.11 3.12 3.13 3.14 3.15
1010

1111
ifndef PYBUILD_TARGET_TRIPLE
1212
$(error PYBUILD_TARGET_TRIPLE not defined)

cpython-unix/build-cpython.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,13 @@ if [ -n "${CPYTHON_OPTIMIZED}" ]; then
512512
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.13.patch"
513513
fi
514514

515-
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]]; then
515+
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" && -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_14}" ]]; then
516516
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.14.patch"
517517
fi
518+
519+
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_15}" ]]; then
520+
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.15.patch"
521+
fi
518522
fi
519523
fi
520524

@@ -609,10 +613,19 @@ if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]; then
609613
CONFIGURE_FLAGS="${CONFIGURE_FLAGS} ac_cv_func_explicit_bzero=no"
610614
fi
611615

616+
# Define the base PGO profiling task, which we'll extend below with ignores
617+
export PROFILE_TASK='-m test --pgo'
618+
612619
# On 3.14+ `test_strftime_y2k` fails when cross-compiling for `x86_64_v2` and `x86_64_v3` targets on
613620
# Linux, so we ignore it. See https://github.com/python/cpython/issues/128104
614621
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" && -n "${CROSS_COMPILING}" && "${PYBUILD_PLATFORM}" != macos* ]]; then
615-
export PROFILE_TASK='-m test --pgo --ignore test_strftime_y2k'
622+
PROFILE_TASK="${PROFILE_TASK} --ignore test_strftime_y2k"
623+
fi
624+
625+
# On 3.15+ `test_json.test_recursion.TestCRecursion.test_highly_nested_objects_decoding` fails during
626+
# PGO due to RecursionError not being raised as expected. See https://github.com/python/cpython/issues/140125
627+
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_15}" ]]; then
628+
PROFILE_TASK="${PROFILE_TASK} --ignore test_json"
616629
fi
617630

618631
# ./configure tries to auto-detect whether it can build 128-bit and 256-bit SIMD helpers for HACL,

cpython-unix/build-main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def main():
6161
"cpython-3.12",
6262
"cpython-3.13",
6363
"cpython-3.14",
64+
"cpython-3.15",
6465
},
6566
default="cpython-3.11",
6667
help="Python distribution to build",

cpython-unix/build.py

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,23 @@ def build_cpython_host(
393393
target_triple: str,
394394
build_options: list[str],
395395
dest_archive,
396+
python_source=None,
397+
entry_name=None,
396398
):
397399
"""Build binutils in the Docker image."""
398-
archive = download_entry(entry, DOWNLOADS_PATH)
400+
if not python_source:
401+
python_version = entry["version"]
402+
archive = download_entry(entry_name, DOWNLOADS_PATH)
403+
else:
404+
python_version = os.environ["PYBUILD_PYTHON_VERSION"]
405+
archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
406+
print("Compressing %s to %s" % (python_source, archive))
407+
with archive.open("wb") as fh:
408+
create_tar_from_directory(
409+
fh, python_source, path_prefix="Python-%s" % python_version
410+
)
399411

400412
with build_environment(client, image) as build_env:
401-
python_version = DOWNLOADS[entry]["version"]
402-
403413
build_env.install_toolchain(
404414
BUILD,
405415
host_platform,
@@ -434,7 +444,7 @@ def build_cpython_host(
434444

435445
# Set environment variables allowing convenient testing for Python
436446
# version ranges.
437-
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"):
447+
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"):
438448
normal_version = v.replace(".", "_")
439449

440450
if meets_python_minimum_version(python_version, v):
@@ -706,12 +716,15 @@ def build_cpython(
706716
"""Build CPython in a Docker image'"""
707717
parsed_build_options = set(build_options.split("+"))
708718
entry_name = "cpython-%s" % version
709-
entry = DOWNLOADS[entry_name]
710719
if not python_source:
720+
entry = DOWNLOADS[entry_name]
711721
python_version = entry["version"]
712722
python_archive = download_entry(entry_name, DOWNLOADS_PATH)
713723
else:
724+
entry = DOWNLOADS.get(entry_name, {})
714725
python_version = os.environ["PYBUILD_PYTHON_VERSION"]
726+
entry.setdefault("licenses", ["Python-2.0", "CNRI-Python"])
727+
entry.setdefault("python_tag", "cp" + "".join(version.split(".")))
715728
python_archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
716729
print("Compressing %s to %s" % (python_source, python_archive))
717730
with python_archive.open("wb") as fh:
@@ -804,7 +817,7 @@ def build_cpython(
804817

805818
# Set environment variables allowing convenient testing for Python
806819
# version ranges.
807-
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"):
820+
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"):
808821
normal_version = v.replace(".", "_")
809822

810823
if meets_python_minimum_version(python_version, v):
@@ -1024,6 +1037,18 @@ def main():
10241037
log_name = "%s-%s" % (action, host_platform)
10251038
elif args.action.startswith("cpython-") and args.action.endswith("-host"):
10261039
log_name = args.action
1040+
elif action.startswith("cpython-"):
1041+
version = (
1042+
os.environ["PYBUILD_PYTHON_VERSION"]
1043+
if python_source
1044+
else DOWNLOADS[action]["version"]
1045+
)
1046+
log_name = "%s-%s-%s-%s" % (
1047+
action,
1048+
version,
1049+
target_triple,
1050+
build_options,
1051+
)
10271052
else:
10281053
entry = DOWNLOADS[action]
10291054
log_name = "%s-%s-%s-%s" % (
@@ -1229,14 +1254,21 @@ def main():
12291254
)
12301255

12311256
elif action.startswith("cpython-") and action.endswith("-host"):
1257+
entry_name = action[:-5]
1258+
if not python_source:
1259+
entry = DOWNLOADS[entry_name]
1260+
else:
1261+
entry = DOWNLOADS.get(entry_name, {})
12321262
build_cpython_host(
12331263
client,
12341264
get_image(client, ROOT, BUILD, docker_image, host_platform),
1235-
action[:-5],
1265+
entry,
12361266
host_platform=host_platform,
12371267
target_triple=target_triple,
12381268
build_options=build_options,
12391269
dest_archive=dest_archive,
1270+
python_source=python_source,
1271+
entry_name=entry_name,
12401272
)
12411273

12421274
elif action in (
@@ -1246,6 +1278,7 @@ def main():
12461278
"cpython-3.12",
12471279
"cpython-3.13",
12481280
"cpython-3.14",
1281+
"cpython-3.15",
12491282
):
12501283
build_cpython(
12511284
settings,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py
2+
--- a/Tools/jit/_llvm.py
3+
+++ b/Tools/jit/_llvm.py
4+
@@ -11,7 +11,7 @@
5+
import _targets
6+
7+
8+
-_LLVM_VERSION = "19"
9+
+_LLVM_VERSION = "20"
10+
_EXTERNALS_LLVM_TAG = "llvm-19.1.7.0"
11+
12+

0 commit comments

Comments
 (0)