-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyqt6-universal-patch.sh
executable file
·37 lines (26 loc) · 1.1 KB
/
pyqt6-universal-patch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# functions
trash() { osascript -e "tell application \"Finder\" to delete POSIX file \"$(realpath "$1")\"" > /dev/null; }
echo "PyQt Universal 2 Binary Patch Utility"
if [[ "$(sysctl -n machdep.cpu.brand_string)" != *"Apple"* ]]; then
echo "This script must be run on an Apple Silicon Mac. Nothing to do."
echo "PyQt Universal 2 Binary Patch Utility complete."
exit
fi
echo "Current Directory: $(pwd)"
echo "Activating virtual environment..."
source ./venv/bin/activate
SITE_PACKAGE=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
echo "Site Package: $SITE_PACKAGE"
echo "Patching PyQt6..."
# make a backup, preserve permissions
cp -R $SITE_PACKAGE/PyQt6 $SITE_PACKAGE/PyQt6.bak
# reinstall PyQt6 as arm64
arch -arm64 pip install PyQt6 --force-reinstall
# Patch
cd $SITE_PACKAGE
echo "Converting to Universal Binary..."
find ./PyQt6/Qt6 -type f -perm +111 -exec sh -c 'xcrun lipo -create -output "{}" "{}" "$(echo "{}" | sed "s|^./PyQt6/|./PyQt6.bak/|")"' \;
echo "Patching complete."
deactivate
echo "PyQt Universal 2 Binary Patch Utility complete."