From 2dee4252865142c03b48b03493b9311ce8b49a46 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 1 Sep 2023 15:00:09 +0800 Subject: [PATCH 1/9] Switch to using .dylib format for iOS binary modules. This is substantially built upon the work done by @alibeyram (and team). --- .gitignore | 3 + Makefile | 2 +- README.rst | 11 +-- patch/Python/Python.patch | 187 +++++++++++++++++++++++++++++--------- 4 files changed, 152 insertions(+), 51 deletions(-) diff --git a/.gitignore b/.gitignore index 0fb0445..c382b0a 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ wheels/* __pycache__ tests/testbed/macOS tests/testbed/iOS +*.log +*.gz +*.DS_Store diff --git a/Makefile b/Makefile index 9a458d6..3f9ce1d 100644 --- a/Makefile +++ b/Makefile @@ -836,7 +836,7 @@ $$(PYTHON_FATINCLUDE-$(sdk)): $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FATSTDLIB-$(sdk)): $$(PYTHON_FATLIB-$(sdk)) @echo ">>> Build Python stdlib for the $(sdk) SDK" - mkdir -p $$(PYTHON_FATSTDLIB-$(sdk)) + mkdir -p $$(PYTHON_FATSTDLIB-$(sdk))/lib-dynload # Copy stdlib from the first target associated with the $(sdk) SDK cp -r $$(PYTHON_INSTALL-$$(firstword $$(SDK_TARGETS-$(sdk))))/lib/python$(PYTHON_VER)/ $$(PYTHON_FATSTDLIB-$(sdk)) diff --git a/README.rst b/README.rst index 1ebbc49..e139ea0 100644 --- a/README.rst +++ b/README.rst @@ -12,11 +12,10 @@ repository: * `Python 3.9 `__ * `Python 3.10 `__ -It works by downloading, patching, and building a fat binary of Python and -selected pre-requisites, and packaging them as static libraries that can be -incorporated into an Xcode project. The binary modules in the Python standard -library are statically compiled, but are distribted as ``.so`` objects that -can be dynamically loaded at runtime. +It works by downloading, patching, and building a fat binary of Python and selected +pre-requisites, and packaging them as static libraries that can be incorporated into an +XCode project. The binary modules in the Python standard library are statically +compiled, but are distributed as objects that can be dynamically loaded at runtime. It exposes *almost* all the modules in the Python standard library except for: @@ -90,7 +89,7 @@ Each support package contains: * ``VERSIONS``, a text file describing the specific versions of code used to build the support package; -* ``Python.xcframework``, a multi-architecture build of libPython3.11.a +* ``Python.xcframework``, a multi-architecture build of the Python runtime library * ``python-stdlib``, the code and binary modules comprising the Python standard library. On iOS, tvOS and watchOS, there are 2 copies of every binary module - one for physical devices, and one for the simulator. The simulator binaries diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index 3909c1c..18f46bd 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -131,7 +131,7 @@ index 2ce5c5b64d..6e10a0c4a5 100644 import pwd os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py -index f603a89f7f..faea51d1b5 100644 +index f603a89f7f..fe508e4615 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -52,7 +52,7 @@ @@ -143,6 +143,46 @@ index f603a89f7f..faea51d1b5 100644 _CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY + _CASE_INSENSITIVE_PLATFORMS_STR_KEY) +@@ -1705,6 +1705,29 @@ + return 'FileFinder({!r})'.format(self.path) + + ++class AppleFrameworkFinder: ++ """A finder for modules that have been packaged as Apple Frameworks ++ for compatibility with Apple's App Store policies. ++ ++ For compatibility with the App Store, *all* binary modules must be in .dylibs, ++ contained in a Framework. If you're trying to run "from foo import _bar", and _bar ++ is implemented with the binary module "foo/_bar.abi3.dylib" (or any other .dylib ++ extension), this loader will look for "{sys.executable}/Frameworks/_bar.framework" ++ """ ++ def __init__(self, path): ++ self.frameworks_path = path ++ ++ def find_spec(self, fullname, path, target=None): ++ name = fullname.split(".")[-1] ++ ++ for extension in EXTENSION_SUFFIXES: ++ dylib_path = _path_join(self.frameworks_path, f"{name}.framework", f"{name}{extension}") ++ if _path_isfile(dylib_path): ++ loader = ExtensionFileLoader(fullname, dylib_path) ++ return _bootstrap.spec_from_loader(fullname, loader) ++ ++ return None ++ + # Import setup ############################################################### + + def _fix_up_module(ns, name, pathname, cpathname=None): +@@ -1752,3 +1775,9 @@ + supported_loaders = _get_supported_file_loaders() + sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) + sys.meta_path.append(PathFinder) ++ if sys.platform == "ios": ++ sys.meta_path.append( ++ AppleFrameworkFinder( ++ _path_join(_path_split(sys.executable)[0], "Frameworks") ++ ) ++ ) diff --git a/Lib/platform.py b/Lib/platform.py index 9b9d88bf58..dbd9ee3276 100755 --- a/Lib/platform.py @@ -1534,6 +1574,49 @@ index 3a2a731808..cb2d9e53e2 100644 #define PY_GETENTROPY 1 /* Fill buffer with size pseudo-random bytes generated by getentropy(): +diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c +index 3c5fd83df5..77b26d2d85 100644 +--- a/Python/dynload_shlib.c ++++ b/Python/dynload_shlib.c +@@ -28,6 +28,10 @@ + #define LEAD_UNDERSCORE "" + #endif + ++#ifdef __APPLE__ ++# include "TargetConditionals.h" ++#endif /* __APPLE__ */ ++ + /* The .so extension module ABI tag, supplied by the Makefile via + Makefile.pre.in and configure. This is used to discriminate between + incompatible .so files so that extensions for different Python builds can +@@ -38,12 +42,21 @@ + #ifdef __CYGWIN__ + ".dll", + #else /* !__CYGWIN__ */ +- "." SOABI ".so", +-#ifdef ALT_SOABI +- "." ALT_SOABI ".so", +-#endif +- ".abi" PYTHON_ABI_STRING ".so", +- ".so", ++# ifdef __APPLE__ ++# if TARGET_OS_IPHONE ++# define SHLIB_SUFFIX ".dylib" ++# else ++# define SHLIB_SUFFIX ".so" ++# endif ++# else ++# define SHLIB_SUFFIX ".so" ++# endif ++ "." SOABI SHLIB_SUFFIX, ++# ifdef ALT_SOABI ++ "." ALT_SOABI SHLIB_SUFFIX, ++# endif ++ ".abi" PYTHON_ABI_STRING SHLIB_SUFFIX, ++ SHLIB_SUFFIX, + #endif /* __CYGWIN__ */ + NULL, + }; diff --git a/Python/marshal.c b/Python/marshal.c index 29f3bab60a..ea3b25a978 100644 --- a/Python/marshal.c @@ -1772,7 +1855,7 @@ index d74fb6deac..a30f74f03d 100755 # Blank kernel with real OS is always fine. ;; diff --git a/configure b/configure -index af4a5bbfdf..4c03d87f16 100755 +index af4a5bbfdf..c01cd44df0 100755 --- a/configure +++ b/configure @@ -838,6 +838,8 @@ @@ -1962,17 +2045,25 @@ index af4a5bbfdf..4c03d87f16 100755 fi -@@ -10940,6 +10996,9 @@ +@@ -10858,6 +10914,7 @@ + esac + ;; + CYGWIN*) SHLIB_SUFFIX=.dll;; ++ iOS|tvOS|watchOS) SHLIB_SUFFIX=.dylib;; + *) SHLIB_SUFFIX=.so;; + esac + fi +@@ -10940,6 +10997,9 @@ BLDSHARED="$LDSHARED" fi ;; + iOS/*|tvOS/*|watchOS/*) -+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup' -+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup';; ++ LDSHARED='$(CC) -dynamiclib -undefined dynamic_lookup' ++ LDCXXSHARED='$(CXX) -dynamiclib -undefined dynamic_lookup';; Emscripten|WASI) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; -@@ -11348,8 +11407,8 @@ +@@ -11348,8 +11408,8 @@ pkg_failed=no @@ -1983,7 +2074,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBUUID_CFLAGS"; then pkg_cv_LIBUUID_CFLAGS="$LIBUUID_CFLAGS" -@@ -11389,7 +11448,7 @@ +@@ -11389,7 +11449,7 @@ if test $pkg_failed = yes; then @@ -1992,7 +2083,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -11532,7 +11591,7 @@ +@@ -11532,7 +11592,7 @@ elif test $pkg_failed = untried; then @@ -2001,7 +2092,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -12183,23 +12242,35 @@ +@@ -12183,23 +12243,35 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5 $as_echo "$with_system_ffi" >&6; } else @@ -2043,7 +2134,7 @@ index af4a5bbfdf..4c03d87f16 100755 # Check for use of the system libmpdec library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5 $as_echo_n "checking for --with-system-libmpdec... " >&6; } -@@ -12340,8 +12411,8 @@ +@@ -12340,8 +12412,8 @@ pkg_failed=no @@ -2054,7 +2145,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBNSL_CFLAGS"; then pkg_cv_LIBNSL_CFLAGS="$LIBNSL_CFLAGS" -@@ -12381,7 +12452,7 @@ +@@ -12381,7 +12453,7 @@ if test $pkg_failed = yes; then @@ -2063,7 +2154,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12482,7 +12553,7 @@ +@@ -12482,7 +12554,7 @@ LIBNSL_LIBS=${LIBNSL_LIBS-$libnsl} elif test $pkg_failed = untried; then @@ -2072,7 +2163,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } LIBNSL_CFLAGS=${LIBNSL_CFLAGS-""} -@@ -12630,8 +12701,8 @@ +@@ -12630,8 +12702,8 @@ pkg_failed=no @@ -2083,7 +2174,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBSQLITE3_CFLAGS"; then pkg_cv_LIBSQLITE3_CFLAGS="$LIBSQLITE3_CFLAGS" -@@ -12671,7 +12742,7 @@ +@@ -12671,7 +12743,7 @@ if test $pkg_failed = yes; then @@ -2092,7 +2183,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12693,7 +12764,7 @@ +@@ -12693,7 +12765,7 @@ elif test $pkg_failed = untried; then @@ -2101,7 +2192,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } LIBSQLITE3_CFLAGS=${LIBSQLITE3_CFLAGS-""} -@@ -13462,8 +13533,8 @@ +@@ -13462,8 +13534,8 @@ pkg_failed=no @@ -2112,7 +2203,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$TCLTK_CFLAGS"; then pkg_cv_TCLTK_CFLAGS="$TCLTK_CFLAGS" -@@ -13503,7 +13574,7 @@ +@@ -13503,7 +13575,7 @@ if test $pkg_failed = yes; then @@ -2121,7 +2212,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13521,7 +13592,7 @@ +@@ -13521,7 +13593,7 @@ found_tcltk=no elif test $pkg_failed = untried; then @@ -2130,7 +2221,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } found_tcltk=no else -@@ -13557,8 +13628,8 @@ +@@ -13557,8 +13629,8 @@ pkg_failed=no @@ -2141,7 +2232,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$X11_CFLAGS"; then pkg_cv_X11_CFLAGS="$X11_CFLAGS" -@@ -13598,7 +13669,7 @@ +@@ -13598,7 +13670,7 @@ if test $pkg_failed = yes; then @@ -2150,7 +2241,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13625,7 +13696,7 @@ +@@ -13625,7 +13697,7 @@ and X11_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then @@ -2159,7 +2250,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -@@ -16201,8 +16272,8 @@ +@@ -16201,8 +16273,8 @@ pkg_failed=no @@ -2170,7 +2261,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" -@@ -16242,7 +16313,7 @@ +@@ -16242,7 +16314,7 @@ if test $pkg_failed = yes; then @@ -2179,7 +2270,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16386,7 +16457,7 @@ +@@ -16386,7 +16458,7 @@ elif test $pkg_failed = untried; then @@ -2188,7 +2279,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16549,8 +16620,8 @@ +@@ -16549,8 +16621,8 @@ pkg_failed=no @@ -2199,7 +2290,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$BZIP2_CFLAGS"; then pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" -@@ -16590,7 +16661,7 @@ +@@ -16590,7 +16662,7 @@ if test $pkg_failed = yes; then @@ -2208,7 +2299,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16687,7 +16758,7 @@ +@@ -16687,7 +16759,7 @@ elif test $pkg_failed = untried; then @@ -2217,7 +2308,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16779,8 +16850,8 @@ +@@ -16779,8 +16851,8 @@ pkg_failed=no @@ -2228,7 +2319,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBLZMA_CFLAGS"; then pkg_cv_LIBLZMA_CFLAGS="$LIBLZMA_CFLAGS" -@@ -16820,7 +16891,7 @@ +@@ -16820,7 +16892,7 @@ if test $pkg_failed = yes; then @@ -2237,7 +2328,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16917,7 +16988,7 @@ +@@ -16917,7 +16989,7 @@ elif test $pkg_failed = untried; then @@ -2246,7 +2337,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -18150,8 +18221,8 @@ +@@ -18150,8 +18222,8 @@ pkg_failed=no @@ -2257,7 +2348,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBCRYPT_CFLAGS"; then pkg_cv_LIBCRYPT_CFLAGS="$LIBCRYPT_CFLAGS" -@@ -18191,7 +18262,7 @@ +@@ -18191,7 +18263,7 @@ if test $pkg_failed = yes; then @@ -2266,7 +2357,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -18288,7 +18359,7 @@ +@@ -18288,7 +18360,7 @@ elif test $pkg_failed = untried; then @@ -2275,7 +2366,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -23063,8 +23134,8 @@ +@@ -23063,8 +23135,8 @@ if ! $found; then OPENSSL_INCLUDES= for ssldir in $ssldirs; do @@ -2286,7 +2377,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -f "$ssldir/include/openssl/ssl.h"; then OPENSSL_INCLUDES="-I$ssldir/include" OPENSSL_LDFLAGS="-L$ssldir/lib" -@@ -23445,8 +23516,8 @@ +@@ -23445,8 +23517,8 @@ pkg_failed=no @@ -2297,7 +2388,7 @@ index af4a5bbfdf..4c03d87f16 100755 if test -n "$LIBB2_CFLAGS"; then pkg_cv_LIBB2_CFLAGS="$LIBB2_CFLAGS" -@@ -23486,7 +23557,7 @@ +@@ -23486,7 +23558,7 @@ if test $pkg_failed = yes; then @@ -2306,7 +2397,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -23504,7 +23575,7 @@ +@@ -23504,7 +23576,7 @@ have_libb2=no elif test $pkg_failed = untried; then @@ -2315,7 +2406,7 @@ index af4a5bbfdf..4c03d87f16 100755 $as_echo "no" >&6; } have_libb2=no else -@@ -23575,6 +23646,29 @@ +@@ -23575,6 +23647,29 @@ py_cv_module_ossaudiodev=n/a py_cv_module_spwd=n/a ;; #( @@ -2346,7 +2437,7 @@ index af4a5bbfdf..4c03d87f16 100755 diff --git a/configure.ac b/configure.ac -index e1cbb7c7fb..9fd0afc76a 100644 +index e1cbb7c7fb..aa944cfc0c 100644 --- a/configure.ac +++ b/configure.ac @@ -545,6 +545,15 @@ @@ -2482,17 +2573,25 @@ index e1cbb7c7fb..9fd0afc76a 100644 fi AC_SUBST(READELF) -@@ -3171,6 +3243,9 @@ +@@ -3091,6 +3163,7 @@ + esac + ;; + CYGWIN*) SHLIB_SUFFIX=.dll;; ++ iOS|tvOS|watchOS) SHLIB_SUFFIX=.dylib;; + *) SHLIB_SUFFIX=.so;; + esac + fi +@@ -3171,6 +3244,9 @@ BLDSHARED="$LDSHARED" fi ;; + iOS/*|tvOS/*|watchOS/*) -+ LDSHARED='$(CC) -bundle -undefined dynamic_lookup' -+ LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup';; ++ LDSHARED='$(CC) -dynamiclib -undefined dynamic_lookup' ++ LDCXXSHARED='$(CXX) -dynamiclib -undefined dynamic_lookup';; Emscripten|WASI) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; -@@ -3640,20 +3715,30 @@ +@@ -3640,20 +3716,30 @@ esac AC_MSG_RESULT($with_system_ffi) else @@ -2528,7 +2627,7 @@ index e1cbb7c7fb..9fd0afc76a 100644 # Check for use of the system libmpdec library AC_MSG_CHECKING(for --with-system-libmpdec) -@@ -6833,6 +6918,30 @@ +@@ -6833,6 +6919,30 @@ [AIX], [PY_STDLIB_MOD_SET_NA([_scproxy], [spwd])], [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [_crypt], [termios], [grp])], [Darwin], [PY_STDLIB_MOD_SET_NA([ossaudiodev], [spwd])], From b04ff0c243a34e74910c21afed475067024c3acd Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 5 Sep 2023 06:47:38 +0800 Subject: [PATCH 2/9] Modify framework naming to avoid name ambiguity. --- patch/Python/Python.patch | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index 18f46bd..e10596d 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -131,7 +131,7 @@ index 2ce5c5b64d..6e10a0c4a5 100644 import pwd os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py -index f603a89f7f..fe508e4615 100644 +index f603a89f7f..0339031178 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -52,7 +52,7 @@ @@ -143,7 +143,7 @@ index f603a89f7f..fe508e4615 100644 _CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY + _CASE_INSENSITIVE_PLATFORMS_STR_KEY) -@@ -1705,6 +1705,29 @@ +@@ -1705,6 +1705,30 @@ return 'FileFinder({!r})'.format(self.path) @@ -161,9 +161,10 @@ index f603a89f7f..fe508e4615 100644 + + def find_spec(self, fullname, path, target=None): + name = fullname.split(".")[-1] ++ framework_name = "_".join(fullname.split(".")) + + for extension in EXTENSION_SUFFIXES: -+ dylib_path = _path_join(self.frameworks_path, f"{name}.framework", f"{name}{extension}") ++ dylib_path = _path_join(self.frameworks_path, f"{framework_name}.framework", f"{name}{extension}") + if _path_isfile(dylib_path): + loader = ExtensionFileLoader(fullname, dylib_path) + return _bootstrap.spec_from_loader(fullname, loader) @@ -173,7 +174,7 @@ index f603a89f7f..fe508e4615 100644 # Import setup ############################################################### def _fix_up_module(ns, name, pathname, cpathname=None): -@@ -1752,3 +1775,9 @@ +@@ -1752,3 +1776,9 @@ supported_loaders = _get_supported_file_loaders() sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) sys.meta_path.append(PathFinder) From e720624d39d0c55f64100ab38dabdac301819a9e Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 6 Sep 2023 10:23:37 +0800 Subject: [PATCH 3/9] Modify Framework loader to return original dylib location in __file__. --- patch/Python/Python.patch | 49 ++++-- patch/libffi-3.4.2.patch | 320 -------------------------------------- 2 files changed, 39 insertions(+), 330 deletions(-) delete mode 100644 patch/libffi-3.4.2.patch diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index e10596d..d3b69a4 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -131,7 +131,7 @@ index 2ce5c5b64d..6e10a0c4a5 100644 import pwd os.environ['HOME'] = pwd.getpwuid(os.getuid())[5] diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py -index f603a89f7f..0339031178 100644 +index f603a89f7f..d6db040d0d 100644 --- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -52,7 +52,7 @@ @@ -143,18 +143,47 @@ index f603a89f7f..0339031178 100644 _CASE_INSENSITIVE_PLATFORMS = (_CASE_INSENSITIVE_PLATFORMS_BYTES_KEY + _CASE_INSENSITIVE_PLATFORMS_STR_KEY) -@@ -1705,6 +1705,30 @@ +@@ -1705,6 +1705,59 @@ return 'FileFinder({!r})'.format(self.path) ++class AppleFrameworkLoader(ExtensionFileLoader): ++ """A loader for modules that have been packaged as Apple Frameworks for ++ compatibility with Apple's App Store policies. ++ ++ For compatibility with the App Store, *all* binary modules must be in .dylibs, ++ contained in a Framework, in the ``Frameworks`` folder of the packaged app. If ++ you're trying to run "from foo import _bar", and _bar is implemented with the binary ++ module "foo/_bar.abi3.dylib" (or any other .dylib extension), this loader will look ++ for "{sys.executable}/Frameworks/foo__bar.framework/_bar.abi3.dylib" (forming the ++ package name by taking the full path of the library, and replacing ``/`` with ++ ``_``). The app packaging tool is responsible for putting the library in this ++ location. ++ ++ However, the ``__file__`` attribute of the _bar module will report as the original ++ location inside the ``foo`` directory. This so that code that depends on walking ++ directory trees will continue to work as expected based on the *original* file ++ location. ++ """ ++ def __init__(self, fullname, dylib_file, path): ++ super().__init__(fullname, dylib_file) ++ self.parent_paths = path ++ ++ def create_module(self, spec): ++ mod = super().create_module(spec) ++ if self.parent_paths: ++ for parent_path in self.parent_paths: ++ if _path_isdir(parent_path): ++ mod.__file__ = _path_join(parent_path, _path_split(self.path)[-1]) ++ continue ++ return mod ++ ++ +class AppleFrameworkFinder: + """A finder for modules that have been packaged as Apple Frameworks + for compatibility with Apple's App Store policies. + -+ For compatibility with the App Store, *all* binary modules must be in .dylibs, -+ contained in a Framework. If you're trying to run "from foo import _bar", and _bar -+ is implemented with the binary module "foo/_bar.abi3.dylib" (or any other .dylib -+ extension), this loader will look for "{sys.executable}/Frameworks/_bar.framework" ++ See AppleFrameworkLoader for details. + """ + def __init__(self, path): + self.frameworks_path = path @@ -164,9 +193,9 @@ index f603a89f7f..0339031178 100644 + framework_name = "_".join(fullname.split(".")) + + for extension in EXTENSION_SUFFIXES: -+ dylib_path = _path_join(self.frameworks_path, f"{framework_name}.framework", f"{name}{extension}") -+ if _path_isfile(dylib_path): -+ loader = ExtensionFileLoader(fullname, dylib_path) ++ dylib_file = _path_join(self.frameworks_path, f"{framework_name}.framework", f"{name}{extension}") ++ if _path_isfile(dylib_file): ++ loader = AppleFrameworkLoader(fullname, dylib_file, path) + return _bootstrap.spec_from_loader(fullname, loader) + + return None @@ -174,7 +203,7 @@ index f603a89f7f..0339031178 100644 # Import setup ############################################################### def _fix_up_module(ns, name, pathname, cpathname=None): -@@ -1752,3 +1776,9 @@ +@@ -1752,3 +1805,9 @@ supported_loaders = _get_supported_file_loaders() sys.path_hooks.extend([FileFinder.path_hook(*supported_loaders)]) sys.meta_path.append(PathFinder) diff --git a/patch/libffi-3.4.2.patch b/patch/libffi-3.4.2.patch deleted file mode 100644 index 7e3d9a2..0000000 --- a/patch/libffi-3.4.2.patch +++ /dev/null @@ -1,320 +0,0 @@ -diff --git a/generate-darwin-source-and-headers.py b/generate-darwin-source-and-headers.py -index 9921b0d..5b60ccc 100755 ---- a/generate-darwin-source-and-headers.py -+++ b/generate-darwin-source-and-headers.py -@@ -11,9 +11,8 @@ class Platform(object): - pass - - --class simulator_platform(Platform): -+class i386_platform(Platform): - arch = 'i386' -- triple = 'i386-apple-darwin11' - - prefix = "#ifdef __i386__\n\n" - suffix = "\n\n#endif" -@@ -21,9 +20,8 @@ class simulator_platform(Platform): - src_files = ['sysv.S', 'ffi.c', 'internal.h'] - - --class simulator64_platform(Platform): -+class x86_64_platform(Platform): - arch = 'x86_64' -- triple = 'x86_64-apple-darwin13' - - prefix = "#ifdef __x86_64__\n\n" - suffix = "\n\n#endif" -@@ -31,101 +29,146 @@ class simulator64_platform(Platform): - src_files = ['unix64.S', 'ffi64.c', 'ffiw64.c', 'win64.S', 'internal64.h', 'asmnames.h'] - - --class device_platform(Platform): -- arch = 'armv7' -- triple = 'arm-apple-darwin11' -+class arm64_platform(Platform): -+ arch = 'arm64' - -- prefix = "#ifdef __arm__\n\n" -+ prefix = "#ifdef __arm64__\n\n" - suffix = "\n\n#endif" -- src_dir = 'arm' -+ src_dir = 'aarch64' - src_files = ['sysv.S', 'ffi.c', 'internal.h'] - - --class device64_platform(Platform): -- arch = 'arm64' -- triple = 'aarch64-apple-darwin13' -+class armv7_platform(Platform): -+ arch = 'armv7' - -- prefix = "#ifdef __arm64__\n\n" -+ prefix = "#ifdef __arm__\n\n" - suffix = "\n\n#endif" -- src_dir = 'aarch64' -+ src_dir = 'arm' - src_files = ['sysv.S', 'ffi.c', 'internal.h'] - - --class ios_simulator_platform(simulator_platform): -+class ios_simulator_i386_platform(i386_platform): -+ triple = 'i386-apple-darwin11' -+ target = 'i386-apple-ios-simulator' -+ directory = 'darwin_ios' -+ sdk = 'iphonesimulator' -+ version_min = '-miphoneos-version-min=7.0' -+ -+ -+class ios_simulator_x86_64_platform(x86_64_platform): -+ triple = 'x86_64-apple-darwin13' -+ target = 'x86_64-apple-ios-simulator' - directory = 'darwin_ios' - sdk = 'iphonesimulator' - version_min = '-miphoneos-version-min=7.0' - - --class ios_simulator64_platform(simulator64_platform): -+class ios_simulator_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin20' -+ target = 'arm64-apple-ios-simulator' - directory = 'darwin_ios' - sdk = 'iphonesimulator' - version_min = '-miphoneos-version-min=7.0' - - --class ios_device_platform(device_platform): -+class ios_device_armv7_platform(armv7_platform): -+ triple = 'arm-apple-darwin11' -+ target = 'armv7-apple-ios' - directory = 'darwin_ios' - sdk = 'iphoneos' - version_min = '-miphoneos-version-min=7.0' - - --class ios_device64_platform(device64_platform): -+class ios_device_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin13' -+ target = 'arm64-apple-ios' - directory = 'darwin_ios' - sdk = 'iphoneos' - version_min = '-miphoneos-version-min=7.0' - - --class desktop32_platform(Platform): -+class desktop_x86_64_platform(x86_64_platform): -+ triple = 'x86_64-apple-darwin10' -+ target = 'x86_64-apple-macos' - directory = 'darwin_osx' - sdk = 'macosx' -- arch = 'i386' -- triple = 'i386-apple-darwin10' - version_min = '-mmacosx-version-min=10.6' -- src_dir = 'x86' -- src_files = ['sysv.S', 'ffi.c', 'internal.h'] -- -- prefix = "#ifdef __i386__\n\n" -- suffix = "\n\n#endif" - - --class desktop64_platform(Platform): -+class desktop_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin20' -+ target = 'arm64-apple-macos' - directory = 'darwin_osx' - sdk = 'macosx' -- arch = 'x86_64' -- triple = 'x86_64-apple-darwin10' -- version_min = '-mmacosx-version-min=10.6' -+ version_min = '-mmacosx-version-min=11.0' - -- prefix = "#ifdef __x86_64__\n\n" -- suffix = "\n\n#endif" -- src_dir = 'x86' -- src_files = ['unix64.S', 'ffi64.c', 'ffiw64.c', 'win64.S', 'internal64.h', 'asmnames.h'] -+ -+class tvos_simulator_x86_64_platform(x86_64_platform): -+ triple = 'x86_64-apple-darwin13' -+ target = 'x86_64-apple-tvos-simulator' -+ directory = 'darwin_tvos' -+ sdk = 'appletvsimulator' -+ version_min = '-mtvos-version-min=9.0' - - --class tvos_simulator64_platform(simulator64_platform): -+class tvos_simulator_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin20' -+ target = 'arm64-apple-tvos-simulator' - directory = 'darwin_tvos' - sdk = 'appletvsimulator' - version_min = '-mtvos-version-min=9.0' - - --class tvos_device64_platform(device64_platform): -+class tvos_device_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin13' -+ target = 'arm64-apple-tvos' - directory = 'darwin_tvos' - sdk = 'appletvos' - version_min = '-mtvos-version-min=9.0' - - --class watchos_simulator_platform(simulator_platform): -+class watchos_simulator_i386_platform(i386_platform): -+ triple = 'i386-apple-darwin11' -+ target = 'i386-apple-watchos-simulator' -+ directory = 'darwin_watchos' -+ sdk = 'watchsimulator' -+ version_min = '-mwatchos-version-min=4.0' -+ -+ -+class watchos_simulator_x86_64_platform(x86_64_platform): -+ triple = 'x86_64-apple-darwin13' -+ target = 'x86_64-apple-watchos-simulator' -+ directory = 'darwin_watchos' -+ sdk = 'watchsimulator' -+ version_min = '-mwatchos-version-min=4.0' -+ -+ -+class watchos_simulator_arm64_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin20' -+ target = 'arm64-apple-watchos-simulator' - directory = 'darwin_watchos' - sdk = 'watchsimulator' - version_min = '-mwatchos-version-min=4.0' - - --class watchos_device_platform(device_platform): -+class watchos_device_armv7k_platform(armv7_platform): -+ triple = 'arm-apple-darwin11' -+ target = 'armv7k-apple-watchos' - directory = 'darwin_watchos' - sdk = 'watchos' - arch = 'armv7k' - version_min = '-mwatchos-version-min=4.0' - - -+class watchos_device_arm64_32_platform(arm64_platform): -+ triple = 'aarch64-apple-darwin13' -+ target = 'arm64_32-apple-watchos' -+ directory = 'darwin_watchos' -+ sdk = 'watchos' -+ arch = 'arm64_32' -+ version_min = '-mwatchos-version-min=4.0' -+ -+ - def mkdir_p(path): - try: - os.makedirs(path) -@@ -175,7 +218,7 @@ def copy_src_platform_files(platform): - - def build_target(platform, platform_headers): - def xcrun_cmd(cmd): -- return 'xcrun -sdk %s %s -arch %s' % (platform.sdk, cmd, platform.arch) -+ return 'xcrun -sdk %s %s -target %s' % (platform.sdk, cmd, platform.target) - - tag='%s-%s' % (platform.sdk, platform.arch) - build_dir = 'build_%s' % tag -@@ -212,34 +255,46 @@ def generate_source_and_headers( - copy_files('include', 'darwin_common/include', pattern='*.h') - - if generate_ios: -- copy_src_platform_files(ios_simulator_platform) -- copy_src_platform_files(ios_simulator64_platform) -- copy_src_platform_files(ios_device_platform) -- copy_src_platform_files(ios_device64_platform) -+ # copy_src_platform_files(ios_simulator_i386_platform) -+ copy_src_platform_files(ios_simulator_x86_64_platform) -+ copy_src_platform_files(ios_simulator_arm64_platform) -+ # copy_src_platform_files(ios_device_armv7_platform) -+ copy_src_platform_files(ios_device_arm64_platform) - if generate_osx: -- copy_src_platform_files(desktop64_platform) -+ copy_src_platform_files(desktop_x86_64_platform) -+ copy_src_platform_files(desktop_arm64_platform) - if generate_tvos: -- copy_src_platform_files(tvos_simulator64_platform) -- copy_src_platform_files(tvos_device64_platform) -+ copy_src_platform_files(tvos_simulator_x86_64_platform) -+ copy_src_platform_files(tvos_simulator_arm64_platform) -+ copy_src_platform_files(tvos_device_arm64_platform) - if generate_watchos: -- copy_src_platform_files(watchos_simulator_platform) -- copy_src_platform_files(watchos_device_platform) -+ # copy_src_platform_files(watchos_simulator_i386_platform) -+ copy_src_platform_files(watchos_simulator_x86_64_platform) -+ # copy_src_platform_files(watchos_simulator_arm64_platform) -+ copy_src_platform_files(watchos_device_armv7k_platform) -+ copy_src_platform_files(watchos_device_arm64_32_platform) - - platform_headers = collections.defaultdict(set) - - if generate_ios: -- build_target(ios_simulator_platform, platform_headers) -- build_target(ios_simulator64_platform, platform_headers) -- build_target(ios_device_platform, platform_headers) -- build_target(ios_device64_platform, platform_headers) -+ # build_target(ios_simulator_i386_platform, platform_headers) -+ build_target(ios_simulator_x86_64_platform, platform_headers) -+ build_target(ios_simulator_arm64_platform, platform_headers) -+ # build_target(ios_device_armv7_platform, platform_headers) -+ build_target(ios_device_arm64_platform, platform_headers) - if generate_osx: -- build_target(desktop64_platform, platform_headers) -+ build_target(desktop_x86_64_platform, platform_headers) -+ build_target(desktop_arm64_platform, platform_headers) - if generate_tvos: -- build_target(tvos_simulator64_platform, platform_headers) -- build_target(tvos_device64_platform, platform_headers) -+ build_target(tvos_simulator_x86_64_platform, platform_headers) -+ build_target(tvos_simulator_arm64_platform, platform_headers) -+ build_target(tvos_device_arm64_platform, platform_headers) - if generate_watchos: -- build_target(watchos_simulator_platform, platform_headers) -- build_target(watchos_device_platform, platform_headers) -+ # build_target(watchos_simulator_i386_platform, platform_headers) -+ build_target(watchos_simulator_x86_64_platform, platform_headers) -+ build_target(watchos_simulator_arm64_platform, platform_headers) -+ # build_target(watchos_device_armv7k_platform, platform_headers) -+ build_target(watchos_device_arm64_32_platform, platform_headers) - - mkdir_p('darwin_common/include') - for header_name, tag_tuples in platform_headers.items(): -diff --git a/src/closures.c b/src/closures.c -index f7bead6..db7ec94 100644 ---- a/src/closures.c -+++ b/src/closures.c -@@ -134,7 +134,7 @@ ffi_tramp_is_present (__attribute__((unused)) void *ptr) - # define HAVE_MNTENT 1 - # endif - # if defined(_WIN32) || defined(__OS2__) --/* Windows systems may have Data Execution Protection (DEP) enabled, -+/* Windows systems may have Data Execution Protection (DEP) enabled, - which requires the use of VirtualMalloc/VirtualFree to alloc/free - executable memory. */ - # define FFI_MMAP_EXEC_WRIT 1 -@@ -230,12 +230,24 @@ ffi_trampoline_table_alloc (void) - kt = vm_remap (mach_task_self (), &trampoline_page, PAGE_MAX_SIZE, 0x0, - VM_FLAGS_OVERWRITE, mach_task_self (), trampoline_page_template, - FALSE, &cur_prot, &max_prot, VM_INHERIT_SHARE); -- if (kt != KERN_SUCCESS || !(cur_prot & VM_PROT_EXECUTE)) -+ if (kt != KERN_SUCCESS) - { - vm_deallocate (mach_task_self (), config_page, PAGE_MAX_SIZE * 2); - return NULL; - } - -+ if (!(cur_prot & VM_PROT_EXECUTE)) -+ { -+ /* If VM_PROT_EXECUTE isn't set on the remapped trampoline page, set it */ -+ kt = vm_protect (mach_task_self (), trampoline_page, PAGE_MAX_SIZE, -+ FALSE, cur_prot | VM_PROT_EXECUTE); -+ if (kt != KERN_SUCCESS) -+ { -+ vm_deallocate (mach_task_self (), config_page, PAGE_MAX_SIZE * 2); -+ return NULL; -+ } -+ } -+ - /* We have valid trampoline and config pages */ - table = calloc (1, sizeof (ffi_trampoline_table)); - table->free_count = FFI_TRAMPOLINE_COUNT; From d2e995613497b141fc154c4c23ab387a7e27f672 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 10 Sep 2023 07:27:31 +0800 Subject: [PATCH 4/9] Create aliases for CC etc. --- .gitignore | 1 + Makefile | 94 ++++++++++++++++++++++++++++-------------- patch/make-xcrun-alias | 9 ++++ 3 files changed, 73 insertions(+), 31 deletions(-) create mode 100755 patch/make-xcrun-alias diff --git a/.gitignore b/.gitignore index c382b0a..22c9b3e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.swp .envrc .vscode/ +alias/* archive/* build/* diff/* diff --git a/Makefile b/Makefile index 3f9ce1d..f44fefb 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,12 @@ # - Python-tvOS - build Python for tvOS # - Python-watchOS - build Python for watchOS -# Current director +# Current directory PROJECT_DIR=$(shell pwd) +# Add the alias folder to the path. +SHELL:=env PATH=$(PATH):$(PROJECT_DIR)/alias /bin/bash + BUILD_NUMBER=custom # Version of packages that will be compiled by this meta-package @@ -97,7 +100,7 @@ BDIST_WHEEL=$(HOST_PYTHON)/lib/python$(PYTHON_VER)/site-packages/wheel/bdist_whe PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin # Build for all operating systems -all: $(OS_LIST) +all: $(OS_LIST) wheels .PHONY: \ all clean distclean update-patch vars wheels \ @@ -107,7 +110,7 @@ all: $(OS_LIST) # Clean all builds clean: - rm -rf build install merge dist support wheels + rm -rf alias build install merge dist support wheels # Full clean - includes all downloaded products distclean: clean @@ -136,6 +139,9 @@ update-patch: -X $(PROJECT_DIR)/patch/Python/diff.exclude -p 1 --clean \ > $(PROJECT_DIR)/patch/Python/Python.patch +alias: + mkdir -p $(PROJECT_DIR)/alias + ########################################################################### # Setup: BZip2 ########################################################################### @@ -221,13 +227,21 @@ TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))-simulato endif SDK_ROOT-$(target)=$$(shell xcrun --sdk $$(SDK-$(target)) --show-sdk-path) -CC-$(target)=xcrun --sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -CPP-$(target)=xcrun --sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E -CXX-$(target)=xcrun --sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -AR-$(target)=xcrun --sdk $$(SDK-$(target)) ar CFLAGS-$(target)=$$(CFLAGS-$(os)) LDFLAGS-$(target)=$$(CFLAGS-$(os)) +########################################################################### +# Target: Aliases +########################################################################### + +alias/clang-$(target): alias + patch/make-xcrun-alias alias/clang-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" + +alias/cpp-$(target): alias + patch/make-xcrun-alias alias/cpp-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" + +aliases-$(target): aliases-$$(SDK-$(target)) alias/clang-$(target) alias/cpp-$(target) + ########################################################################### # Target: BZip2 ########################################################################### @@ -245,12 +259,12 @@ $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz # Touch the makefile to ensure that Make identifies it as up to date. touch $$(BZIP2_SRCDIR-$(target))/Makefile -$$(BZIP2_LIB-$(target)): $$(BZIP2_SRCDIR-$(target))/Makefile +$$(BZIP2_LIB-$(target)): aliases-$(target) $$(BZIP2_SRCDIR-$(target))/Makefile @echo ">>> Build BZip2 for $(target)" cd $$(BZIP2_SRCDIR-$(target)) && \ make install \ PREFIX="$$(BZIP2_INSTALL-$(target))" \ - CC="$$(CC-$(target))" \ + CC=clang-$(target) \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ 2>&1 | tee -a ../bzip2-$(BZIP2_VERSION).build.log @@ -295,16 +309,18 @@ XZ_LIB-$(target)=$$(XZ_INSTALL-$(target))/lib/liblzma.a XZ_WHEEL-$(target)=wheels/dist/xz/xz-$(XZ_VERSION)-1-$$(WHEEL_TAG-$(target)).whl XZ_WHEEL_DISTINFO-$(target)=$$(XZ_INSTALL-$(target))/wheel/xz-$(XZ_VERSION).dist-info -$$(XZ_SRCDIR-$(target))/Makefile: downloads/xz-$(XZ_VERSION).tar.gz +$$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz @echo ">>> Unpack XZ sources for $(target)" mkdir -p $$(XZ_SRCDIR-$(target)) tar zxf $$< --strip-components 1 -C $$(XZ_SRCDIR-$(target)) # Patch the source to add support for new platforms cd $$(XZ_SRCDIR-$(target)) && patch -p1 < $(PROJECT_DIR)/patch/xz-$(XZ_VERSION).patch + +$$(XZ_SRCDIR-$(target))/Makefile: aliases-$(target) $$(XZ_SRCDIR-$(target))/configure # Configure the build cd $$(XZ_SRCDIR-$(target)) && \ ./configure \ - CC="$$(CC-$(target))" \ + CC=clang-$(target) \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ --disable-shared \ @@ -362,7 +378,7 @@ OPENSSL_CRYPTO_LIB-$(target)=$$(OPENSSL_INSTALL-$(target))/lib/libcrypto.a OPENSSL_WHEEL-$(target)=wheels/dist/openssl/openssl-$(OPENSSL_VERSION)-1-$$(WHEEL_TAG-$(target)).whl OPENSSL_WHEEL_DISTINFO-$(target)=$$(OPENSSL_INSTALL-$(target))/wheel/openssl-$(OPENSSL_VERSION).dist-info -$$(OPENSSL_SRCDIR-$(target))/is_configured: downloads/openssl-$(OPENSSL_VERSION).tar.gz +$$(OPENSSL_SRCDIR-$(target))/Configure: downloads/openssl-$(OPENSSL_VERSION).tar.gz @echo ">>> Unpack and configure OpenSSL sources for $(target)" mkdir -p $$(OPENSSL_SRCDIR-$(target)) tar zxf $$< --strip-components 1 -C $$(OPENSSL_SRCDIR-$(target)) @@ -378,17 +394,19 @@ else endif endif + +$$(OPENSSL_SRCDIR-$(target))/is_configured: aliases-$(target) $$(OPENSSL_SRCDIR-$(target))/Configure # Configure the OpenSSL build ifeq ($(os),macOS) cd $$(OPENSSL_SRCDIR-$(target)) && \ - CC="$$(CC-$(target)) $$(CFLAGS-$(target))" \ + CC="clang-$(target) $$(CFLAGS-$(target))" \ ./Configure darwin64-$$(ARCH-$(target))-cc no-tests \ --prefix="$$(OPENSSL_INSTALL-$(target))" \ --openssldir=/etc/ssl \ 2>&1 | tee -a ../openssl-$(OPENSSL_VERSION).config.log else cd $$(OPENSSL_SRCDIR-$(target)) && \ - CC="$$(CC-$(target)) $$(CFLAGS-$(target))" \ + CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ ./Configure iphoneos-cross no-asm no-tests \ @@ -408,7 +426,7 @@ $$(OPENSSL_SRCDIR-$(target))/libssl.a: $$(OPENSSL_SRCDIR-$(target))/is_configure # OpenSSL's `all` target modifies the Makefile; # use the raw targets that make up all and it's dependencies cd $$(OPENSSL_SRCDIR-$(target)) && \ - CC="$$(CC-$(target)) $$(CFLAGS-$(target))" \ + CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ make build_sw \ @@ -418,7 +436,7 @@ $$(OPENSSL_SSL_LIB-$(target)): $$(OPENSSL_SRCDIR-$(target))/libssl.a @echo ">>> Install OpenSSL for $(target)" # Install just the software (not the docs) cd $$(OPENSSL_SRCDIR-$(target)) && \ - CC="$$(CC-$(target)) $$(CFLAGS-$(target))" \ + CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ make install_sw \ @@ -531,7 +549,7 @@ PYTHON_SRCDIR-$(target)=build/$(os)/$(target)/python-$(PYTHON_VERSION) PYTHON_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/python-$(PYTHON_VERSION) PYTHON_LIB-$(target)=$$(PYTHON_INSTALL-$(target))/lib/libpython$(PYTHON_VER).a -$$(PYTHON_SRCDIR-$(target))/Makefile: \ +$$(PYTHON_SRCDIR-$(target))/configure: \ downloads/Python-$(PYTHON_VERSION).tar.gz \ $$(BZIP2_FATLIB-$$(SDK-$(target))) \ $$(XZ_FATLIB-$$(SDK-$(target))) \ @@ -543,13 +561,15 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \ tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(target)) # Apply target Python patches cd $$(PYTHON_SRCDIR-$(target)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch + +$$(PYTHON_SRCDIR-$(target))/Makefile: aliases-$(target) $$(PYTHON_SRCDIR-$(target))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(target)) && \ ./configure \ - AR="$$(AR-$(target))" \ - CC="$$(CC-$(target))" \ - CPP="$$(CPP-$(target))" \ - CXX="$$(CXX-$(target))" \ + AR=ar-$$(SDK-$(target)) \ + CC=clang-$(target) \ + CPP=cpp-$(target) \ + CXX=clang-$(target) \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ LIBLZMA_CFLAGS="-I$$(XZ_MERGE-$$(SDK-$(target)))/include" \ @@ -595,8 +615,6 @@ vars-$(target): @echo "ARCH-$(target): $$(ARCH-$(target))" @echo "TARGET_TRIPLE-$(target): $$(TARGET_TRIPLE-$(target))" @echo "SDK_ROOT-$(target): $$(SDK_ROOT-$(target))" - @echo "CC-$(target): $$(CC-$(target))" - @echo "CPP-$(target): $$(CPP-$(target))" @echo "CFLAGS-$(target): $$(CFLAGS-$(target))" @echo "LDFLAGS-$(target): $$(LDFLAGS-$(target))" @echo "BZIP2_SRCDIR-$(target): $$(BZIP2_SRCDIR-$(target))" @@ -650,8 +668,6 @@ else SDK_SLICE-$(sdk)=$$(OS_LOWER-$(sdk))-$$(shell echo $$(SDK_ARCHES-$(sdk)) | sed "s/ /_/g")-simulator endif -CC-$(sdk)=xcrun --sdk $(sdk) clang -CPP-$(sdk)=xcrun --sdk $(sdk) clang -E CFLAGS-$(sdk)=$$(CFLAGS-$(os)) LDFLAGS-$(sdk)=$$(CFLAGS-$(os)) @@ -679,6 +695,21 @@ PYTHON_FATSTDLIB-$(sdk)=$$(PYTHON_MERGE-$(sdk))/python-stdlib # Expand the build-target macro for target on this OS $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(eval $$(call build-target,$$(target),$(os)))) +########################################################################### +# SDK: Aliases +########################################################################### + +alias/clang-$(sdk): alias + patch/make-xcrun-alias alias/clang-$(sdk) "--sdk $(sdk) clang" + +alias/cpp-$(sdk): alias + patch/make-xcrun-alias alias/cpp-$(sdk) "--sdk $(sdk) clang -E" + +alias/ar-$(sdk): alias + patch/make-xcrun-alias alias/ar-$(sdk) "--sdk $(sdk) ar" + +aliases-$(sdk): alias/clang-$(sdk) alias/cpp-$(sdk) alias/ar-$(sdk) + ########################################################################### # SDK: BZip2 ########################################################################### @@ -754,7 +785,7 @@ PYTHON_SRCDIR-$(sdk)=build/$(os)/$(sdk)/python-$(PYTHON_VERSION) PYTHON_INSTALL-$(sdk)=$(PROJECT_DIR)/install/$(os)/$(sdk)/python-$(PYTHON_VERSION) PYTHON_LIB-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/lib/libpython$(PYTHON_VER).a -$$(PYTHON_SRCDIR-$(sdk))/Makefile: \ +$$(PYTHON_SRCDIR-$(sdk))/configure: \ $$(BZIP2_FATLIB-$$(sdk)) \ $$(XZ_FATLIB-$$(sdk)) \ $$(OPENSSL_FATINCLUDE-$$(sdk)) $$(OPENSSL_SSL_FATLIB-$$(sdk)) $$(OPENSSL_CRYPTO_FATLIB-$$(sdk)) \ @@ -764,11 +795,14 @@ $$(PYTHON_SRCDIR-$(sdk))/Makefile: \ tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(sdk)) # Apply target Python patches cd $$(PYTHON_SRCDIR-$(sdk)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch + + +$$(PYTHON_SRCDIR-$(sdk))/Makefile: aliases-$(sdk) $$(PYTHON_SRCDIR-$(sdk))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(sdk)) && \ ./configure \ - CC="$$(CC-$(sdk))" \ - CPP="$$(CPP-$(sdk))" \ + CC=clang-$(sdk) \ + CPP=cpp-$(sdk) \ CFLAGS="$$(CFLAGS-$(sdk))" \ LDFLAGS="$$(LDFLAGS-$(sdk))" \ LIBLZMA_CFLAGS="-I$$(XZ_MERGE-$(sdk))/include" \ @@ -870,8 +904,6 @@ vars-$(sdk): @echo "SDK_TARGETS-$(sdk): $$(SDK_TARGETS-$(sdk))" @echo "SDK_ARCHES-$(sdk): $$(SDK_ARCHES-$(sdk))" @echo "SDK_SLICE-$(sdk): $$(SDK_SLICE-$(sdk))" - @echo "CC-$(sdk): $$(CC-$(sdk))" - @echo "CPP-$(sdk): $$(CPP-$(sdk))" @echo "CFLAGS-$(sdk): $$(CFLAGS-$(sdk))" @echo "LDFLAGS-$(sdk): $$(LDFLAGS-$(sdk))" @echo "BZIP2_MERGE-$(sdk): $$(BZIP2_MERGE-$(sdk))" @@ -1139,7 +1171,7 @@ clean-$(os): install/$(os) \ merge/$(os) \ dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz \ - dist/Python-$(PYTHON_VER)-$(os)-support.test-$(BUILD_NUMBER).tar.gz \ + dist/Python-$(PYTHON_VER)-$(os)-support.test-$(BUILD_NUMBER).tar.gz clean-wheels-$(os): $(foreach dep,$(DEPENDENCIES),clean-$(dep)-wheels-$(os)) diff --git a/patch/make-xcrun-alias b/patch/make-xcrun-alias new file mode 100755 index 0000000..e30290e --- /dev/null +++ b/patch/make-xcrun-alias @@ -0,0 +1,9 @@ +#!/bin/bash +# A script that writes an executable xcrun alias. +# Arg 1: The name of the file to output +# Arg 2: The arguments to pass to xcrun +cat << EOF > $1 +#!/bin/bash +xcrun $2 \$@ +EOF +chmod +x $1 From dfc10ff8c131cf054528ae038764f2ccaf9c8f78 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 10 Sep 2023 07:27:49 +0800 Subject: [PATCH 5/9] Purge .dylibs from iOS packages. --- patch/Python/release.common.exclude | 6 +----- patch/Python/release.iOS.exclude | 4 ++++ patch/Python/release.macOS.exclude | 4 ++++ patch/Python/release.tvOS.exclude | 4 ++++ patch/Python/release.watchOS.exclude | 4 ++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/patch/Python/release.common.exclude b/patch/Python/release.common.exclude index 8f11eac..bec2b86 100644 --- a/patch/Python/release.common.exclude +++ b/patch/Python/release.common.exclude @@ -18,13 +18,9 @@ python-stdlib/idlelib python-stdlib/tkinter python-stdlib/turtle.py python-stdlib/turtledemo -# Remove the testing binary modules -python-stdlib/lib-dynload/_test*.so -python-stdlib/lib-dynload/_xx*.so -python-stdlib/lib-dynload/xx*.so # Remove site-packages directory. The template unpacks user code and # dependencies to a different path. python-stdlib/site-packages # Remove pyc files. These take up space, but since most stdlib modules are # never imported by user code, they mostly have no value. -*/__pycache__ \ No newline at end of file +*/__pycache__ diff --git a/patch/Python/release.iOS.exclude b/patch/Python/release.iOS.exclude index 471b190..3bd9b2e 100644 --- a/patch/Python/release.iOS.exclude +++ b/patch/Python/release.iOS.exclude @@ -4,3 +4,7 @@ # # Remove command-line curses toolkit. python-stdlib/curses +# Remove the testing binary modules +python-stdlib/lib-dynload/_test*.dylib +python-stdlib/lib-dynload/_xx*.dylib +python-stdlib/lib-dynload/xx*.dylib diff --git a/patch/Python/release.macOS.exclude b/patch/Python/release.macOS.exclude index 20009bb..a5bcd4a 100644 --- a/patch/Python/release.macOS.exclude +++ b/patch/Python/release.macOS.exclude @@ -2,3 +2,7 @@ # from macOS Python-Apple-support tarballs. # It is used by `tar -X` during the Makefile build. # +# Remove the testing binary modules +python-stdlib/lib-dynload/_test*.so +python-stdlib/lib-dynload/_xx*.so +python-stdlib/lib-dynload/xx*.so diff --git a/patch/Python/release.tvOS.exclude b/patch/Python/release.tvOS.exclude index 0aeb430..a1d6026 100644 --- a/patch/Python/release.tvOS.exclude +++ b/patch/Python/release.tvOS.exclude @@ -4,3 +4,7 @@ # # Remove command-line curses toolkit. Python/Resources/lib/python*/curses +# Remove the testing binary modules +python-stdlib/lib-dynload/_test*.dylib +python-stdlib/lib-dynload/_xx*.dylib +python-stdlib/lib-dynload/xx*.dylib diff --git a/patch/Python/release.watchOS.exclude b/patch/Python/release.watchOS.exclude index e41e7a4..708d846 100644 --- a/patch/Python/release.watchOS.exclude +++ b/patch/Python/release.watchOS.exclude @@ -4,3 +4,7 @@ # # Remove command-line curses toolkit. Python/Resources/lib/python*/curses +# Remove the testing binary modules +python-stdlib/lib-dynload/_test*.dylib +python-stdlib/lib-dynload/_xx*.dylib +python-stdlib/lib-dynload/xx*.dylib From a7beb2a043fad8f35de37096b79331d08e257f3b Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 10 Sep 2023 17:28:40 +0800 Subject: [PATCH 6/9] Rework how aliases are created and referenced. --- Makefile | 68 ++++++++++++++++++++++++++---------------- patch/make-xcrun-alias | 1 + 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index f44fefb..fe1120f 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,6 @@ # Current directory PROJECT_DIR=$(shell pwd) -# Add the alias folder to the path. -SHELL:=env PATH=$(PATH):$(PROJECT_DIR)/alias /bin/bash - BUILD_NUMBER=custom # Version of packages that will be compiled by this meta-package @@ -139,9 +136,6 @@ update-patch: -X $(PROJECT_DIR)/patch/Python/diff.exclude -p 1 --clean \ > $(PROJECT_DIR)/patch/Python/Python.patch -alias: - mkdir -p $(PROJECT_DIR)/alias - ########################################################################### # Setup: BZip2 ########################################################################### @@ -234,14 +228,12 @@ LDFLAGS-$(target)=$$(CFLAGS-$(os)) # Target: Aliases ########################################################################### -alias/clang-$(target): alias +alias/clang-$(target): patch/make-xcrun-alias alias/clang-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" -alias/cpp-$(target): alias +alias/cpp-$(target): patch/make-xcrun-alias alias/cpp-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" -aliases-$(target): aliases-$$(SDK-$(target)) alias/clang-$(target) alias/cpp-$(target) - ########################################################################### # Target: BZip2 ########################################################################### @@ -259,9 +251,10 @@ $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz # Touch the makefile to ensure that Make identifies it as up to date. touch $$(BZIP2_SRCDIR-$(target))/Makefile -$$(BZIP2_LIB-$(target)): aliases-$(target) $$(BZIP2_SRCDIR-$(target))/Makefile +$$(BZIP2_LIB-$(target)): alias/clang-$(target) $$(BZIP2_SRCDIR-$(target))/Makefile @echo ">>> Build BZip2 for $(target)" cd $$(BZIP2_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ make install \ PREFIX="$$(BZIP2_INSTALL-$(target))" \ CC=clang-$(target) \ @@ -315,10 +308,13 @@ $$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz tar zxf $$< --strip-components 1 -C $$(XZ_SRCDIR-$(target)) # Patch the source to add support for new platforms cd $$(XZ_SRCDIR-$(target)) && patch -p1 < $(PROJECT_DIR)/patch/xz-$(XZ_VERSION).patch + # Touch the configure script to ensure that Make identifies it as up to date. + touch $$(XZ_SRCDIR-$(target))/configure -$$(XZ_SRCDIR-$(target))/Makefile: aliases-$(target) $$(XZ_SRCDIR-$(target))/configure +$$(XZ_SRCDIR-$(target))/Makefile: alias/clang-$(target) $$(XZ_SRCDIR-$(target))/configure # Configure the build cd $$(XZ_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ CC=clang-$(target) \ CFLAGS="$$(CFLAGS-$(target))" \ @@ -333,6 +329,7 @@ $$(XZ_SRCDIR-$(target))/Makefile: aliases-$(target) $$(XZ_SRCDIR-$(target))/conf $$(XZ_LIB-$(target)): $$(XZ_SRCDIR-$(target))/Makefile @echo ">>> Build and install XZ for $(target)" cd $$(XZ_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ make install \ 2>&1 | tee -a ../xz-$(XZ_VERSION).build.log @@ -393,12 +390,15 @@ else sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/speed.c endif endif + # Touch the Configure script to ensure that Make identifies it as up to date. + touch $$(OPENSSL_SRCDIR-$(target))/Configure -$$(OPENSSL_SRCDIR-$(target))/is_configured: aliases-$(target) $$(OPENSSL_SRCDIR-$(target))/Configure +$$(OPENSSL_SRCDIR-$(target))/is_configured: alias/clang-$(target) $$(OPENSSL_SRCDIR-$(target))/Configure # Configure the OpenSSL build ifeq ($(os),macOS) cd $$(OPENSSL_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ CC="clang-$(target) $$(CFLAGS-$(target))" \ ./Configure darwin64-$$(ARCH-$(target))-cc no-tests \ --prefix="$$(OPENSSL_INSTALL-$(target))" \ @@ -406,6 +406,7 @@ ifeq ($(os),macOS) 2>&1 | tee -a ../openssl-$(OPENSSL_VERSION).config.log else cd $$(OPENSSL_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -426,6 +427,7 @@ $$(OPENSSL_SRCDIR-$(target))/libssl.a: $$(OPENSSL_SRCDIR-$(target))/is_configure # OpenSSL's `all` target modifies the Makefile; # use the raw targets that make up all and it's dependencies cd $$(OPENSSL_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -436,6 +438,7 @@ $$(OPENSSL_SSL_LIB-$(target)): $$(OPENSSL_SRCDIR-$(target))/libssl.a @echo ">>> Install OpenSSL for $(target)" # Install just the software (not the docs) cd $$(OPENSSL_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ CC="clang-$(target) $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -561,10 +564,17 @@ $$(PYTHON_SRCDIR-$(target))/configure: \ tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(target)) # Apply target Python patches cd $$(PYTHON_SRCDIR-$(target)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch - -$$(PYTHON_SRCDIR-$(target))/Makefile: aliases-$(target) $$(PYTHON_SRCDIR-$(target))/configure + # Touch the configure script to ensure that Make identifies it as up to date. + touch $$(PYTHON_SRCDIR-$(target))/configure + +$$(PYTHON_SRCDIR-$(target))/Makefile: \ + alias/ar-$$(SDK-$(target)) \ + alias/clang-$(target) \ + alias/cpp-$(target) \ + $$(PYTHON_SRCDIR-$(target))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(target)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ AR=ar-$$(SDK-$(target)) \ CC=clang-$(target) \ @@ -594,14 +604,16 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: aliases-$(target) $$(PYTHON_SRCDIR-$(targe $$(PYTHON_SRCDIR-$(target))/python.exe: $$(PYTHON_SRCDIR-$(target))/Makefile @echo ">>> Build Python for $(target)" cd $$(PYTHON_SRCDIR-$(target)) && \ - make all \ - 2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + make all \ + 2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log $$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe @echo ">>> Install Python for $(target)" cd $$(PYTHON_SRCDIR-$(target)) && \ - make install \ - 2>&1 | tee -a ../python-$(PYTHON_VERSION).install.log + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + make install \ + 2>&1 | tee -a ../python-$(PYTHON_VERSION).install.log endif @@ -699,17 +711,15 @@ $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(eval $$(call build-target,$$(target) # SDK: Aliases ########################################################################### -alias/clang-$(sdk): alias +alias/clang-$(sdk): patch/make-xcrun-alias alias/clang-$(sdk) "--sdk $(sdk) clang" -alias/cpp-$(sdk): alias +alias/cpp-$(sdk): patch/make-xcrun-alias alias/cpp-$(sdk) "--sdk $(sdk) clang -E" -alias/ar-$(sdk): alias +alias/ar-$(sdk): patch/make-xcrun-alias alias/ar-$(sdk) "--sdk $(sdk) ar" -aliases-$(sdk): alias/clang-$(sdk) alias/cpp-$(sdk) alias/ar-$(sdk) - ########################################################################### # SDK: BZip2 ########################################################################### @@ -795,11 +805,16 @@ $$(PYTHON_SRCDIR-$(sdk))/configure: \ tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(sdk)) # Apply target Python patches cd $$(PYTHON_SRCDIR-$(sdk)) && patch -p1 < $(PROJECT_DIR)/patch/Python/Python.patch + # Touch the configure script to ensure that Make identifies it as up to date. + touch $$(PYTHON_SRCDIR-$(sdk))/configure - -$$(PYTHON_SRCDIR-$(sdk))/Makefile: aliases-$(sdk) $$(PYTHON_SRCDIR-$(sdk))/configure +$$(PYTHON_SRCDIR-$(sdk))/Makefile: \ + alias/clang-$(sdk) \ + alias/cpp-$(sdk) \ + $$(PYTHON_SRCDIR-$(sdk))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(sdk)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ CC=clang-$(sdk) \ CPP=cpp-$(sdk) \ @@ -821,6 +836,7 @@ $$(PYTHON_SRCDIR-$(sdk))/python.exe: \ $$(PYTHON_SRCDIR-$(sdk))/Makefile @echo ">>> Build Python for $(sdk)" cd $$(PYTHON_SRCDIR-$(sdk)) && \ + PATH="$(PROJECT_DIR)/alias:$(PATH)" \ make all \ 2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log diff --git a/patch/make-xcrun-alias b/patch/make-xcrun-alias index e30290e..50340e1 100755 --- a/patch/make-xcrun-alias +++ b/patch/make-xcrun-alias @@ -2,6 +2,7 @@ # A script that writes an executable xcrun alias. # Arg 1: The name of the file to output # Arg 2: The arguments to pass to xcrun +mkdir -p $(dirname $1) cat << EOF > $1 #!/bin/bash xcrun $2 \$@ From a96029e0949809241eee459ea1b45ed1249e08bc Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 13 Sep 2023 10:54:00 +0800 Subject: [PATCH 7/9] Rationalize usage of platform and multiarch. --- Makefile | 52 +-- patch/Python/Python.patch | 438 ++++++++++++++---- patch/Python/_sysconfigdata__ios_iphoneos.py | 2 - .../_sysconfigdata__ios_iphonesimulator.py | 11 - .../Python/_sysconfigdata__tvos_appletvos.py | 2 - .../_sysconfigdata__tvos_appletvsimulator.py | 11 - .../Python/_sysconfigdata__watchos_watchos.py | 2 - .../_sysconfigdata__watchos_watchsimulator.py | 11 - patch/Python/pyconfig-watchOS.h | 6 +- 9 files changed, 366 insertions(+), 169 deletions(-) delete mode 100644 patch/Python/_sysconfigdata__ios_iphoneos.py delete mode 100644 patch/Python/_sysconfigdata__ios_iphonesimulator.py delete mode 100644 patch/Python/_sysconfigdata__tvos_appletvos.py delete mode 100644 patch/Python/_sysconfigdata__tvos_appletvsimulator.py delete mode 100644 patch/Python/_sysconfigdata__watchos_watchos.py delete mode 100644 patch/Python/_sysconfigdata__watchos_watchsimulator.py diff --git a/Makefile b/Makefile index fe1120f..b103de6 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,8 @@ all: $(OS_LIST) wheels .PHONY: \ all clean distclean update-patch vars wheels \ $(foreach product,$(PRODUCTS),$(product) $(foreach os,$(OS_LIST),$(product)-$(os) clean-$(product) clean-$(product)-$(os))) \ - $(foreach product,$(PRODUCTS),$(product)-wheels $(foreach os,$(OS_LIST),$(product)-wheels-$(os) clean-$(product)-wheels-$(os))) \ - $(foreach os,$(OS_LIST),$(os) wheels-$(os) clean-$(os) clean-wheels-$(os) vars-$(os)) + $(foreach product,$(PRODUCTS),$(product)-wheels $(foreach os,$(OS_LIST),$(product)-$(os)-wheels clean-$(product)-$(os)-wheels)) \ + $(foreach os,$(OS_LIST),$(os) $(os)-wheels clean-$(os) clean-$(os)-wheels vars-$(os)) # Clean all builds clean: @@ -204,12 +204,13 @@ target=$1 os=$2 OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') -WHEEL_TAG-$(target)=py3-none-$$(OS_LOWER-$(target))_$$(shell echo $$(VERSION_MIN-$(os))_$(target) | sed "s/\./_/g") # $(target) can be broken up into is composed of $(SDK).$(ARCH) SDK-$(target)=$$(basename $(target)) ARCH-$(target)=$$(subst .,,$$(suffix $(target))) +WHEEL_TAG-$(target)=py3-none-$$(SDK-$(target))_$$(shell echo $$(VERSION_MIN-$(os))_$$(ARCH-$(target)) | sed "s/\./_/g") + ifeq ($(os),macOS) TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-darwin else @@ -896,14 +897,11 @@ $$(PYTHON_FATSTDLIB-$(sdk)): $$(PYTHON_FATLIB-$(sdk)) $$(PYTHON_FATSTDLIB-$(sdk))/config-* \ $$(PYTHON_FATSTDLIB-$(sdk))/lib-dynload/* - # Copy the cross-target _sysconfigdata module from the patch folder - cp $(PROJECT_DIR)/patch/Python/_sysconfigdata__$$(OS_LOWER-$(sdk))_$(sdk).py $$(PYTHON_FATSTDLIB-$(sdk)) - # Copy the individual _sysconfigdata modules into names that include the architecture - $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INSTALL-$$(target))/lib/python$(PYTHON_VER)/_sysconfigdata__$$(OS_LOWER-$(sdk))_$(sdk).py $$(PYTHON_FATSTDLIB-$(sdk))/_sysconfigdata__$$(OS_LOWER-$(sdk))_$(sdk)_$$(ARCH-$$(target)).py; ) + $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INSTALL-$$(target))/lib/python$(PYTHON_VER)/_sysconfigdata_* $$(PYTHON_FATSTDLIB-$(sdk))/; ) # Copy the individual config modules directories into names that include the architecture - $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp -r $$(PYTHON_INSTALL-$$(target))/lib/python$(PYTHON_VER)/config-$(PYTHON_VER)-$(sdk) $$(PYTHON_FATSTDLIB-$(sdk))/config-$(PYTHON_VER)-$$(target); ) + $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp -r $$(PYTHON_INSTALL-$$(target))/lib/python$(PYTHON_VER)/config-$(PYTHON_VER)-$(sdk)-$$(ARCH-$$(target)) $$(PYTHON_FATSTDLIB-$(sdk))/; ) # Merge the binary modules from each target in the $(sdk) SDK into a single binary $$(foreach module,$$(wildcard $$(PYTHON_INSTALL-$$(firstword $$(SDK_TARGETS-$(sdk))))/lib/python$(PYTHON_VER)/lib-dynload/*),lipo -create -output $$(PYTHON_FATSTDLIB-$(sdk))/lib-dynload/$$(notdir $$(module)) $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_INSTALL-$$(target))/lib/python$(PYTHON_VER)/lib-dynload/$$(notdir $$(module))); ) @@ -972,7 +970,7 @@ $$(foreach sdk,$$(SDKS-$(os)),$$(eval $$(call build-sdk,$$(sdk),$(os)))) ########################################################################### BZip2-$(os): $$(foreach sdk,$$(SDKS-$(os)),$$(BZIP2_FATLIB-$$(sdk))) -BZip2-wheels-$(os): $$(foreach target,$$(TARGETS-$(os)),$$(BZIP2_WHEEL-$$(target))) +BZip2-$(os)-wheels: $$(foreach target,$$(TARGETS-$(os)),$$(BZIP2_WHEEL-$$(target))) clean-BZip2-$(os): @echo ">>> Clean BZip2 build products on $(os)" @@ -985,7 +983,7 @@ clean-BZip2-$(os): merge/$(os)/*/bzip2-$(BZIP2_VERSION).*.log \ wheels/dist/bzip2 -clean-BZip2-wheels-$(os): +clean-BZip2-$(os)-wheels: rm -rf \ install/$(os)/*/bzip2-$(BZIP2_VERSION)/wheel \ wheels/dist/bzip2 @@ -995,7 +993,7 @@ clean-BZip2-wheels-$(os): ########################################################################### XZ-$(os): $$(foreach sdk,$$(SDKS-$(os)),$$(XZ_FATLIB-$$(sdk))) -XZ-wheels-$(os): $$(foreach target,$$(TARGETS-$(os)),$$(XZ_WHEEL-$$(target))) +XZ-$(os)-wheels: $$(foreach target,$$(TARGETS-$(os)),$$(XZ_WHEEL-$$(target))) clean-XZ-$(os): @echo ">>> Clean XZ build products on $(os)" @@ -1008,7 +1006,7 @@ clean-XZ-$(os): merge/$(os)/*/xz-$(XZ_VERSION).*.log \ wheels/dist/xz -clean-XZ-wheels-$(os): +clean-XZ-$(os)-wheels: rm -rf \ install/$(os)/*/xz-$(XZ_VERSION)/wheel \ wheels/dist/xz @@ -1018,7 +1016,7 @@ clean-XZ-wheels-$(os): ########################################################################### OpenSSL-$(os): $$(foreach sdk,$$(SDKS-$(os)),$$(OPENSSL_FATINCLUDE-$$(sdk)) $$(OPENSSL_SSL_FATLIB-$$(sdk)) $$(OPENSSL_CRYPTO_FATLIB-$$(sdk))) -OpenSSL-wheels-$(os): $$(foreach target,$$(TARGETS-$(os)),$$(OPENSSL_WHEEL-$$(target))) +OpenSSL-$(os)-wheels: $$(foreach target,$$(TARGETS-$(os)),$$(OPENSSL_WHEEL-$$(target))) clean-OpenSSL-$(os): @echo ">>> Clean OpenSSL build products on $(os)" @@ -1031,7 +1029,7 @@ clean-OpenSSL-$(os): merge/$(os)/*/openssl-$(OPENSSL_VERSION).*.log \ wheels/dist/openssl -clean-OpenSSL-wheels-$(os): +clean-OpenSSL-$(os)-wheels: rm -rf \ install/$(os)/*/openssl-$(OPENSSL_VERSION)/wheel \ wheels/dist/openssl @@ -1058,7 +1056,7 @@ $$(LIBFFI_SRCDIR-$(os))/darwin_common/include/ffi.h: downloads/libffi-$(LIBFFI_V endif libFFI-$(os): $$(foreach sdk,$$(SDKS-$(os)),$$(LIBFFI_FATLIB-$$(sdk))) -libFFI-wheels-$(os): $$(foreach target,$$(TARGETS-$(os)),$$(LIBFFI_WHEEL-$$(target))) +libFFI-$(os)-wheels: $$(foreach target,$$(TARGETS-$(os)),$$(LIBFFI_WHEEL-$$(target))) clean-libFFI-$(os): @echo ">>> Clean libFFI build products on $(os)" @@ -1069,7 +1067,7 @@ clean-libFFI-$(os): merge/$(os)/libffi-$(LIBFFI_VERSION).*.log \ wheels/dist/libffi -clean-libFFI-wheels-$(os): +clean-libFFI-$(os)-wheels: rm -rf \ build/$(os)/libffi-$(LIBFFI_VERSION)/build_*/wheel \ wheels/dist/libffi @@ -1178,7 +1176,7 @@ merge-clean-Python-$(os): ########################################################################### $(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz -$(os)-wheels: $(foreach dep,$(DEPENDENCIES),$(dep)-wheels-$(os)) +$(os)-wheels: $(foreach dep,$(DEPENDENCIES),$(dep)-$(os)-wheels) clean-$(os): @echo ">>> Clean $(os) build products" @@ -1189,7 +1187,7 @@ clean-$(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz \ dist/Python-$(PYTHON_VER)-$(os)-support.test-$(BUILD_NUMBER).tar.gz -clean-wheels-$(os): $(foreach dep,$(DEPENDENCIES),clean-$(dep)-wheels-$(os)) +clean-$(os)-wheels: $(foreach dep,$(DEPENDENCIES),clean-$(dep)-$(os)-wheels) ########################################################################### # Build: Debug @@ -1212,31 +1210,31 @@ $(BDIST_WHEEL): $(HOST_PYTHON_EXE) # Binary support wheels wheels: $(foreach dep,$(DEPENDENCIES),$(dep)-wheels) -clean-wheels: $(foreach dep,$(DEPENDENCIES),clean-wheels-$(dep)) +clean-wheels: $(foreach dep,$(DEPENDENCIES),clean-$(dep)-wheels) # Dump environment variables (for debugging purposes) vars: $(foreach os,$(OS_LIST),vars-$(os)) # Expand cross-platform build and clean targets for each output product BZip2: $(foreach os,$(OS_LIST),BZip2-$(os)) -BZip2-wheels: $(foreach os,$(OS_LIST),BZip2-wheels-$(os)) +BZip2-wheels: $(foreach os,$(OS_LIST),BZip2-$(os)-wheels) clean-BZip2: $(foreach os,$(OS_LIST),clean-BZip2-$(os)) -clean-BZip2-wheels: $(foreach os,$(OS_LIST),clean-BZip2-wheels-$(os)) +clean-BZip2-wheels: $(foreach os,$(OS_LIST),clean-BZip2-$(os)-wheels) XZ: $(foreach os,$(OS_LIST),XZ-$(os)) -XZ-wheels: $(foreach os,$(OS_LIST),XZ-wheels-$(os)) +XZ-wheels: $(foreach os,$(OS_LIST),XZ-$(os)-wheels) clean-XZ: $(foreach os,$(OS_LIST),clean-XZ-$(os)) -clean-XZ-wheels: $(foreach os,$(OS_LIST),clean-XZ-wheels-$(os)) +clean-XZ-wheels: $(foreach os,$(OS_LIST),clean-XZ-$(os)-wheels) OpenSSL: $(foreach os,$(OS_LIST),OpenSSL-$(os)) -OpenSSL-wheels: $(foreach os,$(OS_LIST),OpenSSL-wheels-$(os)) +OpenSSL-wheels: $(foreach os,$(OS_LIST),OpenSSL-$(os)-wheels) clean-OpenSSL: $(foreach os,$(OS_LIST),clean-OpenSSL-$(os)) -clean-OpenSSL-wheels: $(foreach os,$(OS_LIST),clean-OpenSSL-wheels-$(os)) +clean-OpenSSL-wheels: $(foreach os,$(OS_LIST),clean-OpenSSL-$(os)-wheels) libFFI: $(foreach os,$(OS_LIST),libFFI-$(os)) -libFFI-wheels: $(foreach os,$(OS_LIST),libFFI-wheels-$(os)) +libFFI-wheels: $(foreach os,$(OS_LIST),libFFI-$(os)-wheels) clean-libFFI: $(foreach os,$(OS_LIST),clean-libFFI-$(os)) -clean-libFFI-wheels: $(foreach os,$(OS_LIST),clean-libFFI-wheels-$(os)) +clean-libFFI-wheels: $(foreach os,$(OS_LIST),clean-libFFI-$(os)-wheels) Python: $(foreach os,$(OS_LIST),Python-$(os)) clean-Python: $(foreach os,$(OS_LIST),clean-Python-$(os)) diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index d3b69a4..46b5603 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -214,21 +214,16 @@ index f603a89f7f..d6db040d0d 100644 + ) + ) diff --git a/Lib/platform.py b/Lib/platform.py -index 9b9d88bf58..dbd9ee3276 100755 +index 9b9d88bf58..6fe084a3a5 100755 --- a/Lib/platform.py +++ b/Lib/platform.py -@@ -452,6 +452,35 @@ +@@ -452,6 +452,26 @@ # If that also doesn't work return the default values return release, versioninfo, machine +def iOS_ver(): -+ """ Get iOS/tvOS version information, and return it as a -+ tuple (system, release, model). All tuple entries are strings. -+ -+ Equivalent of: -+ system = [[UIDevice currentDevice].systemName] UTF8String] -+ release = [[UIDevice currentDevice].systemVersion] UTF8String] -+ model = [[UIDevice currentDevice].model] UTF8String] ++ """Get iOS/tvOS version information, and return it as a ++ tuple (system, release, model). All tuple entries are strings. + """ + import _ios_support + return _ios_support.get_platform_ios() @@ -244,16 +239,12 @@ index 9b9d88bf58..dbd9ee3276 100755 + from actual devices because they are reproducing actual device + properties. + """ -+ if sys.platform in ('ios', 'tvos', 'watchos'): -+ return sys.implementation._multiarch.endswith('simulator') -+ -+ # All other platforms aren't simulators. -+ return False ++ return getattr(sys.implementation, "_simulator", False) + def _java_getprop(name, default): from java.lang import System -@@ -608,7 +637,7 @@ +@@ -608,7 +628,7 @@ default in case the command should fail. """ @@ -262,7 +253,7 @@ index 9b9d88bf58..dbd9ee3276 100755 # XXX Others too ? return default -@@ -750,6 +779,24 @@ +@@ -750,6 +770,24 @@ csid, cpu_number = vms_lib.getsyi('SYI$_CPU', 0) return 'Alpha' if cpu_number >= 128 else 'VAX' @@ -287,22 +278,23 @@ index 9b9d88bf58..dbd9ee3276 100755 def from_subprocess(): """ Fall back to `uname -p` -@@ -904,6 +951,14 @@ +@@ -904,6 +942,15 @@ system = 'Windows' release = 'Vista' + # Normalize responses on Apple mobile platforms + if sys.platform in ('ios', 'tvos'): + system, release, model = iOS_ver() -+ # Simulator devices report as "arm64" or "x86_64"; -+ # use the model as the basis for the normalized machine name. -+ if sys.implementation._multiarch.endswith('simulator'): -+ machine = f'{model} Simulator' ++ ++ # On iOS/tvOS simulators, os.uname() reports the machine as something ++ # like "arm64" or "x86_64". ++ if getattr(sys.implementation, "_simulator", False): ++ machine = f'{model}Simulator' + vals = system, node, release, version, machine # Replace 'unknown' values with the more portable '' _uname_cache = uname_result(*map(_unknown_as_blank, vals)) -@@ -1216,11 +1271,13 @@ +@@ -1216,11 +1263,13 @@ system, release, version = system_alias(system, release, version) if system == 'Darwin': @@ -312,7 +304,7 @@ index 9b9d88bf58..dbd9ee3276 100755 - system = 'macOS' - release = macos_release + if sys.platform in ('ios', 'tvos'): -+ system, release, model = iOS_ver() ++ system, release, _ = iOS_ver() + else: + macos_release = mac_ver()[0] + if macos_release: @@ -336,7 +328,7 @@ index 69670d9d7f..8287267e64 100644 return f'{userbase}/lib/python{version[0]}.{version[1]}/site-packages' diff --git a/Lib/subprocess.py b/Lib/subprocess.py -index 6df5dd551e..396fb60c8d 100644 +index 6df5dd551e..597da09643 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -74,8 +74,8 @@ @@ -350,8 +342,84 @@ index 6df5dd551e..396fb60c8d 100644 if _mswindows: import _winapi +@@ -103,18 +103,22 @@ + if _can_fork_exec: + from _posixsubprocess import fork_exec as _fork_exec + # used in methods that are called by __del__ +- _waitpid = os.waitpid +- _waitstatus_to_exitcode = os.waitstatus_to_exitcode +- _WIFSTOPPED = os.WIFSTOPPED +- _WSTOPSIG = os.WSTOPSIG +- _WNOHANG = os.WNOHANG ++ class _del_safe: ++ waitpid = os.waitpid ++ waitstatus_to_exitcode = os.waitstatus_to_exitcode ++ WIFSTOPPED = os.WIFSTOPPED ++ WSTOPSIG = os.WSTOPSIG ++ WNOHANG = os.WNOHANG ++ ECHILD = errno.ECHILD + else: +- _fork_exec = None +- _waitpid = None +- _waitstatus_to_exitcode = None +- _WIFSTOPPED = None +- _WSTOPSIG = None +- _WNOHANG = None ++ class _del_safe: ++ waitpid = None ++ waitstatus_to_exitcode = None ++ WIFSTOPPED = None ++ WSTOPSIG = None ++ WNOHANG = None ++ ECHILD = errno.ECHILD ++ + import select + import selectors + +@@ -1951,20 +1955,16 @@ + raise child_exception_type(err_msg) + + +- def _handle_exitstatus(self, sts, +- _waitstatus_to_exitcode=_waitstatus_to_exitcode, +- _WIFSTOPPED=_WIFSTOPPED, +- _WSTOPSIG=_WSTOPSIG): ++ def _handle_exitstatus(self, sts, _del_safe=_del_safe): + """All callers to this function MUST hold self._waitpid_lock.""" + # This method is called (indirectly) by __del__, so it cannot + # refer to anything outside of its local scope. +- if _WIFSTOPPED(sts): +- self.returncode = -_WSTOPSIG(sts) ++ if _del_safe.WIFSTOPPED(sts): ++ self.returncode = -_del_safe.WSTOPSIG(sts) + else: +- self.returncode = _waitstatus_to_exitcode(sts) ++ self.returncode = _del_safe.waitstatus_to_exitcode(sts) + +- def _internal_poll(self, _deadstate=None, _waitpid=_waitpid, +- _WNOHANG=_WNOHANG, _ECHILD=errno.ECHILD): ++ def _internal_poll(self, _deadstate=None, _del_safe=_del_safe): + """Check if child process has terminated. Returns returncode + attribute. + +@@ -1980,13 +1980,13 @@ + try: + if self.returncode is not None: + return self.returncode # Another thread waited. +- pid, sts = _waitpid(self.pid, _WNOHANG) ++ pid, sts = _del_safe.waitpid(self.pid, _del_safe.WNOHANG) + if pid == self.pid: + self._handle_exitstatus(sts) + except OSError as e: + if _deadstate is not None: + self.returncode = _deadstate +- elif e.errno == _ECHILD: ++ elif e.errno == _del_safe.ECHILD: + # This happens if SIGCLD is set to be ignored or + # waiting for child processes has otherwise been + # disabled for our process. This child is dead, we diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index ebe3711827..ea00c3176d 100644 +index ebe3711827..6006b92386 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -95,6 +95,33 @@ @@ -408,7 +476,33 @@ index ebe3711827..ea00c3176d 100644 return { 'prefix': 'posix_prefix', 'home': 'posix_home', -@@ -788,10 +822,16 @@ +@@ -455,9 +489,24 @@ + + def _get_sysconfigdata_name(): + multiarch = getattr(sys.implementation, '_multiarch', '') ++ ++ # On most platforms, sys.platform is all we need. However, iOS/tvOS/watchOS have a ++ # single sys.platform, but two underlying platforms depending on whether we're on ++ # device or on simulator. ++ platform = { ++ ("ios", False): "iphoneos", ++ ("ios", True): "iphonesimulator", ++ ("tvos", True): "appletvos", ++ ("tvos", False): "appletvsimulator", ++ ("watchos", False): "watchos", ++ ("watchos", True): "watchsimulator", ++ }.get( ++ (sys.platform, getattr(sys.implementation, "_simulator", False)), ++ sys.platform ++ ) + return os.environ.get( + '_PYTHON_SYSCONFIGDATA_NAME', +- f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}', ++ f'_sysconfigdata_{sys.abiflags}_{platform}_{multiarch}' + ) + + +@@ -788,10 +837,16 @@ if m: release = m.group() elif osname[:6] == "darwin": @@ -1203,10 +1297,19 @@ index 44974d433b..ae4e18802b 100755 # # Platform support for Windows diff --git a/Makefile.pre.in b/Makefile.pre.in -index 884bea1841..a15df8a03c 100644 +index 884bea1841..a0d3bfecc1 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in -@@ -344,6 +344,8 @@ +@@ -124,6 +124,8 @@ + # Strict or non-strict aliasing flags used to compile dtoa.c, see above + CFLAGS_ALIASING=@CFLAGS_ALIASING@ + ++# Platform descriptor ++PLATFORM= @PLATFORM@ + + # Machine-dependent subdirectories + MACHDEP= @MACHDEP@ +@@ -344,6 +346,8 @@ ########################################################################## LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@ @@ -1215,6 +1318,15 @@ index 884bea1841..a15df8a03c 100644 ########################################################################## # Parser +@@ -1384,7 +1388,7 @@ + Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o: $(srcdir)/Include/internal/pycore_ast.h + + Python/getplatform.o: $(srcdir)/Python/getplatform.c +- $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c ++ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(PLATFORM)"' -o $@ $(srcdir)/Python/getplatform.c + + Python/importdl.o: $(srcdir)/Python/importdl.c + $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index ad9daaede4..f295528d4e 100644 --- a/Modules/_posixsubprocess.c @@ -1681,6 +1793,37 @@ index 29f3bab60a..ea3b25a978 100644 #endif #define TYPE_NULL '0' +diff --git a/Python/sysmodule.c b/Python/sysmodule.c +index 6e9ec90c9d..16b0a6ab11 100644 +--- a/Python/sysmodule.c ++++ b/Python/sysmodule.c +@@ -49,6 +49,10 @@ + extern const char *PyWin_DLLVersionString; + #endif + ++#if defined(__APPLE__) ++#include "TargetConditionals.h" ++#endif ++ + #ifdef __EMSCRIPTEN__ + #include + #endif +@@ -2739,6 +2743,15 @@ + goto error; + #endif + ++#if TARGET_OS_IPHONE ++# if TARGET_OS_SIMULATOR ++ res = PyDict_SetItemString(impl_info, "_simulator", Py_True); ++# else ++ res = PyDict_SetItemString(impl_info, "_simulator", Py_False); ++# endif ++ if (res < 0) ++ goto error; ++#endif + /* dict ready */ + + ns = _PyNamespace_New(impl_info); diff --git a/aclocal.m4 b/aclocal.m4 index 6a33c0cc9d..09ae5d1aa8 100644 --- a/aclocal.m4 @@ -1885,10 +2028,18 @@ index d74fb6deac..a30f74f03d 100755 # Blank kernel with real OS is always fine. ;; diff --git a/configure b/configure -index af4a5bbfdf..c01cd44df0 100755 +index af4a5bbfdf..ec56feb260 100755 --- a/configure +++ b/configure -@@ -838,6 +838,8 @@ +@@ -819,6 +819,7 @@ + MACHDEP_OBJS + DYNLOADFILE + DLINCLDIR ++PLATFORM + PLATFORM_OBJS + PLATFORM_HEADERS + DTRACE_OBJS +@@ -838,6 +839,8 @@ LIBMPDEC_INTERNAL LIBMPDEC_LDFLAGS LIBMPDEC_CFLAGS @@ -1897,7 +2048,7 @@ index af4a5bbfdf..c01cd44df0 100755 LIBFFI_INCLUDEDIR LIBEXPAT_INTERNAL LIBEXPAT_LDFLAGS -@@ -991,7 +993,6 @@ +@@ -991,7 +994,6 @@ docdir oldincludedir includedir @@ -1905,7 +2056,7 @@ index af4a5bbfdf..c01cd44df0 100755 localstatedir sharedstatedir sysconfdir -@@ -1142,7 +1143,6 @@ +@@ -1142,7 +1144,6 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' @@ -1913,7 +2064,7 @@ index af4a5bbfdf..c01cd44df0 100755 includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -@@ -1395,15 +1395,6 @@ +@@ -1395,15 +1396,6 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -1929,7 +2080,7 @@ index af4a5bbfdf..c01cd44df0 100755 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -@@ -1541,7 +1532,7 @@ +@@ -1541,7 +1533,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ @@ -1938,7 +2089,7 @@ index af4a5bbfdf..c01cd44df0 100755 do eval ac_val=\$$ac_var # Remove trailing slashes. -@@ -1694,7 +1685,6 @@ +@@ -1694,7 +1686,6 @@ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] @@ -1946,23 +2097,47 @@ index af4a5bbfdf..c01cd44df0 100755 --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] -@@ -3823,6 +3813,15 @@ +@@ -3823,6 +3814,24 @@ *-*-cygwin*) ac_sys_system=Cygwin ;; ++ *-apple-ios*-simulator) ++ ac_sys_system=iphonesimulator ++ ;; + *-apple-ios*) -+ ac_sys_system=iOS ++ ac_sys_system=iphoneos ++ ;; ++ *-apple-tvos*-simulator) ++ ac_sys_system=appletvsimulator + ;; + *-apple-tvos*) -+ ac_sys_system=tvOS ++ ac_sys_system=appletvos ++ ;; ++ *-apple-watchos*-simulator) ++ ac_sys_system=watchsimulator + ;; + *-apple-watchos*) -+ ac_sys_system=watchOS ++ ac_sys_system=watchos + ;; *-*-vxworks*) ac_sys_system=VxWorks ;; -@@ -3879,6 +3878,15 @@ +@@ -3860,6 +3869,14 @@ + darwin*) MACHDEP="darwin";; + '') MACHDEP="unknown";; + esac ++ ++ case $ac_sys_system in ++ iphoneos | iphonesimulator) PLATFORM=ios;; ++ appletvos | appletvsimulator) PLATFORM=tvos;; ++ watchos | watchsimulator) PLATFORM=watchos;; ++ *) PLATFORM=$MACHDEP;; ++ esac ++ + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$MACHDEP\"" >&5 + $as_echo "\"$MACHDEP\"" >&6; } +@@ -3879,6 +3896,15 @@ *-*-cygwin*) _host_cpu= ;; @@ -1978,21 +2153,21 @@ index af4a5bbfdf..c01cd44df0 100755 *-*-vxworks*) _host_cpu=$host_cpu ;; -@@ -3957,6 +3965,13 @@ +@@ -3957,6 +3983,13 @@ define_xopen_source=no;; Darwin/[12][0-9].*) define_xopen_source=no;; + # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. -+ iOS/*) ++ iphoneos/*|iphonesimulator/*) + define_xopen_source=no;; -+ tvOS/*) ++ appletv/*|appletvsimulator/*) + define_xopen_source=no;; -+ watchOS/*) ++ watchos/*|watchsimulator/*) + define_xopen_source=no;; # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) -@@ -6159,7 +6174,30 @@ +@@ -6159,7 +6192,42 @@ #elif defined(__gnu_hurd__) i386-gnu #elif defined(__APPLE__) @@ -2000,21 +2175,33 @@ index af4a5bbfdf..c01cd44df0 100755 +# include "TargetConditionals.h" +# if TARGET_OS_IOS +# if TARGET_OS_SIMULATOR -+ iphonesimulator ++# if __x86_64__ ++ iphonesimulator-x86_64 ++# else ++ iphonesimulator-arm64 ++# endif +# else -+ iphoneos ++ iphoneos-arm64 +# endif +# elif TARGET_OS_TV +# if TARGET_OS_SIMULATOR -+ appletvsimulator ++# if __x86_64__ ++ appletvsimulator-x86_64 ++# else ++ appletvsimulator-arm64 ++# endif +# else -+ appletvos ++ appletvos-arm64 +# endif +# elif TARGET_OS_WATCH +# if TARGET_OS_SIMULATOR -+ watchsimulator ++# if __x86_64__ ++ watchsimulator-x86_64 ++# else ++ watchsimulator-arm64 ++# endif +# else -+ watchos ++ watchos-arm64_32 +# endif +# elif TARGET_OS_OSX + darwin @@ -2024,20 +2211,57 @@ index af4a5bbfdf..c01cd44df0 100755 #elif defined(__VXWORKS__) vxworks #elif defined(__wasm32__) -@@ -6204,6 +6242,12 @@ +@@ -6204,6 +6272,8 @@ case $ac_sys_system in #( Darwin*) : MULTIARCH="" ;; #( -+ iOS*) : -+ MULTIARCH="" ;; #( -+ tvOS*) : -+ MULTIARCH="" ;; #( -+ watchOS*) : ++ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) : + MULTIARCH="" ;; #( FreeBSD*) : MULTIARCH="" ;; #( *) : -@@ -6266,7 +6310,7 @@ +@@ -6218,8 +6288,18 @@ + if test x$PLATFORM_TRIPLET != x$MULTIARCH; then + as_fn_error $? "internal configure error for the platform triplet, please file a bug report" "$LINENO" 5 + fi ++ SOABI_PLATFORM=$PLATFORM_TRIPLET + elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then +- MULTIARCH=$PLATFORM_TRIPLET ++ case $ac_sys_system in #( ++ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) : ++ SOABI_PLATFORM=$(echo $PLATFORM_TRIPLET | cut -d- -f1) ++ MULTIARCH=$(echo $PLATFORM_TRIPLET | cut -d- -f2) ++ ;; #( ++ *) : ++ MULTIARCH=$PLATFORM_TRIPLET ++ SOABI_PLATFORM=$PLATFORM_TRIPLET ++ ;; ++ esac + fi + + +@@ -6263,10 +6343,28 @@ + PY_SUPPORT_TIER=3 ;; #( + wasm32-unknown-wasi/clang) : + PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-ios/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-ios-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ x86_64-apple-ios-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-tvos/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-tvos-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ x86_64-apple-tvos-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-watchos/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ aarch64-apple-watchos-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( ++ x86_64-apple-watchos-simulator/clang) : ++ PY_SUPPORT_TIER=3 ;; #( x86_64-*-freebsd*/clang) : PY_SUPPORT_TIER=3 ;; #( *) : @@ -2046,7 +2270,7 @@ index af4a5bbfdf..c01cd44df0 100755 ;; esac -@@ -7210,11 +7254,23 @@ +@@ -7210,11 +7308,23 @@ fi if test "$cross_compiling" = yes; then @@ -2075,25 +2299,25 @@ index af4a5bbfdf..c01cd44df0 100755 fi -@@ -10858,6 +10914,7 @@ +@@ -10858,6 +10968,7 @@ esac ;; CYGWIN*) SHLIB_SUFFIX=.dll;; -+ iOS|tvOS|watchOS) SHLIB_SUFFIX=.dylib;; ++ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) SHLIB_SUFFIX=.dylib;; *) SHLIB_SUFFIX=.so;; esac fi -@@ -10940,6 +10997,9 @@ +@@ -10940,6 +11051,9 @@ BLDSHARED="$LDSHARED" fi ;; -+ iOS/*|tvOS/*|watchOS/*) ++ iphoneos/*|iphonesimulator/*|appletvos/*|appletvsimulator/*|watchos/*|watchsimulator*) + LDSHARED='$(CC) -dynamiclib -undefined dynamic_lookup' + LDCXXSHARED='$(CXX) -dynamiclib -undefined dynamic_lookup';; Emscripten|WASI) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; -@@ -11348,8 +11408,8 @@ +@@ -11348,8 +11462,8 @@ pkg_failed=no @@ -2104,7 +2328,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBUUID_CFLAGS"; then pkg_cv_LIBUUID_CFLAGS="$LIBUUID_CFLAGS" -@@ -11389,7 +11449,7 @@ +@@ -11389,7 +11503,7 @@ if test $pkg_failed = yes; then @@ -2113,7 +2337,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -11532,7 +11592,7 @@ +@@ -11532,7 +11646,7 @@ elif test $pkg_failed = untried; then @@ -2122,14 +2346,14 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -12183,23 +12243,35 @@ +@@ -12183,23 +12297,35 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5 $as_echo "$with_system_ffi" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - if test "$with_system_ffi" != "" -+ if test "$ac_sys_system" = "iOS" || test "$ac_sys_system" = "tvOS" || test "$ac_sys_system" = "watchOS" ++ if test "$ac_sys_system" = "iphoneos" || test "$ac_sys_system" = "iphonesimulator" || test "$ac_sys_system" = "appletvos" || test "$ac_sys_system" = "appletvsimulator" || test "$ac_sys_system" = "watchos" || test "$ac_sys_system" = "watchsimulator" then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with(out)-system-ffi is ignored on this platform" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -2164,7 +2388,7 @@ index af4a5bbfdf..c01cd44df0 100755 # Check for use of the system libmpdec library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5 $as_echo_n "checking for --with-system-libmpdec... " >&6; } -@@ -12340,8 +12412,8 @@ +@@ -12340,8 +12466,8 @@ pkg_failed=no @@ -2175,7 +2399,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBNSL_CFLAGS"; then pkg_cv_LIBNSL_CFLAGS="$LIBNSL_CFLAGS" -@@ -12381,7 +12453,7 @@ +@@ -12381,7 +12507,7 @@ if test $pkg_failed = yes; then @@ -2184,7 +2408,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12482,7 +12554,7 @@ +@@ -12482,7 +12608,7 @@ LIBNSL_LIBS=${LIBNSL_LIBS-$libnsl} elif test $pkg_failed = untried; then @@ -2193,7 +2417,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } LIBNSL_CFLAGS=${LIBNSL_CFLAGS-""} -@@ -12630,8 +12702,8 @@ +@@ -12630,8 +12756,8 @@ pkg_failed=no @@ -2204,7 +2428,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBSQLITE3_CFLAGS"; then pkg_cv_LIBSQLITE3_CFLAGS="$LIBSQLITE3_CFLAGS" -@@ -12671,7 +12743,7 @@ +@@ -12671,7 +12797,7 @@ if test $pkg_failed = yes; then @@ -2213,7 +2437,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12693,7 +12765,7 @@ +@@ -12693,7 +12819,7 @@ elif test $pkg_failed = untried; then @@ -2222,7 +2446,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } LIBSQLITE3_CFLAGS=${LIBSQLITE3_CFLAGS-""} -@@ -13462,8 +13534,8 @@ +@@ -13462,8 +13588,8 @@ pkg_failed=no @@ -2233,7 +2457,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$TCLTK_CFLAGS"; then pkg_cv_TCLTK_CFLAGS="$TCLTK_CFLAGS" -@@ -13503,7 +13575,7 @@ +@@ -13503,7 +13629,7 @@ if test $pkg_failed = yes; then @@ -2242,7 +2466,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13521,7 +13593,7 @@ +@@ -13521,7 +13647,7 @@ found_tcltk=no elif test $pkg_failed = untried; then @@ -2251,7 +2475,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } found_tcltk=no else -@@ -13557,8 +13629,8 @@ +@@ -13557,8 +13683,8 @@ pkg_failed=no @@ -2262,7 +2486,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$X11_CFLAGS"; then pkg_cv_X11_CFLAGS="$X11_CFLAGS" -@@ -13598,7 +13670,7 @@ +@@ -13598,7 +13724,7 @@ if test $pkg_failed = yes; then @@ -2271,7 +2495,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13625,7 +13697,7 @@ +@@ -13625,7 +13751,7 @@ and X11_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then @@ -2280,7 +2504,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -@@ -16201,8 +16273,8 @@ +@@ -16201,8 +16327,8 @@ pkg_failed=no @@ -2291,7 +2515,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" -@@ -16242,7 +16314,7 @@ +@@ -16242,7 +16368,7 @@ if test $pkg_failed = yes; then @@ -2300,7 +2524,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16386,7 +16458,7 @@ +@@ -16386,7 +16512,7 @@ elif test $pkg_failed = untried; then @@ -2309,7 +2533,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16549,8 +16621,8 @@ +@@ -16549,8 +16675,8 @@ pkg_failed=no @@ -2320,7 +2544,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$BZIP2_CFLAGS"; then pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" -@@ -16590,7 +16662,7 @@ +@@ -16590,7 +16716,7 @@ if test $pkg_failed = yes; then @@ -2329,7 +2553,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16687,7 +16759,7 @@ +@@ -16687,7 +16813,7 @@ elif test $pkg_failed = untried; then @@ -2338,7 +2562,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16779,8 +16851,8 @@ +@@ -16779,8 +16905,8 @@ pkg_failed=no @@ -2349,7 +2573,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBLZMA_CFLAGS"; then pkg_cv_LIBLZMA_CFLAGS="$LIBLZMA_CFLAGS" -@@ -16820,7 +16892,7 @@ +@@ -16820,7 +16946,7 @@ if test $pkg_failed = yes; then @@ -2358,7 +2582,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16917,7 +16989,7 @@ +@@ -16917,7 +17043,7 @@ elif test $pkg_failed = untried; then @@ -2367,7 +2591,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -18150,8 +18222,8 @@ +@@ -18150,8 +18276,8 @@ pkg_failed=no @@ -2378,7 +2602,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBCRYPT_CFLAGS"; then pkg_cv_LIBCRYPT_CFLAGS="$LIBCRYPT_CFLAGS" -@@ -18191,7 +18263,7 @@ +@@ -18191,7 +18317,7 @@ if test $pkg_failed = yes; then @@ -2387,7 +2611,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -18288,7 +18360,7 @@ +@@ -18288,7 +18414,7 @@ elif test $pkg_failed = untried; then @@ -2396,7 +2620,25 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -23063,8 +23135,8 @@ +@@ -20750,7 +20876,7 @@ + $as_echo "$ABIFLAGS" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5 + $as_echo_n "checking SOABI... " >&6; } +-SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} ++SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${SOABI_PLATFORM:+-$SOABI_PLATFORM} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5 + $as_echo "$SOABI" >&6; } + +@@ -20758,7 +20884,7 @@ + if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then + # Similar to SOABI but remove "d" flag from ABIFLAGS + +- ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} ++ ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${SOABI_PLATFORM:+-$SOABI_PLATFORM} + + cat >>confdefs.h <<_ACEOF + #define ALT_SOABI "${ALT_SOABI}" +@@ -23063,8 +23189,8 @@ if ! $found; then OPENSSL_INCLUDES= for ssldir in $ssldirs; do @@ -2407,7 +2649,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -f "$ssldir/include/openssl/ssl.h"; then OPENSSL_INCLUDES="-I$ssldir/include" OPENSSL_LDFLAGS="-L$ssldir/lib" -@@ -23445,8 +23517,8 @@ +@@ -23445,8 +23571,8 @@ pkg_failed=no @@ -2418,7 +2660,7 @@ index af4a5bbfdf..c01cd44df0 100755 if test -n "$LIBB2_CFLAGS"; then pkg_cv_LIBB2_CFLAGS="$LIBB2_CFLAGS" -@@ -23486,7 +23558,7 @@ +@@ -23486,7 +23612,7 @@ if test $pkg_failed = yes; then @@ -2427,7 +2669,7 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -23504,7 +23576,7 @@ +@@ -23504,7 +23630,7 @@ have_libb2=no elif test $pkg_failed = untried; then @@ -2436,11 +2678,11 @@ index af4a5bbfdf..c01cd44df0 100755 $as_echo "no" >&6; } have_libb2=no else -@@ -23575,6 +23647,29 @@ +@@ -23575,6 +23701,29 @@ py_cv_module_ossaudiodev=n/a py_cv_module_spwd=n/a ;; #( -+ iOS|tvOS|watchOS) : ++ iphoneos|iphonesimulator|appletvos|appletvsimulator|watchos|watchsimulator) : + + + diff --git a/patch/Python/_sysconfigdata__ios_iphoneos.py b/patch/Python/_sysconfigdata__ios_iphoneos.py deleted file mode 100644 index 780bf88..0000000 --- a/patch/Python/_sysconfigdata__ios_iphoneos.py +++ /dev/null @@ -1,2 +0,0 @@ -# There's only one supported architecture for iOS hardware -from _sysconfigdata__ios_iphoneos_arm64 import * diff --git a/patch/Python/_sysconfigdata__ios_iphonesimulator.py b/patch/Python/_sysconfigdata__ios_iphonesimulator.py deleted file mode 100644 index 1bede11..0000000 --- a/patch/Python/_sysconfigdata__ios_iphonesimulator.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - - -# os.uname().machine is the host CPU architecture on the simulator -arch = os.uname().machine -if arch == 'x86_64': - from _sysconfigdata__ios_iphonesimulator_x86_64 import * -elif arch == 'arm64': - from _sysconfigdata__ios_iphonesimulator_arm64 import * -else: - raise RuntimeError("Unknown iOS simulator architecture.") diff --git a/patch/Python/_sysconfigdata__tvos_appletvos.py b/patch/Python/_sysconfigdata__tvos_appletvos.py deleted file mode 100644 index eb7ac9c..0000000 --- a/patch/Python/_sysconfigdata__tvos_appletvos.py +++ /dev/null @@ -1,2 +0,0 @@ -# There's only one supported architecture for tvOS hardware -from _sysconfigdata__tvos_appletvos_arm64 import * diff --git a/patch/Python/_sysconfigdata__tvos_appletvsimulator.py b/patch/Python/_sysconfigdata__tvos_appletvsimulator.py deleted file mode 100644 index 29f8a67..0000000 --- a/patch/Python/_sysconfigdata__tvos_appletvsimulator.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - - -# os.uname().machine is the host CPU architecture on the simulator -arch = os.uname().machine -if arch == 'x86_64': - from _sysconfigdata__tvos_appletvsimulator_x86_64 import * -elif arch == 'arm64': - from _sysconfigdata__tvos_appletvsimulator_arm64 import * -else: - raise RuntimeError("Unknown tvOS simulator architecture.") diff --git a/patch/Python/_sysconfigdata__watchos_watchos.py b/patch/Python/_sysconfigdata__watchos_watchos.py deleted file mode 100644 index c1872df..0000000 --- a/patch/Python/_sysconfigdata__watchos_watchos.py +++ /dev/null @@ -1,2 +0,0 @@ -# There's only one supported architecture for watchOS hardware -from _sysconfigdata__watchos_watchos_arm64_32 import * diff --git a/patch/Python/_sysconfigdata__watchos_watchsimulator.py b/patch/Python/_sysconfigdata__watchos_watchsimulator.py deleted file mode 100644 index c34bd97..0000000 --- a/patch/Python/_sysconfigdata__watchos_watchsimulator.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - - -# os.uname().machine is the host CPU architecture on the simulator -arch = os.uname().machine -if arch == 'x86_64': - from _sysconfigdata__watchos_watchsimulator_x86_64 import * -elif arch == 'arm64': - from _sysconfigdata__watchos_watchsimulator_arm64 import * -else: - raise RuntimeError("Unknown watchOS simulator architecture.") diff --git a/patch/Python/pyconfig-watchOS.h b/patch/Python/pyconfig-watchOS.h index ae4563f..f842b98 100644 --- a/patch/Python/pyconfig-watchOS.h +++ b/patch/Python/pyconfig-watchOS.h @@ -1,7 +1,3 @@ -#ifdef __arm__ -#include "pyconfig-armv7k.h" -#endif - #ifdef __arm64__ # ifdef __LP64__ #include "pyconfig-arm64.h" @@ -12,4 +8,4 @@ #ifdef __x86_64__ #include "pyconfig-x86_64.h" -#endif \ No newline at end of file +#endif From 18eb4ad2df862290c2dc445817d3482a27cd9256 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 19 Sep 2023 09:34:12 +0800 Subject: [PATCH 8/9] More multiarch cleanups. --- Makefile | 189 +++--- patch/Python/Python.patch | 579 +++++++++++------- ...{sitecustomize.py => sitecustomize.iOS.py} | 0 patch/Python/sitecustomize.macOS.py | 14 + patch/Python/sitecustomize.tvOS.py | 99 +++ patch/Python/sitecustomize.watchOS.py | 99 +++ 6 files changed, 670 insertions(+), 310 deletions(-) rename patch/Python/{sitecustomize.py => sitecustomize.iOS.py} (100%) create mode 100644 patch/Python/sitecustomize.macOS.py create mode 100644 patch/Python/sitecustomize.tvOS.py create mode 100644 patch/Python/sitecustomize.watchOS.py diff --git a/Makefile b/Makefile index b103de6..facfa47 100644 --- a/Makefile +++ b/Makefile @@ -47,13 +47,7 @@ BZIP2_VERSION=1.0.8 XZ_VERSION=5.4.4 -# Preference is to use OpenSSL 3; however, Cryptography 3.4.8 (and -# probably some other packages as well) only works with 1.1.1, so -# we need to preserve the ability to build the older OpenSSL (for now...) OPENSSL_VERSION=3.1.2 -# OPENSSL_VERSION_NUMBER=1.1.1 -# OPENSSL_REVISION=v -# OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION) LIBFFI_VERSION=3.4.4 @@ -209,15 +203,15 @@ OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]') SDK-$(target)=$$(basename $(target)) ARCH-$(target)=$$(subst .,,$$(suffix $(target))) -WHEEL_TAG-$(target)=py3-none-$$(SDK-$(target))_$$(shell echo $$(VERSION_MIN-$(os))_$$(ARCH-$(target)) | sed "s/\./_/g") +WHEEL_TAG-$(target)=py3-none-$$(shell echo $$(OS_LOWER-$(target))_$$(VERSION_MIN-$(os))_$(target) | sed "s/\./_/g") ifeq ($(os),macOS) TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-darwin else ifeq ($$(findstring simulator,$$(SDK-$(target))),) -TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target)) +TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os)) else -TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))-simulator +TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator endif endif @@ -229,11 +223,11 @@ LDFLAGS-$(target)=$$(CFLAGS-$(os)) # Target: Aliases ########################################################################### -alias/clang-$(target): - patch/make-xcrun-alias alias/clang-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" +alias/$$(TARGET_TRIPLE-$(target))-gcc: + patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(target))-gcc "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" -alias/cpp-$(target): - patch/make-xcrun-alias alias/cpp-$(target) "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" +alias/$$(TARGET_TRIPLE-$(target))-cpp: + patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(target))-cpp "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" ########################################################################### # Target: BZip2 @@ -242,7 +236,7 @@ alias/cpp-$(target): BZIP2_SRCDIR-$(target)=build/$(os)/$(target)/bzip2-$(BZIP2_VERSION) BZIP2_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/bzip2-$(BZIP2_VERSION) BZIP2_LIB-$(target)=$$(BZIP2_INSTALL-$(target))/lib/libbz2.a -BZIP2_WHEEL-$(target)=wheels/dist/bzip2/bzip2-$(BZIP2_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +BZIP2_WHEEL-$(target)=wheels/$(os)/bzip2/bzip2-$(BZIP2_VERSION)-1-$$(WHEEL_TAG-$(target)).whl BZIP2_WHEEL_DISTINFO-$(target)=$$(BZIP2_INSTALL-$(target))/wheel/bzip2-$(BZIP2_VERSION).dist-info $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz @@ -252,13 +246,13 @@ $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz # Touch the makefile to ensure that Make identifies it as up to date. touch $$(BZIP2_SRCDIR-$(target))/Makefile -$$(BZIP2_LIB-$(target)): alias/clang-$(target) $$(BZIP2_SRCDIR-$(target))/Makefile +$$(BZIP2_LIB-$(target)): alias/$$(TARGET_TRIPLE-$(target))-gcc $$(BZIP2_SRCDIR-$(target))/Makefile @echo ">>> Build BZip2 for $(target)" cd $$(BZIP2_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ make install \ PREFIX="$$(BZIP2_INSTALL-$(target))" \ - CC=clang-$(target) \ + CC=$$(TARGET_TRIPLE-$(target))-gcc \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ 2>&1 | tee -a ../bzip2-$(BZIP2_VERSION).build.log @@ -276,22 +270,22 @@ $$(BZIP2_WHEEL-$(target)): $$(BZIP2_LIB-$(target)) $$(BDIST_WHEEL) cp $$(BZIP2_SRCDIR-$(target))/LICENSE $$(BZIP2_WHEEL_DISTINFO-$(target)) # Write package metadata - echo "Metadata-Version: 1.2" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA + echo "Metadata-Version: 1.2" > $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA echo "Name: bzip2" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA echo "Version: $(BZIP2_VERSION)" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA echo "Summary: " >> $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA echo "Download-URL: " >> $$(BZIP2_WHEEL_DISTINFO-$(target))/METADATA # Write wheel metadata - echo "Wheel-Version: 1.0" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL + echo "Wheel-Version: 1.0" > $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL echo "Root-Is-Purelib: false" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL echo "Generator: Python-Apple-support.BeeWare" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL echo "Build: 1" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/dist/bzip2 - $(HOST_PYTHON_EXE) -m wheel pack $$(BZIP2_INSTALL-$(target))/wheel --dest-dir wheels/dist/bzip2 --build-number 1 + mkdir -p wheels/$(os)/bzip2 + $(HOST_PYTHON_EXE) -m wheel pack $$(BZIP2_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/bzip2 --build-number 1 ########################################################################### # Target: XZ (LZMA) @@ -300,7 +294,7 @@ $$(BZIP2_WHEEL-$(target)): $$(BZIP2_LIB-$(target)) $$(BDIST_WHEEL) XZ_SRCDIR-$(target)=build/$(os)/$(target)/xz-$(XZ_VERSION) XZ_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/xz-$(XZ_VERSION) XZ_LIB-$(target)=$$(XZ_INSTALL-$(target))/lib/liblzma.a -XZ_WHEEL-$(target)=wheels/dist/xz/xz-$(XZ_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +XZ_WHEEL-$(target)=wheels/$(os)/xz/xz-$(XZ_VERSION)-1-$$(WHEEL_TAG-$(target)).whl XZ_WHEEL_DISTINFO-$(target)=$$(XZ_INSTALL-$(target))/wheel/xz-$(XZ_VERSION).dist-info $$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz @@ -312,12 +306,12 @@ $$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz # Touch the configure script to ensure that Make identifies it as up to date. touch $$(XZ_SRCDIR-$(target))/configure -$$(XZ_SRCDIR-$(target))/Makefile: alias/clang-$(target) $$(XZ_SRCDIR-$(target))/configure +$$(XZ_SRCDIR-$(target))/Makefile: alias/$$(TARGET_TRIPLE-$(target))-gcc $$(XZ_SRCDIR-$(target))/configure # Configure the build cd $$(XZ_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ - CC=clang-$(target) \ + CC=$$(TARGET_TRIPLE-$(target))-gcc \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ --disable-shared \ @@ -348,22 +342,22 @@ $$(XZ_WHEEL-$(target)): $$(XZ_LIB-$(target)) $$(BDIST_WHEEL) cp $$(XZ_SRCDIR-$(target))/COPYING.* $$(XZ_WHEEL_DISTINFO-$(target)) # Write package metadata - echo "Metadata-Version: 1.2" >> $$(XZ_WHEEL_DISTINFO-$(target))/METADATA + echo "Metadata-Version: 1.2" > $$(XZ_WHEEL_DISTINFO-$(target))/METADATA echo "Name: xz" >> $$(XZ_WHEEL_DISTINFO-$(target))/METADATA echo "Version: $(XZ_VERSION)" >> $$(XZ_WHEEL_DISTINFO-$(target))/METADATA echo "Summary: " >> $$(XZ_WHEEL_DISTINFO-$(target))/METADATA echo "Download-URL: " >> $$(XZ_WHEEL_DISTINFO-$(target))/METADATA # Write wheel metadata - echo "Wheel-Version: 1.0" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL + echo "Wheel-Version: 1.0" > $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL echo "Root-Is-Purelib: false" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL echo "Generator: Python-Apple-support.BeeWare" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL echo "Build: 1" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/dist/xz - $(HOST_PYTHON_EXE) -m wheel pack $$(XZ_INSTALL-$(target))/wheel --dest-dir wheels/dist/xz --build-number 1 + mkdir -p wheels/$(os)/xz + $(HOST_PYTHON_EXE) -m wheel pack $$(XZ_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/xz --build-number 1 ########################################################################### # Target: OpenSSL @@ -373,7 +367,7 @@ OPENSSL_SRCDIR-$(target)=build/$(os)/$(target)/openssl-$(OPENSSL_VERSION) OPENSSL_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/openssl-$(OPENSSL_VERSION) OPENSSL_SSL_LIB-$(target)=$$(OPENSSL_INSTALL-$(target))/lib/libssl.a OPENSSL_CRYPTO_LIB-$(target)=$$(OPENSSL_INSTALL-$(target))/lib/libcrypto.a -OPENSSL_WHEEL-$(target)=wheels/dist/openssl/openssl-$(OPENSSL_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +OPENSSL_WHEEL-$(target)=wheels/$(os)/openssl/openssl-$(OPENSSL_VERSION)-1-$$(WHEEL_TAG-$(target)).whl OPENSSL_WHEEL_DISTINFO-$(target)=$$(OPENSSL_INSTALL-$(target))/wheel/openssl-$(OPENSSL_VERSION).dist-info $$(OPENSSL_SRCDIR-$(target))/Configure: downloads/openssl-$(OPENSSL_VERSION).tar.gz @@ -383,24 +377,19 @@ $$(OPENSSL_SRCDIR-$(target))/Configure: downloads/openssl-$(OPENSSL_VERSION).tar ifneq ($(os),macOS) # Patch code to disable the use of fork as it's not available on $(os) -ifeq ($(OPENSSL_VERSION_NUMBER),1.1.1) - sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/speed.c - sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/ocsp.c -else sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/include/http_server.h sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/speed.c -endif endif # Touch the Configure script to ensure that Make identifies it as up to date. touch $$(OPENSSL_SRCDIR-$(target))/Configure -$$(OPENSSL_SRCDIR-$(target))/is_configured: alias/clang-$(target) $$(OPENSSL_SRCDIR-$(target))/Configure +$$(OPENSSL_SRCDIR-$(target))/is_configured: alias/$$(TARGET_TRIPLE-$(target))-gcc $$(OPENSSL_SRCDIR-$(target))/Configure # Configure the OpenSSL build ifeq ($(os),macOS) cd $$(OPENSSL_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ - CC="clang-$(target) $$(CFLAGS-$(target))" \ + CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ ./Configure darwin64-$$(ARCH-$(target))-cc no-tests \ --prefix="$$(OPENSSL_INSTALL-$(target))" \ --openssldir=/etc/ssl \ @@ -408,7 +397,7 @@ ifeq ($(os),macOS) else cd $$(OPENSSL_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ - CC="clang-$(target) $$(CFLAGS-$(target))" \ + CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ ./Configure iphoneos-cross no-asm no-tests \ @@ -429,7 +418,7 @@ $$(OPENSSL_SRCDIR-$(target))/libssl.a: $$(OPENSSL_SRCDIR-$(target))/is_configure # use the raw targets that make up all and it's dependencies cd $$(OPENSSL_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ - CC="clang-$(target) $$(CFLAGS-$(target))" \ + CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ make build_sw \ @@ -440,7 +429,7 @@ $$(OPENSSL_SSL_LIB-$(target)): $$(OPENSSL_SRCDIR-$(target))/libssl.a # Install just the software (not the docs) cd $$(OPENSSL_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ - CC="clang-$(target) $$(CFLAGS-$(target))" \ + CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ make install_sw \ @@ -467,22 +456,22 @@ $$(OPENSSL_WHEEL-$(target)): $$(OPENSSL_LIB-$(target)) $$(BDIST_WHEEL) fi # Write package metadata - echo "Metadata-Version: 1.2" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA + echo "Metadata-Version: 1.2" > $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA echo "Name: openssl" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA echo "Version: $(OPENSSL_VERSION)" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA echo "Summary: " >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA echo "Download-URL: " >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/METADATA # Write wheel metadata - echo "Wheel-Version: 1.0" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL + echo "Wheel-Version: 1.0" > $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL echo "Root-Is-Purelib: false" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL echo "Generator: Python-Apple-support.BeeWare" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL echo "Build: 1" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/dist/openssl - $(HOST_PYTHON_EXE) -m wheel pack $$(OPENSSL_INSTALL-$(target))/wheel --dest-dir wheels/dist/openssl --build-number 1 + mkdir -p wheels/$(os)/openssl + $(HOST_PYTHON_EXE) -m wheel pack $$(OPENSSL_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/openssl --build-number 1 ########################################################################### # Target: libFFI @@ -496,7 +485,7 @@ ifneq ($(os),macOS) LIBFFI_SRCDIR-$(os)=build/$(os)/libffi-$(LIBFFI_VERSION) LIBFFI_SRCDIR-$(target)=$$(LIBFFI_SRCDIR-$(os))/build_$$(SDK-$(target))-$$(ARCH-$(target)) LIBFFI_LIB-$(target)=$$(LIBFFI_SRCDIR-$(target))/.libs/libffi.a -LIBFFI_WHEEL-$(target)=wheels/dist/libffi/libffi-$(LIBFFI_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +LIBFFI_WHEEL-$(target)=wheels/$(os)/libffi/libffi-$(LIBFFI_VERSION)-1-$$(WHEEL_TAG-$(target)).whl LIBFFI_WHEEL_DISTINFO-$(target)=$$(LIBFFI_SRCDIR-$(target))/wheel/libffi-$(LIBFFI_VERSION).dist-info $$(LIBFFI_LIB-$(target)): $$(LIBFFI_SRCDIR-$(os))/darwin_common/include/ffi.h @@ -521,22 +510,22 @@ $$(LIBFFI_WHEEL-$(target)): $$(LIBFFI_LIB-$(target)) $$(BDIST_WHEEL) cp $$(LIBFFI_SRCDIR-$(os))/LICENSE $$(LIBFFI_WHEEL_DISTINFO-$(target)) # Write package metadata - echo "Metadata-Version: 1.2" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA + echo "Metadata-Version: 1.2" > $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA echo "Name: libffi" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA echo "Version: $(LIBFFI_VERSION)" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA echo "Summary: " >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA echo "Download-URL: " >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/METADATA # Write wheel metadata - echo "Wheel-Version: 1.0" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL + echo "Wheel-Version: 1.0" > $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL echo "Root-Is-Purelib: false" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL echo "Generator: Python-Apple-support.BeeWare" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL echo "Build: 1" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/dist/libffi - $(HOST_PYTHON_EXE) -m wheel pack $$(LIBFFI_SRCDIR-$(target))/wheel --dest-dir wheels/dist/libffi --build-number 1 + mkdir -p wheels/$(os)/libffi + $(HOST_PYTHON_EXE) -m wheel pack $$(LIBFFI_SRCDIR-$(target))/wheel --dest-dir wheels/$(os)/libffi --build-number 1 endif @@ -546,7 +535,7 @@ endif # macOS builds are compiled as a single universal2 build. # The macOS Python build is configured in the `build-sdk` macro, rather than the -# `build-target` macro. +# `build-target` macro. However, the site-customize scripts generated here, per target. ifneq ($(os),macOS) PYTHON_SRCDIR-$(target)=build/$(os)/$(target)/python-$(PYTHON_VERSION) @@ -559,7 +548,7 @@ $$(PYTHON_SRCDIR-$(target))/configure: \ $$(XZ_FATLIB-$$(SDK-$(target))) \ $$(OPENSSL_FATINCLUDE-$$(SDK-$(target))) $$(OPENSSL_SSL_FATLIB-$$(SDK-$(target))) $$(OPENSSL_CRYPTO_FATLIB-$$(SDK-$(target))) \ $$(LIBFFI_FATLIB-$$(SDK-$(target))) \ - $$(PYTHON_XCFRAMEWORK-macOS) + $$(PYTHON_LIB-macOS) @echo ">>> Unpack and configure Python for $(target)" mkdir -p $$(PYTHON_SRCDIR-$(target)) tar zxf downloads/Python-$(PYTHON_VERSION).tar.gz --strip-components 1 -C $$(PYTHON_SRCDIR-$(target)) @@ -569,18 +558,18 @@ $$(PYTHON_SRCDIR-$(target))/configure: \ touch $$(PYTHON_SRCDIR-$(target))/configure $$(PYTHON_SRCDIR-$(target))/Makefile: \ - alias/ar-$$(SDK-$(target)) \ - alias/clang-$(target) \ - alias/cpp-$(target) \ + alias/$$(TARGET_TRIPLE-$$(SDK-$(target)))-ar \ + alias/$$(TARGET_TRIPLE-$(target))-gcc \ + alias/$$(TARGET_TRIPLE-$(target))-cpp \ $$(PYTHON_SRCDIR-$(target))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(target)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ - AR=ar-$$(SDK-$(target)) \ - CC=clang-$(target) \ - CPP=cpp-$(target) \ - CXX=clang-$(target) \ + AR=$$(TARGET_TRIPLE-$$(SDK-$(target)))-ar \ + CC=$$(TARGET_TRIPLE-$(target))-gcc \ + CPP=$$(TARGET_TRIPLE-$(target))-cpp \ + CXX=$$(TARGET_TRIPLE-$(target))-gcc \ CFLAGS="$$(CFLAGS-$(target))" \ LDFLAGS="$$(LDFLAGS-$(target))" \ LIBLZMA_CFLAGS="-I$$(XZ_MERGE-$$(SDK-$(target)))/include" \ @@ -618,6 +607,18 @@ $$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe endif +PYTHON_SITECUSTOMIZE-$(target)=$(PROJECT_DIR)/support/$(PYTHON_VER)/$(os)/platform-site/$(target)/sitecustomize.py + +$$(PYTHON_SITECUSTOMIZE-$(target)): + @echo ">>> Create cross-platform sitecustomize.py for $(target)" + mkdir -p $$(dir $$(PYTHON_SITECUSTOMIZE-$(target))) + cat $(PROJECT_DIR)/patch/Python/sitecustomize.$(os).py \ + | sed -e "s/{{os}}/$(os)/g" \ + | sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \ + | sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(SDK-$(target))-$$(ARCH-$(target))/g" \ + > $$(PYTHON_SITECUSTOMIZE-$(target)) + + ########################################################################### # Target: Debug ########################################################################### @@ -705,6 +706,16 @@ PYTHON_FATLIB-$(sdk)=$$(PYTHON_MERGE-$(sdk))/libPython$(PYTHON_VER).a PYTHON_FATINCLUDE-$(sdk)=$$(PYTHON_MERGE-$(sdk))/Headers PYTHON_FATSTDLIB-$(sdk)=$$(PYTHON_MERGE-$(sdk))/python-stdlib +ifeq ($(os),macOS) +TARGET_TRIPLE-$(sdk)=apple-darwin +else + ifeq ($$(findstring simulator,$(sdk)),) +TARGET_TRIPLE-$(sdk)=apple-$$(OS_LOWER-$(sdk))$$(VERSION_MIN-$(os)) + else +TARGET_TRIPLE-$(sdk)=apple-$$(OS_LOWER-$(sdk))$$(VERSION_MIN-$(os))-simulator + endif +endif + # Expand the build-target macro for target on this OS $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(eval $$(call build-target,$$(target),$(os)))) @@ -712,14 +723,14 @@ $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(eval $$(call build-target,$$(target) # SDK: Aliases ########################################################################### -alias/clang-$(sdk): - patch/make-xcrun-alias alias/clang-$(sdk) "--sdk $(sdk) clang" +alias/$$(TARGET_TRIPLE-$(sdk))-gcc: + patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-gcc "--sdk $(sdk) clang" -alias/cpp-$(sdk): - patch/make-xcrun-alias alias/cpp-$(sdk) "--sdk $(sdk) clang -E" +alias/$$(TARGET_TRIPLE-$(sdk))-cpp: + patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-cpp "--sdk $(sdk) clang -E" -alias/ar-$(sdk): - patch/make-xcrun-alias alias/ar-$(sdk) "--sdk $(sdk) ar" +alias/$$(TARGET_TRIPLE-$(sdk))-ar: + patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-ar "--sdk $(sdk) ar" ########################################################################### # SDK: BZip2 @@ -810,15 +821,15 @@ $$(PYTHON_SRCDIR-$(sdk))/configure: \ touch $$(PYTHON_SRCDIR-$(sdk))/configure $$(PYTHON_SRCDIR-$(sdk))/Makefile: \ - alias/clang-$(sdk) \ - alias/cpp-$(sdk) \ + alias/$$(TARGET_TRIPLE-$(sdk))-gcc \ + alias/$$(TARGET_TRIPLE-$(sdk))-cpp \ $$(PYTHON_SRCDIR-$(sdk))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(sdk)) && \ PATH="$(PROJECT_DIR)/alias:$(PATH)" \ ./configure \ - CC=clang-$(sdk) \ - CPP=cpp-$(sdk) \ + CC=$$(TARGET_TRIPLE-$(sdk))-gcc \ + CPP=$$(TARGET_TRIPLE-$(sdk))-cpp \ CFLAGS="$$(CFLAGS-$(sdk))" \ LDFLAGS="$$(LDFLAGS-$(sdk))" \ LIBLZMA_CFLAGS="-I$$(XZ_MERGE-$(sdk))/include" \ @@ -981,12 +992,12 @@ clean-BZip2-$(os): install/$(os)/*/bzip2-$(BZIP2_VERSION).*.log \ merge/$(os)/*/bzip2-$(BZIP2_VERSION) \ merge/$(os)/*/bzip2-$(BZIP2_VERSION).*.log \ - wheels/dist/bzip2 + wheels/$(os)/bzip2 clean-BZip2-$(os)-wheels: rm -rf \ install/$(os)/*/bzip2-$(BZIP2_VERSION)/wheel \ - wheels/dist/bzip2 + wheels/$(os)/bzip2 ########################################################################### # Build: XZ (LZMA) @@ -1004,12 +1015,12 @@ clean-XZ-$(os): install/$(os)/*/xz-$(XZ_VERSION).*.log \ merge/$(os)/*/xz-$(XZ_VERSION) \ merge/$(os)/*/xz-$(XZ_VERSION).*.log \ - wheels/dist/xz + wheels/$(os)/xz clean-XZ-$(os)-wheels: rm -rf \ install/$(os)/*/xz-$(XZ_VERSION)/wheel \ - wheels/dist/xz + wheels/$(os)/xz ########################################################################### # Build: OpenSSL @@ -1027,12 +1038,12 @@ clean-OpenSSL-$(os): install/$(os)/*/openssl-$(OPENSSL_VERSION).*.log \ merge/$(os)/*/openssl-$(OPENSSL_VERSION) \ merge/$(os)/*/openssl-$(OPENSSL_VERSION).*.log \ - wheels/dist/openssl + wheels/$(os)/openssl clean-OpenSSL-$(os)-wheels: rm -rf \ install/$(os)/*/openssl-$(OPENSSL_VERSION)/wheel \ - wheels/dist/openssl + wheels/$(os)/openssl ########################################################################### # Build: libFFI @@ -1065,27 +1076,26 @@ clean-libFFI-$(os): build/$(os)/libffi-$(LIBFFI_VERSION).*.log \ merge/$(os)/libffi-$(LIBFFI_VERSION) \ merge/$(os)/libffi-$(LIBFFI_VERSION).*.log \ - wheels/dist/libffi + wheels/$(os)/libffi clean-libFFI-$(os)-wheels: rm -rf \ build/$(os)/libffi-$(LIBFFI_VERSION)/build_*/wheel \ - wheels/dist/libffi + wheels/$(os)/libffi ########################################################################### # Build: Python ########################################################################### -$$(PYTHON_XCFRAMEWORK-$(os)): \ +$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \ $$(foreach sdk,$$(SDKS-$(os)),$$(PYTHON_FATLIB-$$(sdk)) $$(PYTHON_FATINCLUDE-$$(sdk))) @echo ">>> Create Python.XCFramework on $(os)" mkdir -p $$(dir $$(PYTHON_XCFRAMEWORK-$(os))) xcodebuild -create-xcframework \ - -output $$@ $$(foreach sdk,$$(SDKS-$(os)),-library $$(PYTHON_FATLIB-$$(sdk)) -headers $$(PYTHON_FATINCLUDE-$$(sdk))) \ + -output $$(PYTHON_XCFRAMEWORK-$(os)) $$(foreach sdk,$$(SDKS-$(os)),-library $$(PYTHON_FATLIB-$$(sdk)) -headers $$(PYTHON_FATINCLUDE-$$(sdk))) \ 2>&1 | tee -a support/$(PYTHON_VER)/python-$(os).xcframework.log -$$(PYTHON_STDLIB-$(os)): \ - $$(PYTHON_XCFRAMEWORK-$(os)) \ +$$(PYTHON_STDLIB-$(os))/VERSIONS: \ $$(foreach sdk,$$(SDKS-$(os)),$$(PYTHON_FATSTDLIB-$$(sdk))) @echo ">>> Create Python stdlib on $(os)" # Copy stdlib from first SDK in $(os) @@ -1106,7 +1116,6 @@ $$(PYTHON_STDLIB-$(os)): \ # Copy the lib-dynload contents from every SDK in $(os) into the support folder. $$(foreach sdk,$$(SDKS-$(os)),cp $$(PYTHON_FATSTDLIB-$$(sdk))/lib-dynload/* $$(PYTHON_STDLIB-$(os))/lib-dynload; ) -dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: $$(PYTHON_XCFRAMEWORK-$(os)) $$(PYTHON_STDLIB-$(os)) @echo ">>> Create VERSIONS file for $(os)" echo "Python version: $(PYTHON_VERSION) " > support/$(PYTHON_VER)/$(os)/VERSIONS echo "Build: $(BUILD_NUMBER)" >> support/$(PYTHON_VER)/$(os)/VERSIONS @@ -1121,14 +1130,10 @@ endif echo "OpenSSL: $(OPENSSL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS echo "XZ: $(XZ_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS -ifneq ($(os),macOS) - @echo ">>> Create cross-platform site sitecustomize.py for $(os)" - mkdir -p support/$(PYTHON_VER)/$(os)/platform-site - cat $(PROJECT_DIR)/patch/Python/sitecustomize.py \ - | sed -e "s/{{os}}/$(os)/g" \ - | sed -e "s/{{tag}}/$$(shell echo $(os) | tr '[:upper:]' '[:lower:]')_$$(shell echo $$(VERSION_MIN-$(os)) | sed "s/\./_/g")/g" \ - > support/$(PYTHON_VER)/$(os)/platform-site/sitecustomize.py -endif +dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \ + $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist \ + $$(PYTHON_STDLIB-$(os))/VERSIONS \ + $$(foreach target,$$(TARGETS-$(os)), $$(PYTHON_SITECUSTOMIZE-$$(target))) \ @echo ">>> Create final distribution artefact for $(os)" mkdir -p dist @@ -1175,10 +1180,14 @@ merge-clean-Python-$(os): # Build ########################################################################### -$(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz $(os)-wheels: $(foreach dep,$(DEPENDENCIES),$(dep)-$(os)-wheels) +$(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz $(os)-wheels + +clean-$(os)-wheels: $(foreach dep,$(DEPENDENCIES),clean-$(dep)-$(os)-wheels) + @echo ">>> Clean $(os) wheels" + rm -rf wheel/$(os) -clean-$(os): +clean-$(os): clean-$(os)-wheels @echo ">>> Clean $(os) build products" rm -rf \ build/$(os) \ @@ -1187,8 +1196,6 @@ clean-$(os): dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz \ dist/Python-$(PYTHON_VER)-$(os)-support.test-$(BUILD_NUMBER).tar.gz -clean-$(os)-wheels: $(foreach dep,$(DEPENDENCIES),clean-$(dep)-$(os)-wheels) - ########################################################################### # Build: Debug ########################################################################### diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index 46b5603..71ebde1 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -419,7 +419,7 @@ index 6df5dd551e..597da09643 100644 # waiting for child processes has otherwise been # disabled for our process. This child is dead, we diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py -index ebe3711827..6006b92386 100644 +index ebe3711827..495dc7bf73 100644 --- a/Lib/sysconfig.py +++ b/Lib/sysconfig.py @@ -95,6 +95,33 @@ @@ -476,33 +476,7 @@ index ebe3711827..6006b92386 100644 return { 'prefix': 'posix_prefix', 'home': 'posix_home', -@@ -455,9 +489,24 @@ - - def _get_sysconfigdata_name(): - multiarch = getattr(sys.implementation, '_multiarch', '') -+ -+ # On most platforms, sys.platform is all we need. However, iOS/tvOS/watchOS have a -+ # single sys.platform, but two underlying platforms depending on whether we're on -+ # device or on simulator. -+ platform = { -+ ("ios", False): "iphoneos", -+ ("ios", True): "iphonesimulator", -+ ("tvos", True): "appletvos", -+ ("tvos", False): "appletvsimulator", -+ ("watchos", False): "watchos", -+ ("watchos", True): "watchsimulator", -+ }.get( -+ (sys.platform, getattr(sys.implementation, "_simulator", False)), -+ sys.platform -+ ) - return os.environ.get( - '_PYTHON_SYSCONFIGDATA_NAME', -- f'_sysconfigdata_{sys.abiflags}_{sys.platform}_{multiarch}', -+ f'_sysconfigdata_{sys.abiflags}_{platform}_{multiarch}' - ) - - -@@ -788,10 +837,16 @@ +@@ -788,10 +822,16 @@ if m: release = m.group() elif osname[:6] == "darwin": @@ -512,7 +486,7 @@ index ebe3711827..6006b92386 100644 - osname, release, machine) + if sys.platform in ("ios", "tvos", "watchos"): + import _ios_support -+ _, release, model = _ios_support.get_platform_ios() ++ _, release, _ = _ios_support.get_platform_ios() + osname = sys.platform + machine = sys.implementation._multiarch + else: @@ -1297,19 +1271,10 @@ index 44974d433b..ae4e18802b 100755 # # Platform support for Windows diff --git a/Makefile.pre.in b/Makefile.pre.in -index 884bea1841..a0d3bfecc1 100644 +index 884bea1841..a15df8a03c 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in -@@ -124,6 +124,8 @@ - # Strict or non-strict aliasing flags used to compile dtoa.c, see above - CFLAGS_ALIASING=@CFLAGS_ALIASING@ - -+# Platform descriptor -+PLATFORM= @PLATFORM@ - - # Machine-dependent subdirectories - MACHDEP= @MACHDEP@ -@@ -344,6 +346,8 @@ +@@ -344,6 +344,8 @@ ########################################################################## LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@ @@ -1318,15 +1283,6 @@ index 884bea1841..a0d3bfecc1 100644 ########################################################################## # Parser -@@ -1384,7 +1388,7 @@ - Python/compile.o Python/symtable.o Python/ast_unparse.o Python/ast.o Python/future.o: $(srcdir)/Include/internal/pycore_ast.h - - Python/getplatform.o: $(srcdir)/Python/getplatform.c -- $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c -+ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(PLATFORM)"' -o $@ $(srcdir)/Python/getplatform.c - - Python/importdl.o: $(srcdir)/Python/importdl.c - $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c diff --git a/Modules/_posixsubprocess.c b/Modules/_posixsubprocess.c index ad9daaede4..f295528d4e 100644 --- a/Modules/_posixsubprocess.c @@ -2028,18 +1984,10 @@ index d74fb6deac..a30f74f03d 100755 # Blank kernel with real OS is always fine. ;; diff --git a/configure b/configure -index af4a5bbfdf..ec56feb260 100755 +index af4a5bbfdf..03f864cc80 100755 --- a/configure +++ b/configure -@@ -819,6 +819,7 @@ - MACHDEP_OBJS - DYNLOADFILE - DLINCLDIR -+PLATFORM - PLATFORM_OBJS - PLATFORM_HEADERS - DTRACE_OBJS -@@ -838,6 +839,8 @@ +@@ -838,6 +838,8 @@ LIBMPDEC_INTERNAL LIBMPDEC_LDFLAGS LIBMPDEC_CFLAGS @@ -2048,7 +1996,7 @@ index af4a5bbfdf..ec56feb260 100755 LIBFFI_INCLUDEDIR LIBEXPAT_INTERNAL LIBEXPAT_LDFLAGS -@@ -991,7 +994,6 @@ +@@ -991,7 +993,6 @@ docdir oldincludedir includedir @@ -2056,7 +2004,7 @@ index af4a5bbfdf..ec56feb260 100755 localstatedir sharedstatedir sysconfdir -@@ -1142,7 +1144,6 @@ +@@ -1142,7 +1143,6 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' @@ -2064,7 +2012,7 @@ index af4a5bbfdf..ec56feb260 100755 includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' -@@ -1395,15 +1396,6 @@ +@@ -1395,15 +1395,6 @@ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; @@ -2080,7 +2028,7 @@ index af4a5bbfdf..ec56feb260 100755 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -@@ -1541,7 +1533,7 @@ +@@ -1541,7 +1532,7 @@ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ @@ -2089,7 +2037,7 @@ index af4a5bbfdf..ec56feb260 100755 do eval ac_val=\$$ac_var # Remove trailing slashes. -@@ -1694,7 +1686,6 @@ +@@ -1694,7 +1685,6 @@ --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] @@ -2097,77 +2045,140 @@ index af4a5bbfdf..ec56feb260 100755 --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] -@@ -3823,6 +3814,24 @@ +@@ -3823,6 +3813,15 @@ *-*-cygwin*) ac_sys_system=Cygwin ;; -+ *-apple-ios*-simulator) -+ ac_sys_system=iphonesimulator -+ ;; + *-apple-ios*) -+ ac_sys_system=iphoneos -+ ;; -+ *-apple-tvos*-simulator) -+ ac_sys_system=appletvsimulator ++ ac_sys_system=iOS + ;; + *-apple-tvos*) -+ ac_sys_system=appletvos -+ ;; -+ *-apple-watchos*-simulator) -+ ac_sys_system=watchsimulator ++ ac_sys_system=tvOS + ;; + *-apple-watchos*) -+ ac_sys_system=watchos ++ ac_sys_system=watchOS + ;; *-*-vxworks*) ac_sys_system=VxWorks ;; -@@ -3860,6 +3869,14 @@ - darwin*) MACHDEP="darwin";; - '') MACHDEP="unknown";; - esac -+ -+ case $ac_sys_system in -+ iphoneos | iphonesimulator) PLATFORM=ios;; -+ appletvos | appletvsimulator) PLATFORM=tvos;; -+ watchos | watchsimulator) PLATFORM=watchos;; -+ *) PLATFORM=$MACHDEP;; -+ esac -+ - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$MACHDEP\"" >&5 - $as_echo "\"$MACHDEP\"" >&6; } -@@ -3879,6 +3896,15 @@ - *-*-cygwin*) - _host_cpu= +@@ -3870,27 +3869,96 @@ + *-*-linux*) + case "$host_cpu" in + arm*) +- _host_cpu=arm ++ _host_ident=arm + ;; + *) +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu + esac ;; + *-*-cygwin*) +- _host_cpu= ++ _host_ident= ++ ;; ++ *-apple-ios*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-iphonesimulator-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-iphonesimulator-$host_cpu ++ esac ++ ;; ++ *-apple-ios*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-iphoneos-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-iphoneos-$host_cpu ++ esac ++ ;; ++ *-apple-tvos*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-appletvsimulator-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-appletvsimulator-$host_cpu ++ esac ++ ;; ++ *-apple-tvos*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-appletvos-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-appletvos-$host_cpu ++ esac ++ ;; ++ *-apple-watchos*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-watchsimualtor-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-watchsimualtor-$host_cpu ++ esac ++ ;; ++ *-apple-watchos*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-watchosos-arm64_32 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-watchosos-$host_cpu ++ esac ++ ;; + *-apple-*) + case "$host_cpu" in + arm*) -+ _host_cpu=arm ++ _host_ident=arm + ;; + *) -+ _host_cpu=$host_cpu ++ _host_ident=$host_cpu + esac -+ ;; + ;; *-*-vxworks*) - _host_cpu=$host_cpu +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu ;; -@@ -3957,6 +3983,13 @@ + wasm32-*-* | wasm64-*-*) +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu + ;; + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + as_fn_error $? "cross build not supported for $host" "$LINENO" 5 + esac +- _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" ++ _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}" + fi + + # Some systems cannot stand _XOPEN_SOURCE being defined at all; they +@@ -3957,6 +4025,13 @@ define_xopen_source=no;; Darwin/[12][0-9].*) define_xopen_source=no;; + # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. -+ iphoneos/*|iphonesimulator/*) ++ iOS/*) + define_xopen_source=no;; -+ appletv/*|appletvsimulator/*) ++ tvOS/*) + define_xopen_source=no;; -+ watchos/*|watchsimulator/*) ++ watchOS/*) + define_xopen_source=no;; # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) -@@ -6159,7 +6192,42 @@ +@@ -6159,7 +6234,42 @@ #elif defined(__gnu_hurd__) i386-gnu #elif defined(__APPLE__) @@ -2211,66 +2222,62 @@ index af4a5bbfdf..ec56feb260 100755 #elif defined(__VXWORKS__) vxworks #elif defined(__wasm32__) -@@ -6204,6 +6272,8 @@ +@@ -6204,6 +6314,12 @@ case $ac_sys_system in #( Darwin*) : MULTIARCH="" ;; #( -+ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) : ++ iOS) : ++ MULTIARCH="" ;; #( ++ tvOS) : ++ MULTIARCH="" ;; #( ++ watchOS) : + MULTIARCH="" ;; #( FreeBSD*) : MULTIARCH="" ;; #( *) : -@@ -6218,8 +6288,18 @@ +@@ -6211,8 +6327,6 @@ + ;; + esac + +-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5 +-$as_echo "$MULTIARCH" >&6; } + + if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then if test x$PLATFORM_TRIPLET != x$MULTIARCH; then - as_fn_error $? "internal configure error for the platform triplet, please file a bug report" "$LINENO" 5 - fi -+ SOABI_PLATFORM=$PLATFORM_TRIPLET - elif test x$PLATFORM_TRIPLET != x && test x$MULTIARCH = x; then -- MULTIARCH=$PLATFORM_TRIPLET -+ case $ac_sys_system in #( -+ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) : -+ SOABI_PLATFORM=$(echo $PLATFORM_TRIPLET | cut -d- -f1) -+ MULTIARCH=$(echo $PLATFORM_TRIPLET | cut -d- -f2) -+ ;; #( -+ *) : -+ MULTIARCH=$PLATFORM_TRIPLET -+ SOABI_PLATFORM=$PLATFORM_TRIPLET -+ ;; -+ esac +@@ -6222,6 +6336,16 @@ + MULTIARCH=$PLATFORM_TRIPLET fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MULTIARCH" >&5 ++$as_echo "$MULTIARCH" >&6; } ++ ++case $ac_sys_system in #( ++ iOS|tvOS|watchOS) : ++ SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f1` ;; #( ++ *) : ++ SOABI_PLATFORM=$PLATFORM_TRIPLET ++ ;; ++esac -@@ -6263,10 +6343,28 @@ + if test x$MULTIARCH != x; then + MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" +@@ -6265,8 +6389,14 @@ PY_SUPPORT_TIER=3 ;; #( - wasm32-unknown-wasi/clang) : + x86_64-*-freebsd*/clang) : PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-ios/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-ios-simulator/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ x86_64-apple-ios-simulator/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-tvos/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-tvos-simulator/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ x86_64-apple-tvos-simulator/clang) : -+ PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-watchos/clang) : ++ aarch64-apple-ios*-simulator/clang) : + PY_SUPPORT_TIER=3 ;; #( -+ aarch64-apple-watchos-simulator/clang) : ++ x86_64-apple-ios*-simulator/clang) : + PY_SUPPORT_TIER=3 ;; #( -+ x86_64-apple-watchos-simulator/clang) : ++ aarch64-apple-ios*/clang) : + PY_SUPPORT_TIER=3 ;; #( - x86_64-*-freebsd*/clang) : - PY_SUPPORT_TIER=3 ;; #( *) : - PY_SUPPORT_TIER=0 -+ PY_SUPPORT_TIER=0 ++ PY_SUPPORT_TIER=0 ;; esac -@@ -7210,11 +7308,23 @@ +@@ -7210,11 +7340,23 @@ fi if test "$cross_compiling" = yes; then @@ -2299,25 +2306,25 @@ index af4a5bbfdf..ec56feb260 100755 fi -@@ -10858,6 +10968,7 @@ +@@ -10858,6 +11000,7 @@ esac ;; CYGWIN*) SHLIB_SUFFIX=.dll;; -+ iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator) SHLIB_SUFFIX=.dylib;; ++ iOS|tvOS|watchOS) SHLIB_SUFFIX=.dylib;; *) SHLIB_SUFFIX=.so;; esac fi -@@ -10940,6 +11051,9 @@ +@@ -10940,6 +11083,9 @@ BLDSHARED="$LDSHARED" fi ;; -+ iphoneos/*|iphonesimulator/*|appletvos/*|appletvsimulator/*|watchos/*|watchsimulator*) ++ iOS/*|tvOS/*|watchOS/*) + LDSHARED='$(CC) -dynamiclib -undefined dynamic_lookup' + LDCXXSHARED='$(CXX) -dynamiclib -undefined dynamic_lookup';; Emscripten|WASI) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; -@@ -11348,8 +11462,8 @@ +@@ -11348,8 +11494,8 @@ pkg_failed=no @@ -2328,7 +2335,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBUUID_CFLAGS"; then pkg_cv_LIBUUID_CFLAGS="$LIBUUID_CFLAGS" -@@ -11389,7 +11503,7 @@ +@@ -11389,7 +11535,7 @@ if test $pkg_failed = yes; then @@ -2337,7 +2344,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -11532,7 +11646,7 @@ +@@ -11532,7 +11678,7 @@ elif test $pkg_failed = untried; then @@ -2346,14 +2353,14 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -12183,23 +12297,35 @@ +@@ -12183,23 +12329,35 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_system_ffi" >&5 $as_echo "$with_system_ffi" >&6; } else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - if test "$with_system_ffi" != "" -+ if test "$ac_sys_system" = "iphoneos" || test "$ac_sys_system" = "iphonesimulator" || test "$ac_sys_system" = "appletvos" || test "$ac_sys_system" = "appletvsimulator" || test "$ac_sys_system" = "watchos" || test "$ac_sys_system" = "watchsimulator" ++ if test "$ac_sys_system" = "iOS" || test "$ac_sys_system" = "tvOS" || test "$ac_sys_system" = "watchOS" then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --with(out)-system-ffi is ignored on this platform" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 @@ -2388,7 +2395,7 @@ index af4a5bbfdf..ec56feb260 100755 # Check for use of the system libmpdec library { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-system-libmpdec" >&5 $as_echo_n "checking for --with-system-libmpdec... " >&6; } -@@ -12340,8 +12466,8 @@ +@@ -12340,8 +12498,8 @@ pkg_failed=no @@ -2399,7 +2406,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBNSL_CFLAGS"; then pkg_cv_LIBNSL_CFLAGS="$LIBNSL_CFLAGS" -@@ -12381,7 +12507,7 @@ +@@ -12381,7 +12539,7 @@ if test $pkg_failed = yes; then @@ -2408,7 +2415,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12482,7 +12608,7 @@ +@@ -12482,7 +12640,7 @@ LIBNSL_LIBS=${LIBNSL_LIBS-$libnsl} elif test $pkg_failed = untried; then @@ -2417,7 +2424,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } LIBNSL_CFLAGS=${LIBNSL_CFLAGS-""} -@@ -12630,8 +12756,8 @@ +@@ -12630,8 +12788,8 @@ pkg_failed=no @@ -2428,7 +2435,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBSQLITE3_CFLAGS"; then pkg_cv_LIBSQLITE3_CFLAGS="$LIBSQLITE3_CFLAGS" -@@ -12671,7 +12797,7 @@ +@@ -12671,7 +12829,7 @@ if test $pkg_failed = yes; then @@ -2437,7 +2444,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -12693,7 +12819,7 @@ +@@ -12693,7 +12851,7 @@ elif test $pkg_failed = untried; then @@ -2446,7 +2453,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } LIBSQLITE3_CFLAGS=${LIBSQLITE3_CFLAGS-""} -@@ -13462,8 +13588,8 @@ +@@ -13462,8 +13620,8 @@ pkg_failed=no @@ -2457,7 +2464,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$TCLTK_CFLAGS"; then pkg_cv_TCLTK_CFLAGS="$TCLTK_CFLAGS" -@@ -13503,7 +13629,7 @@ +@@ -13503,7 +13661,7 @@ if test $pkg_failed = yes; then @@ -2466,7 +2473,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13521,7 +13647,7 @@ +@@ -13521,7 +13679,7 @@ found_tcltk=no elif test $pkg_failed = untried; then @@ -2475,7 +2482,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } found_tcltk=no else -@@ -13557,8 +13683,8 @@ +@@ -13557,8 +13715,8 @@ pkg_failed=no @@ -2486,7 +2493,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$X11_CFLAGS"; then pkg_cv_X11_CFLAGS="$X11_CFLAGS" -@@ -13598,7 +13724,7 @@ +@@ -13598,7 +13756,7 @@ if test $pkg_failed = yes; then @@ -2495,7 +2502,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -13625,7 +13751,7 @@ +@@ -13625,7 +13783,7 @@ and X11_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then @@ -2504,7 +2511,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -@@ -16201,8 +16327,8 @@ +@@ -16201,8 +16359,8 @@ pkg_failed=no @@ -2515,7 +2522,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" -@@ -16242,7 +16368,7 @@ +@@ -16242,7 +16400,7 @@ if test $pkg_failed = yes; then @@ -2524,7 +2531,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16386,7 +16512,7 @@ +@@ -16386,7 +16544,7 @@ elif test $pkg_failed = untried; then @@ -2533,7 +2540,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16549,8 +16675,8 @@ +@@ -16549,8 +16707,8 @@ pkg_failed=no @@ -2544,7 +2551,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$BZIP2_CFLAGS"; then pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" -@@ -16590,7 +16716,7 @@ +@@ -16590,7 +16748,7 @@ if test $pkg_failed = yes; then @@ -2553,7 +2560,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16687,7 +16813,7 @@ +@@ -16687,7 +16845,7 @@ elif test $pkg_failed = untried; then @@ -2562,7 +2569,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -16779,8 +16905,8 @@ +@@ -16779,8 +16937,8 @@ pkg_failed=no @@ -2573,7 +2580,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBLZMA_CFLAGS"; then pkg_cv_LIBLZMA_CFLAGS="$LIBLZMA_CFLAGS" -@@ -16820,7 +16946,7 @@ +@@ -16820,7 +16978,7 @@ if test $pkg_failed = yes; then @@ -2582,7 +2589,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -16917,7 +17043,7 @@ +@@ -16917,7 +17075,7 @@ elif test $pkg_failed = untried; then @@ -2591,7 +2598,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -18150,8 +18276,8 @@ +@@ -18150,8 +18308,8 @@ pkg_failed=no @@ -2602,7 +2609,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBCRYPT_CFLAGS"; then pkg_cv_LIBCRYPT_CFLAGS="$LIBCRYPT_CFLAGS" -@@ -18191,7 +18317,7 @@ +@@ -18191,7 +18349,7 @@ if test $pkg_failed = yes; then @@ -2611,7 +2618,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -18288,7 +18414,7 @@ +@@ -18288,7 +18446,7 @@ elif test $pkg_failed = untried; then @@ -2620,7 +2627,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } save_CFLAGS=$CFLAGS -@@ -20750,7 +20876,7 @@ +@@ -20750,7 +20908,7 @@ $as_echo "$ABIFLAGS" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5 $as_echo_n "checking SOABI... " >&6; } @@ -2629,7 +2636,7 @@ index af4a5bbfdf..ec56feb260 100755 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5 $as_echo "$SOABI" >&6; } -@@ -20758,7 +20884,7 @@ +@@ -20758,7 +20916,7 @@ if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then # Similar to SOABI but remove "d" flag from ABIFLAGS @@ -2638,7 +2645,7 @@ index af4a5bbfdf..ec56feb260 100755 cat >>confdefs.h <<_ACEOF #define ALT_SOABI "${ALT_SOABI}" -@@ -23063,8 +23189,8 @@ +@@ -23063,8 +23221,8 @@ if ! $found; then OPENSSL_INCLUDES= for ssldir in $ssldirs; do @@ -2649,7 +2656,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -f "$ssldir/include/openssl/ssl.h"; then OPENSSL_INCLUDES="-I$ssldir/include" OPENSSL_LDFLAGS="-L$ssldir/lib" -@@ -23445,8 +23571,8 @@ +@@ -23445,8 +23603,8 @@ pkg_failed=no @@ -2660,7 +2667,7 @@ index af4a5bbfdf..ec56feb260 100755 if test -n "$LIBB2_CFLAGS"; then pkg_cv_LIBB2_CFLAGS="$LIBB2_CFLAGS" -@@ -23486,7 +23612,7 @@ +@@ -23486,7 +23644,7 @@ if test $pkg_failed = yes; then @@ -2669,7 +2676,7 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then -@@ -23504,7 +23630,7 @@ +@@ -23504,7 +23662,7 @@ have_libb2=no elif test $pkg_failed = untried; then @@ -2678,11 +2685,11 @@ index af4a5bbfdf..ec56feb260 100755 $as_echo "no" >&6; } have_libb2=no else -@@ -23575,6 +23701,29 @@ +@@ -23575,6 +23733,29 @@ py_cv_module_ossaudiodev=n/a py_cv_module_spwd=n/a ;; #( -+ iphoneos|iphonesimulator|appletvos|appletvsimulator|watchos|watchsimulator) : ++ iOS|tvOS|watchOS) : + + + @@ -2709,7 +2716,7 @@ index af4a5bbfdf..ec56feb260 100755 diff --git a/configure.ac b/configure.ac -index e1cbb7c7fb..aa944cfc0c 100644 +index e1cbb7c7fb..34cf532a87 100644 --- a/configure.ac +++ b/configure.ac @@ -545,6 +545,15 @@ @@ -2728,23 +2735,110 @@ index e1cbb7c7fb..aa944cfc0c 100644 *-*-vxworks*) ac_sys_system=VxWorks ;; -@@ -600,6 +609,15 @@ - *-*-cygwin*) - _host_cpu= +@@ -591,27 +600,96 @@ + *-*-linux*) + case "$host_cpu" in + arm*) +- _host_cpu=arm ++ _host_ident=arm + ;; + *) +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu + esac ;; + *-*-cygwin*) +- _host_cpu= ++ _host_ident= ++ ;; ++ *-apple-ios*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-iphonesimulator-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-iphonesimulator-$host_cpu ++ esac ++ ;; ++ *-apple-ios*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-iphoneos-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-iphoneos-$host_cpu ++ esac ++ ;; ++ *-apple-tvos*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-appletvsimulator-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-appletvsimulator-$host_cpu ++ esac ++ ;; ++ *-apple-tvos*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-appletvos-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-appletvos-$host_cpu ++ esac ++ ;; ++ *-apple-watchos*-simulator) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-watchsimualtor-arm64 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-watchsimualtor-$host_cpu ++ esac ++ ;; ++ *-apple-watchos*) ++ _host_os_min_version=`echo $host | cut -d '-' -f3` ++ case "$host_cpu" in ++ aarch64) ++ _host_ident=${_host_os_min_version:3}-watchosos-arm64_32 ++ ;; ++ *) ++ _host_ident=${_host_os_min_version:3}-watchosos-$host_cpu ++ esac ++ ;; + *-apple-*) + case "$host_cpu" in + arm*) -+ _host_cpu=arm ++ _host_ident=arm + ;; + *) -+ _host_cpu=$host_cpu ++ _host_ident=$host_cpu + esac -+ ;; + ;; *-*-vxworks*) - _host_cpu=$host_cpu +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu + ;; + wasm32-*-* | wasm64-*-*) +- _host_cpu=$host_cpu ++ _host_ident=$host_cpu ;; -@@ -675,6 +693,13 @@ + *) + # for now, limit cross builds to known configurations + MACHDEP="unknown" + AC_MSG_ERROR([cross build not supported for $host]) + esac +- _PYTHON_HOST_PLATFORM="$MACHDEP${_host_cpu:+-$_host_cpu}" ++ _PYTHON_HOST_PLATFORM="$MACHDEP${_host_ident:+-$_host_ident}" + fi + + # Some systems cannot stand _XOPEN_SOURCE being defined at all; they +@@ -675,6 +753,13 @@ define_xopen_source=no;; Darwin/@<:@[12]@:>@@<:@0-9@:>@.*) define_xopen_source=no;; @@ -2758,7 +2852,7 @@ index e1cbb7c7fb..aa944cfc0c 100644 # On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from # defining NI_NUMERICHOST. QNX/6.3.2) -@@ -1054,7 +1079,30 @@ +@@ -1054,7 +1139,42 @@ #elif defined(__gnu_hurd__) i386-gnu #elif defined(__APPLE__) @@ -2766,21 +2860,33 @@ index e1cbb7c7fb..aa944cfc0c 100644 +# include "TargetConditionals.h" +# if TARGET_OS_IOS +# if TARGET_OS_SIMULATOR -+ iphonesimulator ++# if __x86_64__ ++ iphonesimulator-x86_64 ++# else ++ iphonesimulator-arm64 ++# endif +# else -+ iphoneos ++ iphoneos-arm64 +# endif +# elif TARGET_OS_TV +# if TARGET_OS_SIMULATOR -+ appletvsimulator ++# if __x86_64__ ++ appletvsimulator-x86_64 ++# else ++ appletvsimulator-arm64 ++# endif +# else -+ appletvos ++ appletvos-arm64 +# endif +# elif TARGET_OS_WATCH +# if TARGET_OS_SIMULATOR -+ watchsimulator ++# if __x86_64__ ++ watchsimulator-x86_64 ++# else ++ watchsimulator-arm64 ++# endif +# else -+ watchos ++ watchos-arm64_32 +# endif +# elif TARGET_OS_OSX + darwin @@ -2790,33 +2896,51 @@ index e1cbb7c7fb..aa944cfc0c 100644 #elif defined(__VXWORKS__) vxworks #elif defined(__wasm32__) -@@ -1095,6 +1143,9 @@ +@@ -1095,11 +1215,13 @@ AC_MSG_CHECKING([for multiarch]) AS_CASE([$ac_sys_system], [Darwin*], [MULTIARCH=""], -+ [iOS*], [MULTIARCH=""], -+ [tvOS*], [MULTIARCH=""], -+ [watchOS*], [MULTIARCH=""], ++ [iOS], [MULTIARCH=""], ++ [tvOS], [MULTIARCH=""], ++ [watchOS], [MULTIARCH=""], [FreeBSD*], [MULTIARCH=""], [MULTIARCH=$($CC --print-multiarch 2>/dev/null)] ) -@@ -1139,6 +1190,15 @@ + AC_SUBST([MULTIARCH]) +-AC_MSG_RESULT([$MULTIARCH]) + + if test x$PLATFORM_TRIPLET != x && test x$MULTIARCH != x; then + if test x$PLATFORM_TRIPLET != x$MULTIARCH; then +@@ -1109,6 +1231,12 @@ + MULTIARCH=$PLATFORM_TRIPLET + fi + AC_SUBST(PLATFORM_TRIPLET) ++AC_MSG_RESULT([$MULTIARCH]) ++ ++AS_CASE([$ac_sys_system], ++ [iOS|tvOS|watchOS], [SOABI_PLATFORM=`echo "$PLATFORM_TRIPLET" | cut -d '-' -f1`], ++ [SOABI_PLATFORM=$PLATFORM_TRIPLET] ++) + + if test x$MULTIARCH != x; then + MULTIARCH_CPPFLAGS="-DMULTIARCH=\\\"$MULTIARCH\\\"" +@@ -1139,6 +1267,15 @@ [wasm32-unknown-emscripten/clang], [PY_SUPPORT_TIER=3], dnl WebAssembly Emscripten [wasm32-unknown-wasi/clang], [PY_SUPPORT_TIER=3], dnl WebAssembly System Interface [x86_64-*-freebsd*/clang], [PY_SUPPORT_TIER=3], dnl FreeBSD on AMD64 -+ dnl [aarch64-apple-ios/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64 -+ dnl [aarch64-apple-ios-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64 -+ dnl [x86_64-apple-ios-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on x86_64 -+ dnl [aarch64-apple-tvos/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS on ARM64 -+ dnl [aarch64-apple-tvos-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS Simulator on ARM64 -+ dnl [x86_64-apple-tvos-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS Simulator on x86_64 -+ dnl [arm64_32-apple-watchos/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS on ARM64_32 -+ dnl [aarch64-apple-watchos-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS Simulator on ARM64 -+ dnl [x86_64-apple-watchos-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS Simulator on x86_64 ++ [aarch64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on arm64 ++ [x86_64-apple-ios*-simulator/clang], [PY_SUPPORT_TIER=3], dnl iOS Simulator on x86_64 ++ [aarch64-apple-ios*/clang], [PY_SUPPORT_TIER=3], dnl iOS on ARM64 ++ dnl [aarch64-apple-tvos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS Simulator on ARM64 ++ dnl [x86_64-apple-tvos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS Simulator on x86_64 ++ dnl [aarch64-apple-tvos*/clang], [PY_SUPPORT_TIER=3], dnl Apple tvOS on ARM64 ++ dnl [aarch64-apple-watchos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS Simulator on ARM64 ++ dnl [x86_64-apple-watchos*-simulator/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS Simulator on x86_64 ++ dnl [arm64_32-apple-watchos*/clang], [PY_SUPPORT_TIER=3], dnl Apple watchOS on ARM64_32 [PY_SUPPORT_TIER=0] ) -@@ -1627,11 +1687,23 @@ +@@ -1627,11 +1764,23 @@ AC_CHECK_TOOLS([READELF], [readelf], [:]) if test "$cross_compiling" = yes; then @@ -2845,7 +2969,7 @@ index e1cbb7c7fb..aa944cfc0c 100644 fi AC_SUBST(READELF) -@@ -3091,6 +3163,7 @@ +@@ -3091,6 +3240,7 @@ esac ;; CYGWIN*) SHLIB_SUFFIX=.dll;; @@ -2853,7 +2977,7 @@ index e1cbb7c7fb..aa944cfc0c 100644 *) SHLIB_SUFFIX=.so;; esac fi -@@ -3171,6 +3244,9 @@ +@@ -3171,6 +3321,9 @@ BLDSHARED="$LDSHARED" fi ;; @@ -2863,7 +2987,7 @@ index e1cbb7c7fb..aa944cfc0c 100644 Emscripten|WASI) LDSHARED='$(CC) -shared' LDCXXSHARED='$(CXX) -shared';; -@@ -3640,20 +3716,30 @@ +@@ -3640,20 +3793,30 @@ esac AC_MSG_RESULT($with_system_ffi) else @@ -2899,7 +3023,24 @@ index e1cbb7c7fb..aa944cfc0c 100644 # Check for use of the system libmpdec library AC_MSG_CHECKING(for --with-system-libmpdec) -@@ -6833,6 +6919,30 @@ +@@ -5687,14 +5850,14 @@ + AC_MSG_CHECKING(ABIFLAGS) + AC_MSG_RESULT($ABIFLAGS) + AC_MSG_CHECKING(SOABI) +-SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} ++SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${SOABI_PLATFORM:+-$SOABI_PLATFORM} + AC_MSG_RESULT($SOABI) + + # Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI + if test "$Py_DEBUG" = 'true' -a "$with_trace_refs" != "yes"; then + # Similar to SOABI but remove "d" flag from ABIFLAGS + AC_SUBST(ALT_SOABI) +- ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET} ++ ALT_SOABI='cpython-'`echo $VERSION | tr -d .``echo $ABIFLAGS | tr -d d`${SOABI_PLATFORM:+-$SOABI_PLATFORM} + AC_DEFINE_UNQUOTED(ALT_SOABI, "${ALT_SOABI}", + [Alternative SOABI used in debug build to load C extensions built in release mode]) + fi +@@ -6833,6 +6996,30 @@ [AIX], [PY_STDLIB_MOD_SET_NA([_scproxy], [spwd])], [VxWorks*], [PY_STDLIB_MOD_SET_NA([_scproxy], [_crypt], [termios], [grp])], [Darwin], [PY_STDLIB_MOD_SET_NA([ossaudiodev], [spwd])], diff --git a/patch/Python/sitecustomize.py b/patch/Python/sitecustomize.iOS.py similarity index 100% rename from patch/Python/sitecustomize.py rename to patch/Python/sitecustomize.iOS.py diff --git a/patch/Python/sitecustomize.macOS.py b/patch/Python/sitecustomize.macOS.py new file mode 100644 index 0000000..500714d --- /dev/null +++ b/patch/Python/sitecustomize.macOS.py @@ -0,0 +1,14 @@ +# 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 {{arch}}. +import platform + +# Make platform.mac_ver() return {{arch}} +orig_mac_ver = platform.mac_ver + +def custom_mac_ver(): + orig = orig_mac_ver() + return orig[0], orig[1], "{{arch}}" + +platform.mac_ver = custom_mac_ver diff --git a/patch/Python/sitecustomize.tvOS.py b/patch/Python/sitecustomize.tvOS.py new file mode 100644 index 0000000..d7d86e3 --- /dev/null +++ b/patch/Python/sitecustomize.tvOS.py @@ -0,0 +1,99 @@ +# 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 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 sysconfig.get_platform() return "{{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) diff --git a/patch/Python/sitecustomize.watchOS.py b/patch/Python/sitecustomize.watchOS.py new file mode 100644 index 0000000..d7d86e3 --- /dev/null +++ b/patch/Python/sitecustomize.watchOS.py @@ -0,0 +1,99 @@ +# 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 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 sysconfig.get_platform() return "{{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) From 461e34c46d93d356f398e6a8d2c316476095768d Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 26 Sep 2023 13:08:07 +0800 Subject: [PATCH 9/9] Use an install/bin folder rather than alias, and make the wheel output flat. --- Makefile | 117 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 64 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index facfa47..f7b7b5e 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,13 @@ BZIP2_VERSION=1.0.8 XZ_VERSION=5.4.4 +# Preference is to use OpenSSL 3; however, Cryptography 3.4.8 (and +# probably some other packages as well) only works with 1.1.1, so +# we need to preserve the ability to build the older OpenSSL (for now...) OPENSSL_VERSION=3.1.2 +# OPENSSL_VERSION_NUMBER=1.1.1 +# OPENSSL_REVISION=v +# OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION) LIBFFI_VERSION=3.4.4 @@ -101,7 +107,7 @@ all: $(OS_LIST) wheels # Clean all builds clean: - rm -rf alias build install merge dist support wheels + rm -rf build install merge dist support wheels # Full clean - includes all downloaded products distclean: clean @@ -223,11 +229,11 @@ LDFLAGS-$(target)=$$(CFLAGS-$(os)) # Target: Aliases ########################################################################### -alias/$$(TARGET_TRIPLE-$(target))-gcc: - patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(target))-gcc "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" +install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-gcc: + patch/make-xcrun-alias $$@ "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target))" -alias/$$(TARGET_TRIPLE-$(target))-cpp: - patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(target))-cpp "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" +install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-cpp: + patch/make-xcrun-alias $$@ "--sdk $$(SDK-$(target)) clang -target $$(TARGET_TRIPLE-$(target)) -E" ########################################################################### # Target: BZip2 @@ -236,7 +242,7 @@ alias/$$(TARGET_TRIPLE-$(target))-cpp: BZIP2_SRCDIR-$(target)=build/$(os)/$(target)/bzip2-$(BZIP2_VERSION) BZIP2_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/bzip2-$(BZIP2_VERSION) BZIP2_LIB-$(target)=$$(BZIP2_INSTALL-$(target))/lib/libbz2.a -BZIP2_WHEEL-$(target)=wheels/$(os)/bzip2/bzip2-$(BZIP2_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +BZIP2_WHEEL-$(target)=wheels/$(os)/bzip2-$(BZIP2_VERSION)-1-$$(WHEEL_TAG-$(target)).whl BZIP2_WHEEL_DISTINFO-$(target)=$$(BZIP2_INSTALL-$(target))/wheel/bzip2-$(BZIP2_VERSION).dist-info $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz @@ -246,10 +252,10 @@ $$(BZIP2_SRCDIR-$(target))/Makefile: downloads/bzip2-$(BZIP2_VERSION).tar.gz # Touch the makefile to ensure that Make identifies it as up to date. touch $$(BZIP2_SRCDIR-$(target))/Makefile -$$(BZIP2_LIB-$(target)): alias/$$(TARGET_TRIPLE-$(target))-gcc $$(BZIP2_SRCDIR-$(target))/Makefile +$$(BZIP2_LIB-$(target)): install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-gcc $$(BZIP2_SRCDIR-$(target))/Makefile @echo ">>> Build BZip2 for $(target)" cd $$(BZIP2_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ make install \ PREFIX="$$(BZIP2_INSTALL-$(target))" \ CC=$$(TARGET_TRIPLE-$(target))-gcc \ @@ -284,8 +290,8 @@ $$(BZIP2_WHEEL-$(target)): $$(BZIP2_LIB-$(target)) $$(BDIST_WHEEL) echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(BZIP2_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/$(os)/bzip2 - $(HOST_PYTHON_EXE) -m wheel pack $$(BZIP2_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/bzip2 --build-number 1 + mkdir -p wheels/$(os) + $(HOST_PYTHON_EXE) -m wheel pack $$(BZIP2_INSTALL-$(target))/wheel --dest-dir wheels/$(os) --build-number 1 ########################################################################### # Target: XZ (LZMA) @@ -294,7 +300,7 @@ $$(BZIP2_WHEEL-$(target)): $$(BZIP2_LIB-$(target)) $$(BDIST_WHEEL) XZ_SRCDIR-$(target)=build/$(os)/$(target)/xz-$(XZ_VERSION) XZ_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/xz-$(XZ_VERSION) XZ_LIB-$(target)=$$(XZ_INSTALL-$(target))/lib/liblzma.a -XZ_WHEEL-$(target)=wheels/$(os)/xz/xz-$(XZ_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +XZ_WHEEL-$(target)=wheels/$(os)/xz-$(XZ_VERSION)-1-$$(WHEEL_TAG-$(target)).whl XZ_WHEEL_DISTINFO-$(target)=$$(XZ_INSTALL-$(target))/wheel/xz-$(XZ_VERSION).dist-info $$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz @@ -306,10 +312,10 @@ $$(XZ_SRCDIR-$(target))/configure: downloads/xz-$(XZ_VERSION).tar.gz # Touch the configure script to ensure that Make identifies it as up to date. touch $$(XZ_SRCDIR-$(target))/configure -$$(XZ_SRCDIR-$(target))/Makefile: alias/$$(TARGET_TRIPLE-$(target))-gcc $$(XZ_SRCDIR-$(target))/configure +$$(XZ_SRCDIR-$(target))/Makefile: install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-gcc $$(XZ_SRCDIR-$(target))/configure # Configure the build cd $$(XZ_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ ./configure \ CC=$$(TARGET_TRIPLE-$(target))-gcc \ CFLAGS="$$(CFLAGS-$(target))" \ @@ -324,7 +330,7 @@ $$(XZ_SRCDIR-$(target))/Makefile: alias/$$(TARGET_TRIPLE-$(target))-gcc $$(XZ_SR $$(XZ_LIB-$(target)): $$(XZ_SRCDIR-$(target))/Makefile @echo ">>> Build and install XZ for $(target)" cd $$(XZ_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ make install \ 2>&1 | tee -a ../xz-$(XZ_VERSION).build.log @@ -356,8 +362,8 @@ $$(XZ_WHEEL-$(target)): $$(XZ_LIB-$(target)) $$(BDIST_WHEEL) echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(XZ_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/$(os)/xz - $(HOST_PYTHON_EXE) -m wheel pack $$(XZ_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/xz --build-number 1 + mkdir -p wheels/$(os) + $(HOST_PYTHON_EXE) -m wheel pack $$(XZ_INSTALL-$(target))/wheel --dest-dir wheels/$(os) --build-number 1 ########################################################################### # Target: OpenSSL @@ -367,7 +373,7 @@ OPENSSL_SRCDIR-$(target)=build/$(os)/$(target)/openssl-$(OPENSSL_VERSION) OPENSSL_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/openssl-$(OPENSSL_VERSION) OPENSSL_SSL_LIB-$(target)=$$(OPENSSL_INSTALL-$(target))/lib/libssl.a OPENSSL_CRYPTO_LIB-$(target)=$$(OPENSSL_INSTALL-$(target))/lib/libcrypto.a -OPENSSL_WHEEL-$(target)=wheels/$(os)/openssl/openssl-$(OPENSSL_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +OPENSSL_WHEEL-$(target)=wheels/$(os)/openssl-$(OPENSSL_VERSION)-1-$$(WHEEL_TAG-$(target)).whl OPENSSL_WHEEL_DISTINFO-$(target)=$$(OPENSSL_INSTALL-$(target))/wheel/openssl-$(OPENSSL_VERSION).dist-info $$(OPENSSL_SRCDIR-$(target))/Configure: downloads/openssl-$(OPENSSL_VERSION).tar.gz @@ -377,18 +383,23 @@ $$(OPENSSL_SRCDIR-$(target))/Configure: downloads/openssl-$(OPENSSL_VERSION).tar ifneq ($(os),macOS) # Patch code to disable the use of fork as it's not available on $(os) +ifeq ($(OPENSSL_VERSION_NUMBER),1.1.1) + sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/speed.c + sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/ocsp.c +else sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/include/http_server.h sed -ie 's/define HAVE_FORK 1/define HAVE_FORK 0/' $$(OPENSSL_SRCDIR-$(target))/apps/speed.c +endif endif # Touch the Configure script to ensure that Make identifies it as up to date. touch $$(OPENSSL_SRCDIR-$(target))/Configure -$$(OPENSSL_SRCDIR-$(target))/is_configured: alias/$$(TARGET_TRIPLE-$(target))-gcc $$(OPENSSL_SRCDIR-$(target))/Configure +$$(OPENSSL_SRCDIR-$(target))/is_configured: install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-gcc $$(OPENSSL_SRCDIR-$(target))/Configure # Configure the OpenSSL build ifeq ($(os),macOS) cd $$(OPENSSL_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ ./Configure darwin64-$$(ARCH-$(target))-cc no-tests \ --prefix="$$(OPENSSL_INSTALL-$(target))" \ @@ -396,7 +407,7 @@ ifeq ($(os),macOS) 2>&1 | tee -a ../openssl-$(OPENSSL_VERSION).config.log else cd $$(OPENSSL_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -417,7 +428,7 @@ $$(OPENSSL_SRCDIR-$(target))/libssl.a: $$(OPENSSL_SRCDIR-$(target))/is_configure # OpenSSL's `all` target modifies the Makefile; # use the raw targets that make up all and it's dependencies cd $$(OPENSSL_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -428,7 +439,7 @@ $$(OPENSSL_SSL_LIB-$(target)): $$(OPENSSL_SRCDIR-$(target))/libssl.a @echo ">>> Install OpenSSL for $(target)" # Install just the software (not the docs) cd $$(OPENSSL_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ CC="$$(TARGET_TRIPLE-$(target))-gcc $$(CFLAGS-$(target))" \ CROSS_TOP="$$(dir $$(SDK_ROOT-$(target))).." \ CROSS_SDK="$$(notdir $$(SDK_ROOT-$(target)))" \ @@ -470,8 +481,8 @@ $$(OPENSSL_WHEEL-$(target)): $$(OPENSSL_LIB-$(target)) $$(BDIST_WHEEL) echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(OPENSSL_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/$(os)/openssl - $(HOST_PYTHON_EXE) -m wheel pack $$(OPENSSL_INSTALL-$(target))/wheel --dest-dir wheels/$(os)/openssl --build-number 1 + mkdir -p wheels/$(os) + $(HOST_PYTHON_EXE) -m wheel pack $$(OPENSSL_INSTALL-$(target))/wheel --dest-dir wheels/$(os) --build-number 1 ########################################################################### # Target: libFFI @@ -485,7 +496,7 @@ ifneq ($(os),macOS) LIBFFI_SRCDIR-$(os)=build/$(os)/libffi-$(LIBFFI_VERSION) LIBFFI_SRCDIR-$(target)=$$(LIBFFI_SRCDIR-$(os))/build_$$(SDK-$(target))-$$(ARCH-$(target)) LIBFFI_LIB-$(target)=$$(LIBFFI_SRCDIR-$(target))/.libs/libffi.a -LIBFFI_WHEEL-$(target)=wheels/$(os)/libffi/libffi-$(LIBFFI_VERSION)-1-$$(WHEEL_TAG-$(target)).whl +LIBFFI_WHEEL-$(target)=wheels/$(os)/libffi-$(LIBFFI_VERSION)-1-$$(WHEEL_TAG-$(target)).whl LIBFFI_WHEEL_DISTINFO-$(target)=$$(LIBFFI_SRCDIR-$(target))/wheel/libffi-$(LIBFFI_VERSION).dist-info $$(LIBFFI_LIB-$(target)): $$(LIBFFI_SRCDIR-$(os))/darwin_common/include/ffi.h @@ -524,8 +535,8 @@ $$(LIBFFI_WHEEL-$(target)): $$(LIBFFI_LIB-$(target)) $$(BDIST_WHEEL) echo "Tag: $$(WHEEL_TAG-$(target))" >> $$(LIBFFI_WHEEL_DISTINFO-$(target))/WHEEL # Pack the wheel - mkdir -p wheels/$(os)/libffi - $(HOST_PYTHON_EXE) -m wheel pack $$(LIBFFI_SRCDIR-$(target))/wheel --dest-dir wheels/$(os)/libffi --build-number 1 + mkdir -p wheels/$(os) + $(HOST_PYTHON_EXE) -m wheel pack $$(LIBFFI_SRCDIR-$(target))/wheel --dest-dir wheels/$(os) --build-number 1 endif @@ -558,13 +569,13 @@ $$(PYTHON_SRCDIR-$(target))/configure: \ touch $$(PYTHON_SRCDIR-$(target))/configure $$(PYTHON_SRCDIR-$(target))/Makefile: \ - alias/$$(TARGET_TRIPLE-$$(SDK-$(target)))-ar \ - alias/$$(TARGET_TRIPLE-$(target))-gcc \ - alias/$$(TARGET_TRIPLE-$(target))-cpp \ + install/$(os)/bin/$$(TARGET_TRIPLE-$$(SDK-$(target)))-ar \ + install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-gcc \ + install/$(os)/bin/$$(TARGET_TRIPLE-$(target))-cpp \ $$(PYTHON_SRCDIR-$(target))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ ./configure \ AR=$$(TARGET_TRIPLE-$$(SDK-$(target)))-ar \ CC=$$(TARGET_TRIPLE-$(target))-gcc \ @@ -594,14 +605,14 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \ $$(PYTHON_SRCDIR-$(target))/python.exe: $$(PYTHON_SRCDIR-$(target))/Makefile @echo ">>> Build Python for $(target)" cd $$(PYTHON_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ make all \ 2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log $$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe @echo ">>> Install Python for $(target)" cd $$(PYTHON_SRCDIR-$(target)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ make install \ 2>&1 | tee -a ../python-$(PYTHON_VERSION).install.log @@ -723,14 +734,14 @@ $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(eval $$(call build-target,$$(target) # SDK: Aliases ########################################################################### -alias/$$(TARGET_TRIPLE-$(sdk))-gcc: - patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-gcc "--sdk $(sdk) clang" +install/$(os)/bin/$$(TARGET_TRIPLE-$(sdk))-gcc: + patch/make-xcrun-alias $$@ "--sdk $(sdk) clang" -alias/$$(TARGET_TRIPLE-$(sdk))-cpp: - patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-cpp "--sdk $(sdk) clang -E" +install/$(os)/bin/$$(TARGET_TRIPLE-$(sdk))-cpp: + patch/make-xcrun-alias $$@ "--sdk $(sdk) clang -E" -alias/$$(TARGET_TRIPLE-$(sdk))-ar: - patch/make-xcrun-alias alias/$$(TARGET_TRIPLE-$(sdk))-ar "--sdk $(sdk) ar" +install/$(os)/bin/$$(TARGET_TRIPLE-$(sdk))-ar: + patch/make-xcrun-alias $$@ "--sdk $(sdk) ar" ########################################################################### # SDK: BZip2 @@ -821,12 +832,12 @@ $$(PYTHON_SRCDIR-$(sdk))/configure: \ touch $$(PYTHON_SRCDIR-$(sdk))/configure $$(PYTHON_SRCDIR-$(sdk))/Makefile: \ - alias/$$(TARGET_TRIPLE-$(sdk))-gcc \ - alias/$$(TARGET_TRIPLE-$(sdk))-cpp \ + install/$(os)/bin/$$(TARGET_TRIPLE-$(sdk))-gcc \ + install/$(os)/bin/$$(TARGET_TRIPLE-$(sdk))-cpp \ $$(PYTHON_SRCDIR-$(sdk))/configure # Configure target Python cd $$(PYTHON_SRCDIR-$(sdk)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ ./configure \ CC=$$(TARGET_TRIPLE-$(sdk))-gcc \ CPP=$$(TARGET_TRIPLE-$(sdk))-cpp \ @@ -848,7 +859,7 @@ $$(PYTHON_SRCDIR-$(sdk))/python.exe: \ $$(PYTHON_SRCDIR-$(sdk))/Makefile @echo ">>> Build Python for $(sdk)" cd $$(PYTHON_SRCDIR-$(sdk)) && \ - PATH="$(PROJECT_DIR)/alias:$(PATH)" \ + PATH="$(PROJECT_DIR)/install/$(os)/bin:$(PATH)" \ make all \ 2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log @@ -992,12 +1003,12 @@ clean-BZip2-$(os): install/$(os)/*/bzip2-$(BZIP2_VERSION).*.log \ merge/$(os)/*/bzip2-$(BZIP2_VERSION) \ merge/$(os)/*/bzip2-$(BZIP2_VERSION).*.log \ - wheels/$(os)/bzip2 + wheels/$(os)/bzip2-$(BZIP2_VERSION)-* clean-BZip2-$(os)-wheels: rm -rf \ install/$(os)/*/bzip2-$(BZIP2_VERSION)/wheel \ - wheels/$(os)/bzip2 + wheels/$(os)/bzip2-$(BZIP2_VERSION)-* ########################################################################### # Build: XZ (LZMA) @@ -1015,12 +1026,12 @@ clean-XZ-$(os): install/$(os)/*/xz-$(XZ_VERSION).*.log \ merge/$(os)/*/xz-$(XZ_VERSION) \ merge/$(os)/*/xz-$(XZ_VERSION).*.log \ - wheels/$(os)/xz + wheels/$(os)/xz-$(XZ_VERSION)-* clean-XZ-$(os)-wheels: rm -rf \ install/$(os)/*/xz-$(XZ_VERSION)/wheel \ - wheels/$(os)/xz + wheels/$(os)/xz-$(XZ_VERSION)-* ########################################################################### # Build: OpenSSL @@ -1038,12 +1049,12 @@ clean-OpenSSL-$(os): install/$(os)/*/openssl-$(OPENSSL_VERSION).*.log \ merge/$(os)/*/openssl-$(OPENSSL_VERSION) \ merge/$(os)/*/openssl-$(OPENSSL_VERSION).*.log \ - wheels/$(os)/openssl + wheels/$(os)/openssl-$(OPENSSL_VERSION)-* clean-OpenSSL-$(os)-wheels: rm -rf \ install/$(os)/*/openssl-$(OPENSSL_VERSION)/wheel \ - wheels/$(os)/openssl + wheels/$(os)/openssl-$(OPENSSL_VERSION)-* ########################################################################### # Build: libFFI @@ -1076,12 +1087,12 @@ clean-libFFI-$(os): build/$(os)/libffi-$(LIBFFI_VERSION).*.log \ merge/$(os)/libffi-$(LIBFFI_VERSION) \ merge/$(os)/libffi-$(LIBFFI_VERSION).*.log \ - wheels/$(os)/libffi + wheels/$(os)/libffi-$(LIBFFI_VERSION)-* clean-libFFI-$(os)-wheels: rm -rf \ build/$(os)/libffi-$(LIBFFI_VERSION)/build_*/wheel \ - wheels/$(os)/libffi + wheels/$(os)/libffi-$(LIBFFI_VERSION)-* ########################################################################### # Build: Python @@ -1133,7 +1144,7 @@ endif dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist \ $$(PYTHON_STDLIB-$(os))/VERSIONS \ - $$(foreach target,$$(TARGETS-$(os)), $$(PYTHON_SITECUSTOMIZE-$$(target))) \ + $$(foreach target,$$(TARGETS-$(os)), $$(PYTHON_SITECUSTOMIZE-$$(target))) @echo ">>> Create final distribution artefact for $(os)" mkdir -p dist @@ -1210,7 +1221,7 @@ vars-$(os): $$(foreach target,$$(TARGETS-$(os)),vars-$$(target)) $$(foreach sdk, endef # build -$(BDIST_WHEEL): $(HOST_PYTHON_EXE) +$(BDIST_WHEEL): @echo ">>> Ensure the macOS python install has pip and wheel" $(HOST_PYTHON_EXE) -m ensurepip PIP_REQUIRE_VIRTUALENV=false $(HOST_PYTHON_EXE) -m pip install wheel