Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,15 @@ NOTES:

- As of this commit: https://github.com/gregneagle/relocatable-python/commit/903c708a01d1a2444ea5648114f3acf6e7f94fd7, instead of removing the signature, we replace it with an ad-hoc signature. This is required for the code to actually run on Apple silicon.


UNIVERSAL PYTHON

As of Python 3.9.11 (Mar 16, 2022), Python.org offers a Universal Python build. If you want to test if your framework is also fully universal, you can use the included "python_universal_tester.sh" script. It takes your version of Python as an argument:
```
% ./python_universal_tester.sh 3.10
Using Python 3.10
All files are universal!
% echo $?
0
```

The script must be run from the same directory as the built Python.framework. If any files are not universal, it will list them and exit 1.
35 changes: 35 additions & 0 deletions python_universal_tester.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

if [[ $1 == *"3."* ]]; then
echo "Using Python $1"
else
echo "Invalid Python version"
exit 1
fi

STATUS=0

# ensure all .so and .dylibs are universal
LIB_COUNT=$(find "Python.framework" -name "*.so" -or -name "*.dylib" | wc -l)
UNIVERSAL_COUNT=$(find "Python.framework" -name "*.so" -or -name "*.dylib" | xargs file | grep "2 architectures" | wc -l)
if [ "$LIB_COUNT" != "$UNIVERSAL_COUNT" ] ; then
echo "$LIB_COUNT libraries (*.so and *.dylib) found in the framework; only $UNIVERSAL_COUNT are universal!"
echo "The following libraries are not universal:"
find Python.framework -name "*.so" -or -name "*.dylib" | xargs file | grep -v "2 architectures" | grep -v "(for architecture"
STATUS=1
fi

# test some more files in the framework
MORE_FILES="Python.framework/Versions/$1/Resources/Python.app/Contents/MacOS/Python
Python.framework/Versions/Current/Python
Python.framework/Versions/Current/bin/python$1"

for TESTFILE in $MORE_FILES ; do
ARCH_TEST=$(file "$TESTFILE" | grep "2 architectures")
if [ "$ARCH_TEST" == "" ] ; then
echo "$TESTFILE is not universal!"
STATUS=1
fi
done

[[ $STATUS == 0 ]] && echo "All files are universal!" || exit $STATUS