From d5e469d2611eff93833298325435a749c547eace Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 24 Nov 2025 16:03:27 -0600 Subject: [PATCH 1/2] Drop `patch-apple-cross` on 3.13+ --- cpython-unix/build-cpython.sh | 6 +- cpython-unix/patch-apple-cross-3.13.patch | 87 ----------------------- 2 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 cpython-unix/patch-apple-cross-3.13.patch diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index 333913365..e6bbc5ee2 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -59,10 +59,8 @@ cat Makefile.extra pushd Python-${PYTHON_VERSION} # configure doesn't support cross-compiling on Apple. Teach it. -if [[ "${PYBUILD_PLATFORM}" = macos* ]]; then - if [ -n "${PYTHON_MEETS_MINIMUM_VERSION_3_13}" ]; then - patch -p1 -i ${ROOT}/patch-apple-cross-3.13.patch - elif [ "${PYTHON_MAJMIN_VERSION}" = "3.12" ]; then +if [[ "${PYBUILD_PLATFORM}" = macos* && -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_12}" ]]; then + if [ "${PYTHON_MAJMIN_VERSION}" = "3.12" ]; then patch -p1 -i ${ROOT}/patch-apple-cross-3.12.patch else patch -p1 -i ${ROOT}/patch-apple-cross.patch diff --git a/cpython-unix/patch-apple-cross-3.13.patch b/cpython-unix/patch-apple-cross-3.13.patch deleted file mode 100644 index f0f05b5d3..000000000 --- a/cpython-unix/patch-apple-cross-3.13.patch +++ /dev/null @@ -1,87 +0,0 @@ -diff --git a/configure.ac b/configure.ac -index 58f54076ff2..a734260691a 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -330,6 +330,21 @@ then - *-apple-ios*) - ac_sys_system=iOS - ;; -+ *-apple-ios*) -+ ac_sys_system=iOS -+ ;; -+ *-apple-tvos*) -+ ac_sys_system=tvOS -+ ;; -+ *-apple-watchos*) -+ ac_sys_system=watchOS -+ ;; -+ *-*-darwin*) -+ ac_sys_system=Darwin -+ ;; -+ *-apple-*) -+ ac_sys_system=Darwin -+ ;; - *-*-vxworks*) - ac_sys_system=VxWorks - ;; -@@ -771,6 +786,15 @@ if test "$cross_compiling" = yes; then - ;; - esac - ;; -+ *-*-darwin*) -+ case "$host_cpu" in -+ arm*) -+ _host_ident=arm -+ ;; -+ *) -+ _host_ident=$host_cpu -+ esac -+ ;; - *-*-vxworks*) - _host_ident=$host_cpu - ;; -@@ -785,6 +809,23 @@ if test "$cross_compiling" = yes; then - _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}" - fi - -+# The _PYTHON_HOST_PLATFORM environment variable is used to -+# override the platform name in distutils and sysconfig when -+# cross-compiling. On Apple, the platform name expansion logic -+# is non-trivial, including renaming MACHDEP=darwin to macosx -+# and including the deployment target (or current OS version if -+# not set). Here we always force an override based on the target -+# triple. We do this in all build configurations because historically -+# the automatic resolution has been brittle. -+case "$host" in -+aarch64-apple-darwin*) -+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-arm64" -+ ;; -+x86_64-apple-darwin*) -+ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-x86_64" -+ ;; -+esac -+ - # Some systems cannot stand _XOPEN_SOURCE being defined at all; they - # disable features if it is defined, without any means to access these - # features as extensions. For these systems, we skip the definition of -@@ -1582,7 +1623,7 @@ if test $enable_shared = "yes"; then - BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' - RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} - ;; -- Darwin*) -+ Darwin*|iOS*|tvOS*|watchOS*) - LDLIBRARY='libpython$(LDVERSION).dylib' - BLDLIBRARY='-L. -lpython$(LDVERSION)' - RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} -@@ -3469,6 +3510,11 @@ then - Linux*|GNU*|QNX*|VxWorks*|Haiku*) - LDSHARED='$(CC) -shared' - LDCXXSHARED='$(CXX) -shared';; -+ iOS*|tvOS*|watchOS*) -+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup' -+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' -+ BLDSHARED="$LDSHARED" -+ ;; - FreeBSD*) - if [[ "`$CC -dM -E - Date: Mon, 24 Nov 2025 17:12:01 -0600 Subject: [PATCH 2/2] Drop `patch-apple-cross` on 3.14+ (#888) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Retains the `patch-apple-cross` patch for Python 3.13 but drops it for 3.14+, where the upstream configure script now supports cross-compiling on Apple. - Changed version check from `PYTHON_MEETS_MAXIMUM_VERSION_3_12` to `PYTHON_MEETS_MAXIMUM_VERSION_3_13` in `cpython-unix/build-cpython.sh` - Restored `patch-apple-cross-3.13.patch` for Python 3.13 - Updated build script to use version-specific patches: - 3.10, 3.11: `patch-apple-cross.patch` - 3.12: `patch-apple-cross-3.12.patch` - 3.13: `patch-apple-cross-3.13.patch` - 3.14+: No patch applied --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: zanieb <2586601+zanieb@users.noreply.github.com> --- cpython-unix/build-cpython.sh | 4 +- cpython-unix/patch-apple-cross-3.13.patch | 87 +++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 cpython-unix/patch-apple-cross-3.13.patch diff --git a/cpython-unix/build-cpython.sh b/cpython-unix/build-cpython.sh index e6bbc5ee2..b2b195f69 100755 --- a/cpython-unix/build-cpython.sh +++ b/cpython-unix/build-cpython.sh @@ -59,9 +59,11 @@ cat Makefile.extra pushd Python-${PYTHON_VERSION} # configure doesn't support cross-compiling on Apple. Teach it. -if [[ "${PYBUILD_PLATFORM}" = macos* && -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_12}" ]]; then +if [[ "${PYBUILD_PLATFORM}" = macos* && -n "${PYTHON_MEETS_MAXIMUM_VERSION_3_13}" ]]; then if [ "${PYTHON_MAJMIN_VERSION}" = "3.12" ]; then patch -p1 -i ${ROOT}/patch-apple-cross-3.12.patch + elif [ "${PYTHON_MAJMIN_VERSION}" = "3.13" ]; then + patch -p1 -i ${ROOT}/patch-apple-cross-3.13.patch else patch -p1 -i ${ROOT}/patch-apple-cross.patch fi diff --git a/cpython-unix/patch-apple-cross-3.13.patch b/cpython-unix/patch-apple-cross-3.13.patch new file mode 100644 index 000000000..f0f05b5d3 --- /dev/null +++ b/cpython-unix/patch-apple-cross-3.13.patch @@ -0,0 +1,87 @@ +diff --git a/configure.ac b/configure.ac +index 58f54076ff2..a734260691a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -330,6 +330,21 @@ then + *-apple-ios*) + ac_sys_system=iOS + ;; ++ *-apple-ios*) ++ ac_sys_system=iOS ++ ;; ++ *-apple-tvos*) ++ ac_sys_system=tvOS ++ ;; ++ *-apple-watchos*) ++ ac_sys_system=watchOS ++ ;; ++ *-*-darwin*) ++ ac_sys_system=Darwin ++ ;; ++ *-apple-*) ++ ac_sys_system=Darwin ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -771,6 +786,15 @@ if test "$cross_compiling" = yes; then + ;; + esac + ;; ++ *-*-darwin*) ++ case "$host_cpu" in ++ arm*) ++ _host_ident=arm ++ ;; ++ *) ++ _host_ident=$host_cpu ++ esac ++ ;; + *-*-vxworks*) + _host_ident=$host_cpu + ;; +@@ -785,6 +809,23 @@ if test "$cross_compiling" = yes; then + _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}" + fi + ++# The _PYTHON_HOST_PLATFORM environment variable is used to ++# override the platform name in distutils and sysconfig when ++# cross-compiling. On Apple, the platform name expansion logic ++# is non-trivial, including renaming MACHDEP=darwin to macosx ++# and including the deployment target (or current OS version if ++# not set). Here we always force an override based on the target ++# triple. We do this in all build configurations because historically ++# the automatic resolution has been brittle. ++case "$host" in ++aarch64-apple-darwin*) ++ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-arm64" ++ ;; ++x86_64-apple-darwin*) ++ _PYTHON_HOST_PLATFORM="macosx-${MACOSX_DEPLOYMENT_TARGET}-x86_64" ++ ;; ++esac ++ + # Some systems cannot stand _XOPEN_SOURCE being defined at all; they + # disable features if it is defined, without any means to access these + # features as extensions. For these systems, we skip the definition of +@@ -1582,7 +1623,7 @@ if test $enable_shared = "yes"; then + BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)' + RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}} + ;; +- Darwin*) ++ Darwin*|iOS*|tvOS*|watchOS*) + LDLIBRARY='libpython$(LDVERSION).dylib' + BLDLIBRARY='-L. -lpython$(LDVERSION)' + RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} +@@ -3469,6 +3510,11 @@ then + Linux*|GNU*|QNX*|VxWorks*|Haiku*) + LDSHARED='$(CC) -shared' + LDCXXSHARED='$(CXX) -shared';; ++ iOS*|tvOS*|watchOS*) ++ LDSHARED='$(CC) -bundle -undefined dynamic_lookup' ++ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup' ++ BLDSHARED="$LDSHARED" ++ ;; + FreeBSD*) + if [[ "`$CC -dM -E -