https://github.com/python/cpython/commit/ca6dfa0f31132c80aaad40855087c2d931dc2d0f
commit: ca6dfa0f31132c80aaad40855087c2d931dc2d0f
branch: main
author: Russell Keith-Magee <[email protected]>
committer: freakboy3742 <[email protected]>
date: 2026-03-27T05:54:03+08:00
summary:

gh-146446: Miscellaneous improvements to iOS XCframework build script (#146447)

Modifies the iOS build script so that the clean target is more selective about
what is cleaned, the test target has a valid fallback value for ci mode, and the
cross-build directory can be customised.

files:
A Misc/NEWS.d/next/Build/2026-03-26-12-48-42.gh-issue-146446.0GyMu4.rst
M Apple/__main__.py

diff --git a/Apple/__main__.py b/Apple/__main__.py
index 85b016dd08acb7..c19108c8e389b5 100644
--- a/Apple/__main__.py
+++ b/Apple/__main__.py
@@ -173,8 +173,11 @@ def all_host_triples(platform: str) -> list[str]:
     return triples
 
 
-def clean(context: argparse.Namespace, target: str = "all") -> None:
+def clean(context: argparse.Namespace, target: str | None = None) -> None:
     """The implementation of the "clean" command."""
+    if target is None:
+        target = context.host
+
     # If we're explicitly targeting the build, there's no platform or
     # distribution artefacts. If we're cleaning tests, we keep all built
     # artefacts. Otherwise, the built artefacts must be dirty, so we remove
@@ -377,7 +380,12 @@ def configure_host_python(
     with group(f"Downloading dependencies ({host})"):
         if not prefix_dir.exists():
             prefix_dir.mkdir()
-            unpack_deps(context.platform, host, prefix_dir, context.cache_dir)
+            cache_dir = (
+                Path(context.cache_dir).resolve()
+                if context.cache_dir
+                else CROSS_BUILD_DIR / "downloads"
+            )
+            unpack_deps(context.platform, host, prefix_dir, cache_dir)
         else:
             print("Dependencies already installed")
 
@@ -828,7 +836,7 @@ def test(context: argparse.Namespace, host: str | None = 
None) -> None:  # noqa:
             + [
                 "--",
                 "test",
-                f"--{context.ci_mode}-ci",
+                f"--{context.ci_mode or 'fast'}-ci",
                 "--single-process",
                 "--no-randomize",
                 "--pythoninfo",
@@ -895,7 +903,7 @@ def parse_args() -> argparse.Namespace:
     configure_build = subcommands.add_parser(
         "configure-build", help="Run `configure` for the build Python"
     )
-    subcommands.add_parser(
+    make_build = subcommands.add_parser(
         "make-build", help="Run `make` for the build Python"
     )
     configure_host = subcommands.add_parser(
@@ -951,6 +959,31 @@ def parse_args() -> argparse.Namespace:
             ),
         )
 
+    # --cross-build-dir argument
+    for cmd in [
+        clean,
+        configure_build,
+        make_build,
+        configure_host,
+        make_host,
+        build,
+        package,
+        test,
+        ci,
+    ]:
+        cmd.add_argument(
+            "--cross-build-dir",
+            action="store",
+            default=os.environ.get("CROSS_BUILD_DIR"),
+            dest="cross_build_dir",
+            type=Path,
+            help=(
+                "Path to the cross-build directory "
+                f"(default: {CROSS_BUILD_DIR}). Can also be set "
+                "with the CROSS_BUILD_DIR environment variable."
+            ),
+        )
+
     # --clean option
     for cmd in [configure_build, configure_host, build, package, test, ci]:
         cmd.add_argument(
@@ -965,7 +998,7 @@ def parse_args() -> argparse.Namespace:
     for cmd in [configure_host, build, ci]:
         cmd.add_argument(
             "--cache-dir",
-            default="./cross-build/downloads",
+            default=os.environ.get("CACHE_DIR"),
             help="The directory to store cached downloads.",
         )
 
@@ -1032,6 +1065,12 @@ def signal_handler(*args):
 
     # Process command line arguments
     context = parse_args()
+
+    # Set the CROSS_BUILD_DIR if an argument was provided
+    if context.cross_build_dir:
+        global CROSS_BUILD_DIR
+        CROSS_BUILD_DIR = context.cross_build_dir.resolve()
+
     dispatch: dict[str, Callable] = {
         "clean": clean,
         "configure-build": configure_build_python,
diff --git 
a/Misc/NEWS.d/next/Build/2026-03-26-12-48-42.gh-issue-146446.0GyMu4.rst 
b/Misc/NEWS.d/next/Build/2026-03-26-12-48-42.gh-issue-146446.0GyMu4.rst
new file mode 100644
index 00000000000000..40795650b53cbf
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-03-26-12-48-42.gh-issue-146446.0GyMu4.rst
@@ -0,0 +1,2 @@
+The clean target for the Apple/iOS XCframework build script is now more
+selective when targeting a single architecture.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to