Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions ci-targets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ darwin:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -28,6 +29,7 @@ darwin:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -48,6 +50,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -67,6 +70,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- noopt
Expand All @@ -88,6 +92,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- noopt
Expand All @@ -109,6 +114,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- noopt
Expand All @@ -130,6 +136,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- noopt
Expand All @@ -151,6 +158,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- noopt
Expand All @@ -172,6 +180,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -193,6 +202,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -214,6 +224,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -235,6 +246,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug
- pgo+lto
Expand All @@ -255,6 +267,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug+static
- noopt+static
Expand All @@ -281,6 +294,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug+static
- noopt+static
Expand All @@ -307,6 +321,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug+static
- noopt+static
Expand All @@ -333,6 +348,7 @@ linux:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- debug+static
- noopt+static
Expand Down Expand Up @@ -385,6 +401,7 @@ windows:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- pgo
build_options_conditional:
Expand All @@ -402,6 +419,7 @@ windows:
- "3.12"
- "3.13"
- "3.14"
- "3.15"
build_options:
- pgo
build_options_conditional:
Expand Down
2 changes: 1 addition & 1 deletion cpython-unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BUILD := $(HERE)/build.py
NULL :=
SPACE := $(subst ,, )

ALL_PYTHON_VERSIONS := 3.9 3.10 3.11 3.12 3.13 3.14
ALL_PYTHON_VERSIONS := 3.9 3.10 3.11 3.12 3.13 3.14 3.15

ifndef PYBUILD_TARGET_TRIPLE
$(error PYBUILD_TARGET_TRIPLE not defined)
Expand Down
22 changes: 19 additions & 3 deletions cpython-unix/build-cpython.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,13 @@ if [ -n "${CPYTHON_OPTIMIZED}" ]; then
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.13.patch"
fi

if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" ]]; then
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" && -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_14}" ]]; then
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.14.patch"
fi

if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_15}" ]]; then
patch -p1 -i "${ROOT}/patch-jit-llvm-version-3.15.patch"
fi
fi
fi

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

# Define the base PGO profiling task, which we'll extend below with ignores
export PROFILE_TASK='-m test --pgo'

# On 3.14+ `test_strftime_y2k` fails when cross-compiling for `x86_64_v2` and `x86_64_v3` targets on
# Linux, so we ignore it. See https://github.com/python/cpython/issues/128104
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_14}" && -n "${CROSS_COMPILING}" && "${PYBUILD_PLATFORM}" != macos* ]]; then
export PROFILE_TASK='-m test --pgo --ignore test_strftime_y2k'
PROFILE_TASK="${PROFILE_TASK} --ignore test_strftime_y2k"
fi

