Skip to content

Commit

Permalink
Add a non-executable stub binary for crossenv detection purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Nov 22, 2023
1 parent fd7051e commit 6d6abb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions patch/Python/Python.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 @@
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6d6abb0

Please sign in to comment.