diff --git a/Makefile b/Makefile index b0ba7299..bc91150d 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,9 @@ OPENSSL_VERSION=3.0.16-1 XZ_VERSION=5.6.4-1 # Supported OS -OS_LIST=macOS iOS tvOS watchOS +OS_LIST=macOS iOS tvOS watchOS MacCatalyst -CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar +CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar -L # macOS targets TARGETS-macOS=macosx.x86_64 macosx.arm64 @@ -45,6 +45,10 @@ VERSION_MIN-macOS=11.0 TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64 VERSION_MIN-iOS=13.0 +# MacCatalyst targets +TARGETS-MacCatalyst=maccatalyst.x86_64 maccatalyst.arm64 +VERSION_MIN-MacCatalyst=14.2 + # tvOS targets TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64 VERSION_MIN-tvOS=12.0 @@ -117,22 +121,32 @@ downloads/python-$(PYTHON_PKG_VERSION)-macos11.pkg: # ########################################################################### define build-target + target=$1 os=$2 OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') # $(target) can be broken up into is composed of $(SDK).$(ARCH) -SDK-$(target)=$$(basename $(target)) +SDK-$(target)=$$(subst maccatalyst,macosx,$$(basename $(target))) ARCH-$(target)=$$(subst .,,$$(suffix $(target))) ifneq ($(os),macOS) - ifeq ($$(findstring simulator,$$(SDK-$(target))),) -TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os)) -IS_SIMULATOR-$(target)=False - else + ifneq ($$(findstring simulator,$$(SDK-$(target))),) TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator -IS_SIMULATOR-$(target)=True +IS_SIMULATOR-$(target)="True" +TARGET_ABI-$(target)="" +TARGET_TRIPLE_SUFFIX-$(target)="" + else ifneq ($$(findstring maccatalyst,$$(target)),) +TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-ios$$(VERSION_MIN-$(os))-macabi +IS_SIMULATOR-$(target)="False" +TARGET_ABI-$(target)="macabi" +TARGET_TRIPLE_SUFFIX-$(target)="-macabi" + else +TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os)) +IS_SIMULATOR-$(target)="False" +TARGET_ABI-$(target)="" +TARGET_TRIPLE_SUFFIX-$(target)="" endif endif @@ -342,16 +356,23 @@ $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)): | sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \ | sed -e "s/{{version_min}}/$$(VERSION_MIN-$(os))/g" \ | sed -e "s/{{is_simulator}}/$$(IS_SIMULATOR-$(target))/g" \ + | sed -e "s/{{abi}}/$$(TARGET_ABI-$(target))/g" \ + | sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(subst macosx,iphoneos,$$(SDK-$(target)))$$(TARGET_TRIPLE_SUFFIX-$(target))/g" \ + | sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(subst macosx,iphoneos-macabi,$$(SDK-$(target)))/g" \ > $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_$$(ARCH-$(target))_$$(SDK-$(target)).py cat $(PROJECT_DIR)/patch/Python/sitecustomize.py.tmpl \ | sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \ | sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \ + | sed -e "s/{{abi}}/$$(TARGET_ABI-$(target))/g" \ + | sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(subst macosx,iphoneos,$$(SDK-$(target)))$$(TARGET_TRIPLE_SUFFIX-$(target))/g" \ + | sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(subst macosx,iphoneos-macabi,$$(SDK-$(target)))/g" \ > $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) endif $(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target)) + ########################################################################### # Target: Debug ########################################################################### @@ -403,10 +424,13 @@ OS_LOWER-$(sdk)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') SDK_TARGETS-$(sdk)=$$(filter $(sdk).%,$$(TARGETS-$(os))) SDK_ARCHES-$(sdk)=$$(sort $$(subst .,,$$(suffix $$(SDK_TARGETS-$(sdk))))) -ifeq ($$(findstring simulator,$(sdk)),) -SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g") -else +ifneq ($$(findstring simulator,$(sdk)),) SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-simulator +else ifneq ($$(findstring maccatalyst,$(sdk)),) +SDK_SLICE-$(sdk)=ios-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-maccatalyst +sdk=macosx +else +SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g") endif # Expand the build-target macro for target on this OS diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index 139da995..a3a39b85 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -131,11 +131,136 @@ index 69f72452c40..34ce643340b 100644 else: import _osx_support osname, release, machine = _osx_support.get_platform_osx( +--- /dev/null ++++ b/MacCatalyst/Resources/Info.plist.in +@@ -0,0 +1,34 @@ ++ ++ ++ ++ ++ CFBundleDevelopmentRegion ++ en ++ CFBundleExecutable ++ Python ++ CFBundleGetInfoString ++ Python Runtime and Library ++ CFBundleIdentifier ++ @PYTHONFRAMEWORKIDENTIFIER@ ++ CFBundleInfoDictionaryVersion ++ 6.0 ++ CFBundleName ++ Python ++ CFBundlePackageType ++ FMWK ++ CFBundleShortVersionString ++ %VERSION% ++ CFBundleLongVersionString ++ %VERSION%, (c) 2001-2024 Python Software Foundation. ++ CFBundleSignature ++ ???? ++ CFBundleVersion ++ %VERSION% ++ CFBundleSupportedPlatforms ++ ++ iPhoneOS ++ ++ MinimumOSVersion ++ @IPHONEOS_DEPLOYMENT_TARGET@ ++ ++ +--- /dev/null ++++ b/MacCatalyst/Resources/bin/arm64-apple-ios-macabi-ar +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} ar "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/arm64-apple-ios-macabi-clang +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang -target arm64-apple-ios-macabi "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/arm64-apple-ios-macabi-clang++ +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang++ -target arm64-apple-ios-macabi "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/arm64-apple-ios-macabi-cpp +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang -target arm64-apple-ios-macabi -E "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/x86_64-apple-ios-macabi-ar +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} ar "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/x86_64-apple-ios-macabi-clang +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang -target x86_64-apple-ios-macabi "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/x86_64-apple-ios-macabi-clang++ +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang++ -target x86_64-apple-ios-macabi "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/bin/x86_64-apple-ios-macabi-cpp +@@ -0,0 +1,2 @@ ++#!/bin/sh ++xcrun --sdk macosx${MACOSX_SDK_VERSION} clang -target x86_64-apple-ios-macabi -E "$@" +--- /dev/null ++++ b/MacCatalyst/Resources/dylib-Info-template.plist +@@ -0,0 +1,26 @@ ++ ++ ++ ++ ++ CFBundleDevelopmentRegion ++ en ++ CFBundleExecutable ++ ++ CFBundleIdentifier ++ ++ CFBundleInfoDictionaryVersion ++ 6.0 ++ CFBundlePackageType ++ APPL ++ CFBundleShortVersionString ++ 1.0 ++ CFBundleSupportedPlatforms ++ ++ iPhoneOS ++ ++ MinimumOSVersion ++ 12.0 ++ CFBundleVersion ++ 1 ++ ++ +--- /dev/null ++++ b/MacCatalyst/Resources/pyconfig.h +@@ -0,0 +1,7 @@ ++#ifdef __arm64__ ++#include "pyconfig-arm64.h" ++#endif ++ ++#ifdef __x86_64__ ++#include "pyconfig-x86_64.h" ++#endif diff --git a/Misc/platform_triplet.c b/Misc/platform_triplet.c -index ec0857a4a99..2350e9dc821 100644 +index ec0857a4a99..13c9106b872 100644 --- a/Misc/platform_triplet.c +++ b/Misc/platform_triplet.c -@@ -257,6 +257,26 @@ +@@ -254,9 +254,35 @@ + # else + PLATFORM_TRIPLET=arm64-iphonesimulator + # endif ++# elif defined(TARGET_OS_MACCATALYST) && TARGET_OS_MACCATALYST ++# if __x86_64__ ++PLATFORM_TRIPLET=x86_64-iphoneos-macabi ++# else ++PLATFORM_TRIPLET=arm64-iphoneos-macabi ++# endif # else PLATFORM_TRIPLET=arm64-iphoneos # endif @@ -162,8 +287,30 @@ index ec0857a4a99..2350e9dc821 100644 // Older macOS SDKs do not define TARGET_OS_OSX # elif !defined(TARGET_OS_OSX) || TARGET_OS_OSX PLATFORM_TRIPLET=darwin +diff --git a/config.sub b/config.sub +index 1bb6a05dc11..7e007ac54c3 100755 +--- a/config.sub ++++ b/config.sub +@@ -1769,7 +1769,7 @@ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +- | fiwix* | mlibc* | cos* | mbr* | ironclad* ) ++ | fiwix* | mlibc* | cos* | mbr* | ironclad* | macabi) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +@@ -1869,6 +1869,8 @@ + ;; + ios*-simulator- | tvos*-simulator- | watchos*-simulator- ) + ;; ++ ios*-macabi- ) ++ ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format diff --git a/configure b/configure -index d46bc563a67..d5cd81d16a8 100755 +index d46bc563a67..d40e0a6981f 100755 --- a/configure +++ b/configure @@ -974,6 +974,8 @@ @@ -197,10 +344,14 @@ index d46bc563a67..d5cd81d16a8 100755 # which isn't a binary that exists, and isn't very convenient, as it contains the # iOS version. As the default cross-compiler name won't exist, configure falls # back to gcc, which *definitely* won't work. We're providing wrapper scripts for -@@ -4196,6 +4204,14 @@ +@@ -4194,32 +4202,72 @@ + if test -z "$AR"; then + case "$host" in aarch64-apple-ios*-simulator) AR=arm64-apple-ios-simulator-ar ;; ++ aarch64-apple-ios*-macabi) AR=arm64-apple-ios-macabi-ar ;; aarch64-apple-ios*) AR=arm64-apple-ios-ar ;; x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;; ++ x86_64-apple-ios*-macabi) AR=x86_64-apple-ios-macabi-ar ;; + + aarch64-apple-tvos*-simulator) AR=arm64-apple-tvos-simulator-ar ;; + aarch64-apple-tvos*) AR=arm64-apple-tvos-ar ;; @@ -212,10 +363,13 @@ index d46bc563a67..d5cd81d16a8 100755 *) esac fi -@@ -4204,6 +4220,14 @@ + if test -z "$CC"; then + case "$host" in aarch64-apple-ios*-simulator) CC=arm64-apple-ios-simulator-clang ;; ++ aarch64-apple-ios*-macabi) CC=arm64-apple-ios-macabi-clang ;; aarch64-apple-ios*) CC=arm64-apple-ios-clang ;; x86_64-apple-ios*-simulator) CC=x86_64-apple-ios-simulator-clang ;; ++ x86_64-apple-ios*-macabi) CC=x86_64-apple-ios-macabi-clang ;; + + aarch64-apple-tvos*-simulator) CC=arm64-apple-tvos-simulator-clang ;; + aarch64-apple-tvos*) CC=arm64-apple-tvos-clang ;; @@ -227,10 +381,13 @@ index d46bc563a67..d5cd81d16a8 100755 *) esac fi -@@ -4212,6 +4236,14 @@ + if test -z "$CPP"; then + case "$host" in aarch64-apple-ios*-simulator) CPP=arm64-apple-ios-simulator-cpp ;; ++ aarch64-apple-ios*-macabi) CPP=arm64-apple-ios-macabi-cpp ;; aarch64-apple-ios*) CPP=arm64-apple-ios-cpp ;; x86_64-apple-ios*-simulator) CPP=x86_64-apple-ios-simulator-cpp ;; ++ x86_64-apple-ios*-macabi) CPP=x86_64-apple-ios-macabi-cpp ;; + + aarch64-apple-tvos*-simulator) CPP=arm64-apple-tvos-simulator-cpp ;; + aarch64-apple-tvos*) CPP=arm64-apple-tvos-cpp ;; @@ -242,10 +399,13 @@ index d46bc563a67..d5cd81d16a8 100755 *) esac fi -@@ -4220,6 +4252,14 @@ + if test -z "$CXX"; then + case "$host" in aarch64-apple-ios*-simulator) CXX=arm64-apple-ios-simulator-clang++ ;; ++ aarch64-apple-ios*-macabi) CXX=arm64-apple-ios-macabi-clang++ ;; aarch64-apple-ios*) CXX=arm64-apple-ios-clang++ ;; x86_64-apple-ios*-simulator) CXX=x86_64-apple-ios-simulator-clang++ ;; ++ x86_64-apple-ios*-macabi) CXX=x86_64-apple-ios-macabi-clang++ ;; + + aarch64-apple-tvos*-simulator) CXX=arm64-apple-tvos-simulator-clang++ ;; + aarch64-apple-tvos*) CXX=arm64-apple-tvos-clang++ ;; @@ -257,7 +417,7 @@ index d46bc563a67..d5cd81d16a8 100755 *) esac fi -@@ -4342,8 +4382,10 @@ +@@ -4342,8 +4390,10 @@ case $enableval in yes) case $ac_sys_system in @@ -270,7 +430,7 @@ index d46bc563a67..d5cd81d16a8 100755 *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5 esac esac -@@ -4352,6 +4394,8 @@ +@@ -4352,6 +4402,8 @@ no) case $ac_sys_system in iOS) as_fn_error $? "iOS builds must use --enable-framework" "$LINENO" 5 ;; @@ -279,7 +439,7 @@ index d46bc563a67..d5cd81d16a8 100755 *) PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework -@@ -4458,6 +4502,36 @@ +@@ -4458,6 +4510,36 @@ ac_config_files="$ac_config_files iOS/Resources/Info.plist" @@ -316,7 +476,7 @@ index d46bc563a67..d5cd81d16a8 100755 ;; *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5 -@@ -4469,6 +4543,8 @@ +@@ -4469,6 +4551,8 @@ e) case $ac_sys_system in iOS) as_fn_error $? "iOS builds must use --enable-framework" "$LINENO" 5 ;; @@ -325,7 +485,7 @@ index d46bc563a67..d5cd81d16a8 100755 *) PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework -@@ -4523,8 +4599,8 @@ +@@ -4523,8 +4607,8 @@ case "$withval" in yes) case $ac_sys_system in @@ -336,7 +496,7 @@ index d46bc563a67..d5cd81d16a8 100755 APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" ;; *) as_fn_error $? "no default app store compliance patch available for $ac_sys_system" "$LINENO" 5 ;; -@@ -4542,8 +4618,8 @@ +@@ -4542,8 +4626,8 @@ else case e in #( e) case $ac_sys_system in @@ -347,7 +507,7 @@ index d46bc563a67..d5cd81d16a8 100755 APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: applying default app store compliance patch" >&5 printf "%s\n" "applying default app store compliance patch" >&6; } -@@ -4598,6 +4674,50 @@ +@@ -4598,6 +4682,50 @@ ;; esac ;; @@ -398,7 +558,7 @@ index d46bc563a67..d5cd81d16a8 100755 *-*-darwin*) case "$host_cpu" in arm*) -@@ -4688,9 +4808,13 @@ +@@ -4688,9 +4816,13 @@ define_xopen_source=no;; Darwin/[12][0-9].*) define_xopen_source=no;; @@ -413,7 +573,7 @@ index d46bc563a67..d5cd81d16a8 100755 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) -@@ -4753,7 +4877,10 @@ +@@ -4753,7 +4885,10 @@ CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' @@ -425,7 +585,7 @@ index d46bc563a67..d5cd81d16a8 100755 # checks for alternative programs -@@ -4794,6 +4921,16 @@ +@@ -4794,6 +4929,16 @@ as_fn_append CFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" as_fn_append LDFLAGS " -mios-version-min=${IPHONEOS_DEPLOYMENT_TARGET}" ;; #( @@ -442,7 +602,7 @@ index d46bc563a67..d5cd81d16a8 100755 *) : ;; esac -@@ -7163,6 +7300,10 @@ +@@ -7163,6 +7308,10 @@ MULTIARCH="" ;; #( iOS) : MULTIARCH="" ;; #( @@ -453,7 +613,7 @@ index d46bc563a67..d5cd81d16a8 100755 FreeBSD*) : MULTIARCH="" ;; #( *) : -@@ -7183,7 +7324,7 @@ +@@ -7183,7 +7332,7 @@ printf "%s\n" "$MULTIARCH" >&6; } case $ac_sys_system in #( @@ -462,12 +622,16 @@ index d46bc563a67..d5cd81d16a8 100755 SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f2` ;; #( *) : SOABI_PLATFORM=$PLATFORM_TRIPLET -@@ -7234,6 +7375,14 @@ +@@ -7234,6 +7383,18 @@ PY_SUPPORT_TIER=3 ;; #( aarch64-apple-ios*/clang) : PY_SUPPORT_TIER=3 ;; #( + aarch64-apple-tvos*-simulator/clang) : + PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-ios*-macabi/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ x86_64-apple-ios*-macabi/clang) : ++ PY_SUPPORT_TIER=3 ;; #( + aarch64-apple-tvos*/clang) : + PY_SUPPORT_TIER=3 ;; #( + aarch64-apple-watchos*-simulator/clang) : @@ -477,7 +641,7 @@ index d46bc563a67..d5cd81d16a8 100755 aarch64-*-linux-android/clang) : PY_SUPPORT_TIER=3 ;; #( x86_64-*-linux-android/clang) : -@@ -7670,7 +7819,7 @@ +@@ -7670,7 +7831,7 @@ case $ac_sys_system in Darwin) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';; @@ -486,7 +650,7 @@ index d46bc563a67..d5cd81d16a8 100755 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; *) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5;; -@@ -7736,7 +7885,7 @@ +@@ -7736,7 +7897,7 @@ BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} ;; @@ -495,7 +659,7 @@ index d46bc563a67..d5cd81d16a8 100755 LDLIBRARY='libpython$(LDVERSION).dylib' ;; AIX*) -@@ -13544,7 +13693,7 @@ +@@ -13544,7 +13705,7 @@ BLDSHARED="$LDSHARED" fi ;; @@ -504,7 +668,7 @@ index d46bc563a67..d5cd81d16a8 100755 LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' BLDSHARED="$LDSHARED" -@@ -13677,7 +13826,7 @@ +@@ -13677,7 +13838,7 @@ Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys @@ -513,7 +677,7 @@ index d46bc563a67..d5cd81d16a8 100755 LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too -@@ -13701,7 +13850,7 @@ +@@ -13701,7 +13862,7 @@ LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED" @@ -522,7 +686,7 @@ index d46bc563a67..d5cd81d16a8 100755 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' fi ;; -@@ -15286,7 +15435,7 @@ +@@ -15286,7 +15447,7 @@ ctypes_malloc_closure=yes ;; #( @@ -531,7 +695,7 @@ index d46bc563a67..d5cd81d16a8 100755 ctypes_malloc_closure=yes ;; #( -@@ -19038,12 +19187,6 @@ +@@ -19038,12 +19199,6 @@ then : printf "%s\n" "#define HAVE_DUP3 1" >>confdefs.h @@ -544,7 +708,7 @@ index d46bc563a67..d5cd81d16a8 100755 fi ac_fn_c_check_func "$LINENO" "explicit_bzero" "ac_cv_func_explicit_bzero" if test "x$ac_cv_func_explicit_bzero" = xyes -@@ -19104,18 +19247,6 @@ +@@ -19104,18 +19259,6 @@ then : printf "%s\n" "#define HAVE_FEXECVE 1" >>confdefs.h @@ -563,7 +727,7 @@ index d46bc563a67..d5cd81d16a8 100755 fi ac_fn_c_check_func "$LINENO" "fpathconf" "ac_cv_func_fpathconf" if test "x$ac_cv_func_fpathconf" = xyes -@@ -19542,24 +19673,6 @@ +@@ -19542,24 +19685,6 @@ then : printf "%s\n" "#define HAVE_POSIX_OPENPT 1" >>confdefs.h @@ -588,7 +752,7 @@ index d46bc563a67..d5cd81d16a8 100755 fi ac_fn_c_check_func "$LINENO" "pread" "ac_cv_func_pread" if test "x$ac_cv_func_pread" = xyes -@@ -19860,12 +19973,6 @@ +@@ -19860,12 +19985,6 @@ then : printf "%s\n" "#define HAVE_SIGACTION 1" >>confdefs.h @@ -601,7 +765,7 @@ index d46bc563a67..d5cd81d16a8 100755 fi ac_fn_c_check_func "$LINENO" "sigfillset" "ac_cv_func_sigfillset" if test "x$ac_cv_func_sigfillset" = xyes -@@ -20134,11 +20241,11 @@ +@@ -20134,11 +20253,11 @@ fi @@ -615,7 +779,7 @@ index d46bc563a67..d5cd81d16a8 100755 ac_fn_c_check_func "$LINENO" "getentropy" "ac_cv_func_getentropy" if test "x$ac_cv_func_getentropy" = xyes then : -@@ -20160,6 +20267,53 @@ +@@ -20160,6 +20279,53 @@ fi @@ -669,7 +833,7 @@ index d46bc563a67..d5cd81d16a8 100755 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5 printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; } if test ${ac_cv_c_undeclared_builtin_options+y} -@@ -23242,7 +23396,8 @@ +@@ -23242,7 +23408,8 @@ # check for openpty, login_tty, and forkpty @@ -679,7 +843,7 @@ index d46bc563a67..d5cd81d16a8 100755 for ac_func in openpty do : -@@ -23356,7 +23511,7 @@ +@@ -23356,7 +23523,7 @@ fi done @@ -688,7 +852,7 @@ index d46bc563a67..d5cd81d16a8 100755 printf %s "checking for library containing login_tty... " >&6; } if test ${ac_cv_search_login_tty+y} then : -@@ -23539,6 +23694,7 @@ +@@ -23539,6 +23706,7 @@ fi done @@ -696,7 +860,7 @@ index d46bc563a67..d5cd81d16a8 100755 # check for long file support functions ac_fn_c_check_func "$LINENO" "fseek64" "ac_cv_func_fseek64" -@@ -23804,10 +23960,10 @@ +@@ -23804,10 +23972,10 @@ done @@ -709,7 +873,7 @@ index d46bc563a67..d5cd81d16a8 100755 then for ac_func in clock_settime -@@ -26146,8 +26302,8 @@ +@@ -26146,8 +26314,8 @@ LIBPYTHON="\$(BLDLIBRARY)" fi @@ -720,7 +884,7 @@ index d46bc563a67..d5cd81d16a8 100755 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)" fi -@@ -29017,7 +29173,7 @@ +@@ -29017,7 +29185,7 @@ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for device files" >&5 printf "%s\n" "$as_me: checking for device files" >&6;} @@ -729,7 +893,7 @@ index d46bc563a67..d5cd81d16a8 100755 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no else -@@ -29510,7 +29666,7 @@ +@@ -29510,7 +29678,7 @@ with_ensurepip=no ;; #( WASI) : with_ensurepip=no ;; #( @@ -738,7 +902,7 @@ index d46bc563a67..d5cd81d16a8 100755 with_ensurepip=no ;; #( *) : with_ensurepip=upgrade -@@ -30490,7 +30646,7 @@ +@@ -30490,7 +30658,7 @@ ;; #( Darwin) : ;; #( @@ -747,7 +911,7 @@ index d46bc563a67..d5cd81d16a8 100755 -@@ -34493,6 +34649,8 @@ +@@ -34493,6 +34661,8 @@ "Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;; "Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;; "iOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES iOS/Resources/Info.plist" ;; @@ -757,7 +921,7 @@ index d46bc563a67..d5cd81d16a8 100755 "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; "Misc/python-embed.pc") CONFIG_FILES="$CONFIG_FILES Misc/python-embed.pc" ;; diff --git a/configure.ac b/configure.ac -index faa89095303..9bd51f7da97 100644 +index faa89095303..ea3af02efeb 100644 --- a/configure.ac +++ b/configure.ac @@ -330,6 +330,12 @@ @@ -782,10 +946,14 @@ index faa89095303..9bd51f7da97 100644 # which isn't a binary that exists, and isn't very convenient, as it contains the # iOS version. As the default cross-compiler name won't exist, configure falls # back to gcc, which *definitely* won't work. We're providing wrapper scripts for -@@ -420,6 +426,14 @@ +@@ -418,32 +424,72 @@ + if test -z "$AR"; then + case "$host" in aarch64-apple-ios*-simulator) AR=arm64-apple-ios-simulator-ar ;; ++ aarch64-apple-ios*-macabi) AR=arm64-apple-ios-macabi-ar ;; aarch64-apple-ios*) AR=arm64-apple-ios-ar ;; x86_64-apple-ios*-simulator) AR=x86_64-apple-ios-simulator-ar ;; ++ x86_64-apple-ios*-macabi) AR=x86_64-apple-ios-macabi-ar ;; + + aarch64-apple-tvos*-simulator) AR=arm64-apple-tvos-simulator-ar ;; + aarch64-apple-tvos*) AR=arm64-apple-tvos-ar ;; @@ -797,10 +965,13 @@ index faa89095303..9bd51f7da97 100644 *) esac fi -@@ -428,6 +442,14 @@ + if test -z "$CC"; then + case "$host" in aarch64-apple-ios*-simulator) CC=arm64-apple-ios-simulator-clang ;; ++ aarch64-apple-ios*-macabi) CC=arm64-apple-ios-macabi-clang ;; aarch64-apple-ios*) CC=arm64-apple-ios-clang ;; x86_64-apple-ios*-simulator) CC=x86_64-apple-ios-simulator-clang ;; ++ x86_64-apple-ios*-macabi) CC=x86_64-apple-ios-macabi-clang ;; + + aarch64-apple-tvos*-simulator) CC=arm64-apple-tvos-simulator-clang ;; + aarch64-apple-tvos*) CC=arm64-apple-tvos-clang ;; @@ -812,10 +983,13 @@ index faa89095303..9bd51f7da97 100644 *) esac fi -@@ -436,6 +458,14 @@ + if test -z "$CPP"; then + case "$host" in aarch64-apple-ios*-simulator) CPP=arm64-apple-ios-simulator-cpp ;; ++ aarch64-apple-ios*-macabi) CPP=arm64-apple-ios-macabi-clang++ ;; aarch64-apple-ios*) CPP=arm64-apple-ios-cpp ;; x86_64-apple-ios*-simulator) CPP=x86_64-apple-ios-simulator-cpp ;; ++ x86_64-apple-ios*-macabi) CPP=x86_64-apple-ios-macabi-clang++ ;; + + aarch64-apple-tvos*-simulator) CPP=arm64-apple-tvos-simulator-cpp ;; + aarch64-apple-tvos*) CPP=arm64-apple-tvos-cpp ;; @@ -827,10 +1001,13 @@ index faa89095303..9bd51f7da97 100644 *) esac fi -@@ -444,6 +474,14 @@ + if test -z "$CXX"; then + case "$host" in aarch64-apple-ios*-simulator) CXX=arm64-apple-ios-simulator-clang++ ;; ++ aarch64-apple-ios*-macabi) CXX=arm64-apple-ios-macabi-clang++ ;; aarch64-apple-ios*) CXX=arm64-apple-ios-clang++ ;; x86_64-apple-ios*-simulator) CXX=x86_64-apple-ios-simulator-clang++ ;; ++ x86_64-apple-ios*-macabi) CXX=x86_64-apple-ios-macabi-clang++ ;; + + aarch64-apple-tvos*-simulator) CXX=arm64-apple-tvos-simulator-clang++ ;; + aarch64-apple-tvos*) CXX=arm64-apple-tvos-clang++ ;; @@ -842,7 +1019,7 @@ index faa89095303..9bd51f7da97 100644 *) esac fi -@@ -558,8 +596,10 @@ +@@ -558,8 +604,10 @@ case $enableval in yes) case $ac_sys_system in @@ -855,7 +1032,7 @@ index faa89095303..9bd51f7da97 100644 *) AC_MSG_ERROR([Unknown platform for framework build]) esac esac -@@ -568,6 +608,8 @@ +@@ -568,6 +616,8 @@ no) case $ac_sys_system in iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;; @@ -864,7 +1041,7 @@ index faa89095303..9bd51f7da97 100644 *) PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework -@@ -670,6 +712,34 @@ +@@ -670,6 +720,34 @@ AC_CONFIG_FILES([iOS/Resources/Info.plist]) ;; @@ -899,7 +1076,7 @@ index faa89095303..9bd51f7da97 100644 *) AC_MSG_ERROR([Unknown platform for framework build]) ;; -@@ -678,6 +748,8 @@ +@@ -678,6 +756,8 @@ ],[ case $ac_sys_system in iOS) AC_MSG_ERROR([iOS builds must use --enable-framework]) ;; @@ -908,7 +1085,7 @@ index faa89095303..9bd51f7da97 100644 *) PYTHONFRAMEWORK= PYTHONFRAMEWORKDIR=no-framework -@@ -730,8 +802,8 @@ +@@ -730,8 +810,8 @@ case "$withval" in yes) case $ac_sys_system in @@ -919,7 +1096,7 @@ index faa89095303..9bd51f7da97 100644 APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" ;; *) AC_MSG_ERROR([no default app store compliance patch available for $ac_sys_system]) ;; -@@ -745,8 +817,8 @@ +@@ -745,8 +825,8 @@ esac ],[ case $ac_sys_system in @@ -930,7 +1107,7 @@ index faa89095303..9bd51f7da97 100644 APP_STORE_COMPLIANCE_PATCH="Mac/Resources/app-store-compliance.patch" AC_MSG_RESULT([applying default app store compliance patch]) ;; -@@ -794,6 +866,46 @@ +@@ -794,6 +874,46 @@ ;; esac ;; @@ -977,7 +1154,7 @@ index faa89095303..9bd51f7da97 100644 *-*-darwin*) case "$host_cpu" in arm*) -@@ -883,9 +995,13 @@ +@@ -883,9 +1003,13 @@ define_xopen_source=no;; Darwin/@<:@[12]@:>@@<:@0-9@:>@.*) define_xopen_source=no;; @@ -992,7 +1169,7 @@ index faa89095303..9bd51f7da97 100644 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) -@@ -944,8 +1060,11 @@ +@@ -944,8 +1068,11 @@ CONFIGURE_MACOSX_DEPLOYMENT_TARGET= EXPORT_MACOSX_DEPLOYMENT_TARGET='#' @@ -1005,7 +1182,7 @@ index faa89095303..9bd51f7da97 100644 # checks for alternative programs -@@ -979,11 +1098,17 @@ +@@ -979,11 +1106,17 @@ ], ) @@ -1024,7 +1201,7 @@ index faa89095303..9bd51f7da97 100644 ], ) -@@ -1172,6 +1297,8 @@ +@@ -1172,6 +1305,8 @@ AS_CASE([$ac_sys_system], [Darwin*], [MULTIARCH=""], [iOS], [MULTIARCH=""], @@ -1033,7 +1210,7 @@ index faa89095303..9bd51f7da97 100644 [FreeBSD*], [MULTIARCH=""], [MULTIARCH=$($CC --print-multiarch 2>/dev/null)] ) -@@ -1193,7 +1320,7 @@ +@@ -1193,7 +1328,7 @@ dnl use a single "fat" binary at runtime. SOABI_PLATFORM is the component of dnl the PLATFORM_TRIPLET that will be used in binary module extensions. AS_CASE([$ac_sys_system], @@ -1042,18 +1219,20 @@ index faa89095303..9bd51f7da97 100644 [SOABI_PLATFORM=$PLATFORM_TRIPLET] ) -@@ -1227,6 +1354,10 @@ +@@ -1227,6 +1362,12 @@ [x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64 [aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64 [aarch64-apple-ios*/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64 + [aarch64-apple-tvos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl tvOS Simulator on arm64 ++ [aarch64-apple-ios*-macabi/clang], [PY_SUPPORT_TIER=3], dnl MacCatalyst on arm64 ++ [x86_64-apple-ios*-macabi/clang], [PY_SUPPORT_TIER=3], dnl MacCatalyst on x86_64 + [aarch64-apple-tvos*/clang], [PY_SUPPORT_TIER=3], dnl tvOS on ARM64 + [aarch64-apple-watchos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl watchOS Simulator on arm64 + [arm64_32-apple-watchos*/clang], [PY_SUPPORT_TIER=3], dnl watchOS on ARM64 [aarch64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on ARM64 [x86_64-*-linux-android/clang], [PY_SUPPORT_TIER=3], dnl Android on AMD64 -@@ -1536,7 +1667,7 @@ +@@ -1536,7 +1677,7 @@ case $ac_sys_system in Darwin) LDLIBRARY='$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)';; @@ -1062,7 +1241,7 @@ index faa89095303..9bd51f7da97 100644 LDLIBRARY='$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)';; *) AC_MSG_ERROR([Unknown platform for framework build]);; -@@ -1601,7 +1732,7 @@ +@@ -1601,7 +1742,7 @@ BLDLIBRARY='-L. -lpython$(LDVERSION)' RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}} ;; @@ -1071,7 +1250,7 @@ index faa89095303..9bd51f7da97 100644 LDLIBRARY='libpython$(LDVERSION).dylib' ;; AIX*) -@@ -3456,7 +3587,7 @@ +@@ -3456,7 +3597,7 @@ BLDSHARED="$LDSHARED" fi ;; @@ -1080,7 +1259,7 @@ index faa89095303..9bd51f7da97 100644 LDSHARED='$(CC) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' LDCXXSHARED='$(CXX) -dynamiclib -F . -framework $(PYTHONFRAMEWORK)' BLDSHARED="$LDSHARED" -@@ -3580,7 +3711,7 @@ +@@ -3580,7 +3721,7 @@ Linux-android*) LINKFORSHARED="-pie -Xlinker -export-dynamic";; Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; # -u libsys_s pulls in all symbols in libsys @@ -1089,7 +1268,7 @@ index faa89095303..9bd51f7da97 100644 LINKFORSHARED="$extra_undefs -framework CoreFoundation" # Issue #18075: the default maximum stack size (8MBytes) is too -@@ -3604,7 +3735,7 @@ +@@ -3604,7 +3745,7 @@ LINKFORSHARED="$LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)' fi LINKFORSHARED="$LINKFORSHARED" @@ -1098,7 +1277,7 @@ index faa89095303..9bd51f7da97 100644 LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED "'$(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)' fi ;; -@@ -4024,7 +4155,7 @@ +@@ -4024,7 +4165,7 @@ dnl when do we need USING_APPLE_OS_LIBFFI? ctypes_malloc_closure=yes ], @@ -1107,7 +1286,7 @@ index faa89095303..9bd51f7da97 100644 ctypes_malloc_closure=yes ], [sunos5], [AS_VAR_APPEND([LIBFFI_LIBS], [" -mimpure-text"])] -@@ -5133,9 +5264,9 @@ +@@ -5133,9 +5274,9 @@ # checks for library functions AC_CHECK_FUNCS([ \ accept4 alarm bind_textdomain_codeset chmod chown clock closefrom close_range confstr \ @@ -1119,7 +1298,7 @@ index faa89095303..9bd51f7da97 100644 gai_strerror getegid geteuid getgid getgrent getgrgid getgrgid_r \ getgrnam_r getgrouplist gethostname getitimer getloadavg getlogin \ getpeername getpgid getpid getppid getpriority _getpty \ -@@ -5143,8 +5274,7 @@ +@@ -5143,8 +5284,7 @@ getspnam getuid getwd grantpt if_nameindex initgroups kill killpg lchown linkat \ lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \ mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \ @@ -1129,7 +1308,7 @@ index faa89095303..9bd51f7da97 100644 pread preadv preadv2 process_vm_readv \ pthread_cond_timedwait_relative_np pthread_condattr_setclock pthread_init \ pthread_kill pthread_getname_np pthread_setname_np \ -@@ -5153,7 +5283,7 @@ +@@ -5153,7 +5293,7 @@ sched_setparam sched_setscheduler sem_clockwait sem_getvalue sem_open \ sem_timedwait sem_unlink sendfile setegid seteuid setgid sethostname \ setitimer setlocale setpgid setpgrp setpriority setregid setresgid \ @@ -1138,7 +1317,7 @@ index faa89095303..9bd51f7da97 100644 sigfillset siginterrupt sigpending sigrelse sigtimedwait sigwait \ sigwaitinfo snprintf splice strftime strlcpy strsignal symlinkat sync \ sysconf tcgetpgrp tcsetpgrp tempnam timegm times tmpfile \ -@@ -5168,12 +5298,20 @@ +@@ -5168,12 +5308,20 @@ AC_CHECK_FUNCS([lchmod]) fi @@ -1162,7 +1341,7 @@ index faa89095303..9bd51f7da97 100644 fi AC_CHECK_DECL([dirfd], -@@ -5427,20 +5565,22 @@ +@@ -5427,20 +5575,22 @@ ]) # check for openpty, login_tty, and forkpty @@ -1199,7 +1378,7 @@ index faa89095303..9bd51f7da97 100644 # check for long file support functions AC_CHECK_FUNCS([fseek64 fseeko fstatvfs ftell64 ftello statvfs]) -@@ -5479,10 +5619,10 @@ +@@ -5479,10 +5629,10 @@ ]) ]) @@ -1212,7 +1391,7 @@ index faa89095303..9bd51f7da97 100644 then AC_CHECK_FUNCS([clock_settime], [], [ AC_CHECK_LIB([rt], [clock_settime], [ -@@ -6233,8 +6373,8 @@ +@@ -6233,8 +6383,8 @@ LIBPYTHON="\$(BLDLIBRARY)" fi @@ -1223,7 +1402,7 @@ index faa89095303..9bd51f7da97 100644 MODULE_DEPS_SHARED="$MODULE_DEPS_SHARED \$(PYTHONFRAMEWORKDIR)/\$(PYTHONFRAMEWORK)" fi -@@ -6893,7 +7033,7 @@ +@@ -6893,7 +7043,7 @@ dnl NOTE: Inform user how to proceed with files when cross compiling. dnl Some cross-compile builds are predictable; they won't ever dnl have /dev/ptmx or /dev/ptc, so we can set them explicitly. @@ -1232,7 +1411,7 @@ index faa89095303..9bd51f7da97 100644 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no else -@@ -7187,7 +7327,7 @@ +@@ -7187,7 +7337,7 @@ AS_CASE([$ac_sys_system], [Emscripten], [with_ensurepip=no], [WASI], [with_ensurepip=no], @@ -1241,7 +1420,7 @@ index faa89095303..9bd51f7da97 100644 [with_ensurepip=upgrade] ) ]) -@@ -7598,7 +7738,7 @@ +@@ -7598,7 +7748,7 @@ [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [termios], [grp])], dnl The _scproxy module is available on macOS [Darwin], [], diff --git a/patch/Python/release.MacCatalyst.exclude b/patch/Python/release.MacCatalyst.exclude new file mode 100644 index 00000000..f1d0f75e --- /dev/null +++ b/patch/Python/release.MacCatalyst.exclude @@ -0,0 +1,6 @@ +# This is a list of support package path patterns that we exclude +# from all Python-Apple-support tarballs. +# It is used by `tar -X` during the Makefile build. +# Remove pyc files. These take up space, but since most stdlib modules are +# never imported by user code, they mostly have no value. +*/__pycache__ diff --git a/patch/Python/sitecustomize.MacCatalyst.py b/patch/Python/sitecustomize.MacCatalyst.py new file mode 100644 index 00000000..48c464ab --- /dev/null +++ b/patch/Python/sitecustomize.MacCatalyst.py @@ -0,0 +1,114 @@ +# A site customization that can be used to trick pip into installing +# packages cross-platform. If the folder containing this file is on +# your PYTHONPATH when you invoke pip, pip will behave as if it were +# running on {{os}}. +import collections +import distutils.ccompiler +import distutils.unixccompiler +import os +import platform +import sys +import sysconfig +import types + +# Make platform.system() return "{{os}}" +def custom_system(): + return "{{os}}" + +platform.system = custom_system + +# Make platform.ios_ver() return an appropriate namedtuple +IOSVersionInfo = collections.namedtuple( + "IOSVersionInfo", + ["system", "release", "model", "is_simulator", "abi"] +) + +def custom_ios_ver(system="", release="", model="", is_simulator=False, abi=""): + return IOSVersionInfo("{{os}}", "{{version_min}}", "iPhone", {{is_simulator}}, "{{abi}}") + +platform.ios_ver = custom_ios_ver + +# Make sys.implementation._multiarch return the multiarch description +sys.implementation._multiarch = "{{multiarch}}" + +# Make sysconfig.get_platform() return the platform tag +def custom_get_platform(): + return "{{tag}}" + +sysconfig.get_platform = custom_get_platform + +# Make distutils raise errors if you try to use it to build modules. +DISABLED_COMPILER_ERROR = "Cannot compile native modules" + +distutils.ccompiler.get_default_compiler = lambda *args, **kwargs: "disabled" +distutils.ccompiler.compiler_class["disabled"] = ( + "disabledcompiler", + "DisabledCompiler", + "Compiler disabled ({})".format(DISABLED_COMPILER_ERROR), +) + + +def disabled_compiler(prefix): + # No need to give any more advice here: that will come from the higher-level code in pip. + from distutils.errors import DistutilsPlatformError + + raise DistutilsPlatformError("{}: {}".format(prefix, DISABLED_COMPILER_ERROR)) + + +class DisabledCompiler(distutils.ccompiler.CCompiler): + compiler_type = "disabled" + + def preprocess(*args, **kwargs): + disabled_compiler("CCompiler.preprocess") + + def compile(*args, **kwargs): + disabled_compiler("CCompiler.compile") + + def create_static_lib(*args, **kwargs): + disabled_compiler("CCompiler.create_static_lib") + + def link(*args, **kwargs): + disabled_compiler("CCompiler.link") + + +# To maximize the chance of the build getting as far as actually calling compile(), make +# sure the class has all of the expected attributes. +for name in [ + "src_extensions", + "obj_extension", + "static_lib_extension", + "shared_lib_extension", + "static_lib_format", + "shared_lib_format", + "exe_extension", +]: + setattr( + DisabledCompiler, name, getattr(distutils.unixccompiler.UnixCCompiler, name) + ) + +DisabledCompiler.executables = { + name: [DISABLED_COMPILER_ERROR.replace(" ", "_")] + for name in distutils.unixccompiler.UnixCCompiler.executables +} + +disabled_mod = types.ModuleType("distutils.disabledcompiler") +disabled_mod.DisabledCompiler = DisabledCompiler +sys.modules["distutils.disabledcompiler"] = disabled_mod + + +# Try to disable native builds for packages which don't use the distutils native build +# system at all (e.g. uwsgi), or only use it to wrap an external build script (e.g. pynacl). +for tool in ["ar", "as", "cc", "cxx", "ld"]: + os.environ[tool.upper()] = DISABLED_COMPILER_ERROR.replace(" ", "_") + + +# Call the next sitecustomize script if there is one +# (https://nedbatchelder.com/blog/201001/running_code_at_python_startup.html). +del sys.modules["sitecustomize"] +this_dir = os.path.dirname(__file__) +path_index = sys.path.index(this_dir) +del sys.path[path_index] +try: + import sitecustomize # noqa: F401 +finally: + sys.path.insert(path_index, this_dir)