# On 3.15+ `test_json.test_recursion.TestCRecursion.test_highly_nested_objects_decoding` fails during
# PGO due to RecursionError not being raised as expected. See https://github.com/python/cpython/issues/140125
if [[ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_15}" ]]; then
PROFILE_TASK="${PROFILE_TASK} --ignore test_json"
fi

# ./configure tries to auto-detect whether it can build 128-bit and 256-bit SIMD helpers for HACL,
Expand Down Expand Up @@ -865,7 +878,10 @@ fi
# It is possible for the Python interpreter to run wheels directly. So we
# simply use our pip to install self. Kinda crazy, but it works!

${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${PIP_WHEEL}"
# The pip wheel segfaults on 3.15+ at this time, only install it on stable versions.
if [ -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_14}" ]; then
${BUILD_PYTHON} "${PIP_WHEEL}/pip" install --prefix="${ROOT}/out/python/install" --no-cache-dir --no-index "${PIP_WHEEL}"
fi

# Setuptools is only installed for Python 3.11 and older, for parity with
# `ensurepip` and `venv`: https://github.com/python/cpython/pull/101039
Expand Down
1 change: 1 addition & 0 deletions cpython-unix/build-main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def main():
"cpython-3.12",
"cpython-3.13",
"cpython-3.14",
"cpython-3.15",
},
default="cpython-3.11",
help="Python distribution to build",
Expand Down
47 changes: 40 additions & 7 deletions cpython-unix/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,23 @@ def build_cpython_host(
target_triple: str,
build_options: list[str],
dest_archive,
python_source=None,
entry_name=None,
Comment on lines +396 to +397
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit: at least one of these is required and in practice we seem to pass entry_name unconditionally. Can we do

Suggested change
python_source=None,
entry_name=None,
entry_name: str,
python_source: str | None = None,

):
"""Build binutils in the Docker image."""
archive = download_entry(entry, DOWNLOADS_PATH)
if not python_source:
python_version = entry["version"]
archive = download_entry(entry_name, DOWNLOADS_PATH)
else:
python_version = os.environ["PYBUILD_PYTHON_VERSION"]
archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
print("Compressing %s to %s" % (python_source, archive))
with archive.open("wb") as fh:
create_tar_from_directory(
fh, python_source, path_prefix="Python-%s" % python_version
)
Comment on lines +400 to +410
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes in here from my initial exploration of making 3.15 build from a source tree instead of a download entry. They're minor and fix bugs, so I think it's fine to leave them in.


with build_environment(client, image) as build_env:
python_version = DOWNLOADS[entry]["version"]

build_env.install_toolchain(
BUILD,
host_platform,
Expand Down Expand Up @@ -434,7 +444,7 @@ def build_cpython_host(

# Set environment variables allowing convenient testing for Python
# version ranges.
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"):
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"):
normal_version = v.replace(".", "_")

if meets_python_minimum_version(python_version, v):
Expand Down Expand Up @@ -706,12 +716,15 @@ def build_cpython(
"""Build CPython in a Docker image'"""
parsed_build_options = set(build_options.split("+"))
entry_name = "cpython-%s" % version
entry = DOWNLOADS[entry_name]
if not python_source:
entry = DOWNLOADS[entry_name]
python_version = entry["version"]
python_archive = download_entry(entry_name, DOWNLOADS_PATH)
else:
entry = DOWNLOADS.get(entry_name, {})
python_version = os.environ["PYBUILD_PYTHON_VERSION"]
entry.setdefault("licenses", ["Python-2.0", "CNRI-Python"])
entry.setdefault("python_tag", "cp" + "".join(version.split(".")))
python_archive = DOWNLOADS_PATH / ("Python-%s.tar.xz" % python_version)
print("Compressing %s to %s" % (python_source, python_archive))
with python_archive.open("wb") as fh:
Expand Down Expand Up @@ -804,7 +817,7 @@ def build_cpython(

# Set environment variables allowing convenient testing for Python
# version ranges.
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14"):
for v in ("3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"):
normal_version = v.replace(".", "_")

if meets_python_minimum_version(python_version, v):
Expand Down Expand Up @@ -1024,6 +1037,18 @@ def main():
log_name = "%s-%s" % (action, host_platform)
elif args.action.startswith("cpython-") and args.action.endswith("-host"):
log_name = args.action
elif action.startswith("cpython-"):
version = (
os.environ["PYBUILD_PYTHON_VERSION"]
if python_source
else DOWNLOADS[action]["version"]
)
log_name = "%s-%s-%s-%s" % (
action,
version,
target_triple,
build_options,
)
else:
entry = DOWNLOADS[action]
log_name = "%s-%s-%s-%s" % (
Expand Down Expand Up @@ -1229,14 +1254,21 @@ def main():
)

elif action.startswith("cpython-") and action.endswith("-host"):
entry_name = action[:-5]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
entry_name = action[:-5]
entry_name = action.removesuffix("-host")

if not python_source:
entry = DOWNLOADS[entry_name]
else:
entry = DOWNLOADS.get(entry_name, {})
build_cpython_host(
client,
get_image(client, ROOT, BUILD, docker_image, host_platform),
action[:-5],
entry,
host_platform=host_platform,
target_triple=target_triple,
build_options=build_options,
dest_archive=dest_archive,
python_source=python_source,
entry_name=entry_name,
)

elif action in (
Expand All @@ -1246,6 +1278,7 @@ def main():
"cpython-3.12",
"cpython-3.13",
"cpython-3.14",
"cpython-3.15",
):
build_cpython(
settings,
Expand Down
12 changes: 12 additions & 0 deletions cpython-unix/patch-jit-llvm-version-3.15.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/Tools/jit/_llvm.py b/Tools/jit/_llvm.py
--- a/Tools/jit/_llvm.py
+++ b/Tools/jit/_llvm.py
@@ -11,7 +11,7 @@
import _targets


-_LLVM_VERSION = "19"
+_LLVM_VERSION = "20"
_EXTERNALS_LLVM_TAG = "llvm-19.1.7.0"


Loading
Loading