From 1816d86b2dbb257887a98e67a3e7148372c2a5dc Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Fri, 10 Apr 2026 19:04:27 +0100 Subject: [PATCH] Update Android to Python 3.13.13 and 3.14.4 --- .pre-commit-config.yaml | 3 ++- cibuildwheel/platforms/android.py | 11 +++++++++-- cibuildwheel/resources/{ => android}/_cross_venv.pth | 0 cibuildwheel/resources/{ => android}/_cross_venv.py | 0 cibuildwheel/resources/android/android.patch | 11 +++++++++++ .../resources/{_rust_shim.py => android/rust_shim.py} | 0 cibuildwheel/resources/build-platforms.toml | 8 ++++---- 7 files changed, 26 insertions(+), 7 deletions(-) rename cibuildwheel/resources/{ => android}/_cross_venv.pth (100%) rename cibuildwheel/resources/{ => android}/_cross_venv.py (100%) create mode 100644 cibuildwheel/resources/android/android.patch rename cibuildwheel/resources/{_rust_shim.py => android/rust_shim.py} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 446af7443..3ea873dc3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,6 +14,7 @@ repos: exclude: (cibuildwheel/resources/pinned_docker_images.cfg)|(.svg$) - id: mixed-line-ending - id: trailing-whitespace + exclude: ^cibuildwheel/resources/android/android.patch$ - repo: https://github.com/astral-sh/ruff-pre-commit rev: c60c980e561ed3e73101667fe8365c609d19a438 # frozen: v0.15.9 @@ -28,7 +29,7 @@ repos: - id: mypy name: mypy 3.11 on cibuildwheel/ args: ["--python-version=3.11"] - exclude: ^cibuildwheel/resources/_cross_venv.py$ # Requires Python 3.13 or later + exclude: ^cibuildwheel/resources/android/_cross_venv.py$ # Requires Python 3.13 or later additional_dependencies: &mypy-dependencies - bracex - build diff --git a/cibuildwheel/platforms/android.py b/cibuildwheel/platforms/android.py index 73ffb4eda..50b07884c 100644 --- a/cibuildwheel/platforms/android.py +++ b/cibuildwheel/platforms/android.py @@ -36,6 +36,8 @@ from cibuildwheel.util.python_build_standalone import create_python_build_standalone_environment from cibuildwheel.venv import constraint_flags, find_uv, virtualenv +RESOURCES_ANDROID = resources.PATH / "android" + ANDROID_TRIPLET = { "arm64_v8a": "aarch64-linux-android", "x86_64": "x86_64-linux-android", @@ -176,6 +178,11 @@ def setup_target_python(config: PythonConfiguration, build_path: Path) -> Path: python_dir = build_path / "python" python_dir.mkdir() shutil.unpack_archive(python_tgz, python_dir) + + # Patch a testbed bug. This code and the patch file can both be removed once we've + # updated to Python versions that include the fix. + call("patch", "-p1", "-i", RESOURCES_ANDROID / "android.patch", cwd=python_dir) + return python_dir @@ -350,7 +357,7 @@ def setup_android_env( ) -> dict[str, str]: site_packages = next(venv_dir.glob("lib/python*/site-packages")) for suffix in ["pth", "py"]: - shutil.copy(resources.PATH / f"_cross_venv.{suffix}", site_packages) + shutil.copy(RESOURCES_ANDROID / f"_cross_venv.{suffix}", site_packages) sysconfigdata_path = Path( shutil.copy( @@ -425,7 +432,7 @@ def setup_rust( venv_bin = Path(env["VIRTUAL_ENV"]) / "bin" for tool in ["cargo", "rustup"]: shim_path = venv_bin / tool - shutil.copy(resources.PATH / "_rust_shim.py", shim_path) + shutil.copy(RESOURCES_ANDROID / "rust_shim.py", shim_path) shim_path.chmod(0o755) diff --git a/cibuildwheel/resources/_cross_venv.pth b/cibuildwheel/resources/android/_cross_venv.pth similarity index 100% rename from cibuildwheel/resources/_cross_venv.pth rename to cibuildwheel/resources/android/_cross_venv.pth diff --git a/cibuildwheel/resources/_cross_venv.py b/cibuildwheel/resources/android/_cross_venv.py similarity index 100% rename from cibuildwheel/resources/_cross_venv.py rename to cibuildwheel/resources/android/_cross_venv.py diff --git a/cibuildwheel/resources/android/android.patch b/cibuildwheel/resources/android/android.patch new file mode 100644 index 000000000..f2d6ff984 --- /dev/null +++ b/cibuildwheel/resources/android/android.patch @@ -0,0 +1,11 @@ +--- a/android.py ++++ b/android.py +@@ -1021,7 +1021,7 @@ def main(): + context = parse_args() + + # Set the CROSS_BUILD_DIR if an argument was provided +- if context.cross_build_dir: ++ if getattr(context, "cross_build_dir", None): + global CROSS_BUILD_DIR + CROSS_BUILD_DIR = context.cross_build_dir.resolve() + diff --git a/cibuildwheel/resources/_rust_shim.py b/cibuildwheel/resources/android/rust_shim.py similarity index 100% rename from cibuildwheel/resources/_rust_shim.py rename to cibuildwheel/resources/android/rust_shim.py diff --git a/cibuildwheel/resources/build-platforms.toml b/cibuildwheel/resources/build-platforms.toml index f75627ada..bad0802e0 100644 --- a/cibuildwheel/resources/build-platforms.toml +++ b/cibuildwheel/resources/build-platforms.toml @@ -231,10 +231,10 @@ python_configurations = [ [android] python_configurations = [ - { identifier = "cp313-android_arm64_v8a", version = "3.13", url = "https://repo.maven.apache.org/maven2/com/chaquo/python/python/3.13.12/python-3.13.12-aarch64-linux-android.tar.gz" }, - { identifier = "cp313-android_x86_64", version = "3.13", url = "https://repo.maven.apache.org/maven2/com/chaquo/python/python/3.13.12/python-3.13.12-x86_64-linux-android.tar.gz" }, - { identifier = "cp314-android_arm64_v8a", version = "3.14", url = "https://www.python.org/ftp/python/3.14.3/python-3.14.3-aarch64-linux-android.tar.gz" }, - { identifier = "cp314-android_x86_64", version = "3.14", url = "https://www.python.org/ftp/python/3.14.3/python-3.14.3-x86_64-linux-android.tar.gz" }, + { identifier = "cp313-android_arm64_v8a", version = "3.13", url = "https://repo.maven.apache.org/maven2/com/chaquo/python/python/3.13.13/python-3.13.13-aarch64-linux-android.tar.gz" }, + { identifier = "cp313-android_x86_64", version = "3.13", url = "https://repo.maven.apache.org/maven2/com/chaquo/python/python/3.13.13/python-3.13.13-x86_64-linux-android.tar.gz" }, + { identifier = "cp314-android_arm64_v8a", version = "3.14", url = "https://www.python.org/ftp/python/3.14.4/python-3.14.4-aarch64-linux-android.tar.gz" }, + { identifier = "cp314-android_x86_64", version = "3.14", url = "https://www.python.org/ftp/python/3.14.4/python-3.14.4-x86_64-linux-android.tar.gz" }, ] [ios]