From 6d6abb0395226caba883ac9601f5fd445f2698b7 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Wed, 22 Nov 2023 12:51:22 +0800 Subject: [PATCH] Add a non-executable stub binary for crossenv detection purposes. --- Makefile | 13 +++++++++---- patch/Python/Python.patch | 8 ++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 58c87c4..aa4d33c 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,7 @@ PYTHON_MICRO_VERSION=$(shell echo $(PYTHON_VERSION) | grep -Eo "\d+\.\d+\.\d+") PYTHON_VER=$(basename $(PYTHON_VERSION)) # The binary releases of dependencies, published at: -# macOS: -# https://github.com/beeware/cpython-macOS-source-deps/releases -# iOS, tvOS, watchOS: -# https://github.com/beeware/cpython-apple-source-deps/releases +# https://github.com/beeware/cpython-apple-source-deps/releases BZIP2_VERSION=1.0.8-1 XZ_VERSION=5.4.4-1 OPENSSL_VERSION=3.0.12-1 @@ -417,13 +414,21 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk)) @echo ">>> Build Python fat headers for the $(sdk) SDK" # Copy binary helpers from the first target in the $(sdk) SDK cp -r $$(PYTHON_BIN-$$(firstword $$(SDK_TARGETS-$(sdk)))) $$(PYTHON_BIN-$(sdk)) + + # Create a non-executable stub binary python3 + echo "#!/bin/bash\necho Can\\'t run $(sdk) binary\nexit 1" > $$(PYTHON_BIN-$(sdk))/python$(PYTHON_VER) + chmod 755 $$(PYTHON_BIN-$(sdk))/python$(PYTHON_VER) + # Copy headers as-is from the first target in the $(sdk) SDK cp -r $$(PYTHON_INCLUDE-$$(firstword $$(SDK_TARGETS-$(sdk)))) $$(PYTHON_INCLUDE-$(sdk)) + # Link the PYTHONHOME version of the headers mkdir -p $$(PYTHON_INSTALL-$(sdk))/include ln -si ../Python.framework/Headers $$(PYTHON_INSTALL-$(sdk))/include/python$(PYTHON_VER) + # Add the individual headers from each target in an arch-specific name $$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_INCLUDE-$$(target))/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig-$$(ARCH-$$(target)).h; ) + # Copy the cross-target header from the patch folder cp $(PROJECT_DIR)/patch/Python/pyconfig-$(os).h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h diff --git a/patch/Python/Python.patch b/patch/Python/Python.patch index cd30184..bf95e9e 100644 --- a/patch/Python/Python.patch +++ b/patch/Python/Python.patch @@ -1842,7 +1842,7 @@ index d74fb6deac..09ebc4287c 100755 # Blank kernel with real OS is always fine. ;; diff --git a/configure b/configure -index c87f518382..45f021d1b1 100755 +index c87f518382..ad0cd39350 100755 --- a/configure +++ b/configure @@ -963,10 +963,13 @@ @@ -2121,7 +2121,7 @@ index c87f518382..45f021d1b1 100755 + esac + + prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION -+ PYTHONFRAMEWORKINSTALLNAMEPREFIX=$(prefix) ++ PYTHONFRAMEWORKINSTALLNAMEPREFIX=${prefix} + RESSRCDIR=Mac/Resources/framework + + # Add files for Mac specific code to the list of output @@ -2606,7 +2606,7 @@ index c87f518382..45f021d1b1 100755 "Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;; "Misc/python-embed.pc") CONFIG_FILES="$CONFIG_FILES Misc/python-embed.pc" ;; diff --git a/configure.ac b/configure.ac -index cd69f0ede5..a96ca3a3c7 100644 +index cd69f0ede5..9306e1270b 100644 --- a/configure.ac +++ b/configure.ac @@ -310,6 +310,83 @@ @@ -2847,7 +2847,7 @@ index cd69f0ede5..a96ca3a3c7 100644 + esac + + prefix=$PYTHONFRAMEWORKINSTALLDIR/Versions/$VERSION -+ PYTHONFRAMEWORKINSTALLNAMEPREFIX=$(prefix) ++ PYTHONFRAMEWORKINSTALLNAMEPREFIX=${prefix} + RESSRCDIR=Mac/Resources/framework + + # Add files for Mac specific code to the list of output