Created
October 1, 2021 18:47
-
-
Save mchapman87501/e9823325ac83287d9ee3ee9175f1cfe3 to your computer and use it in GitHub Desktop.
Install PySide6 on macOS (Monterey) for M1 (Apple Silicon) Devices - h/t elliewhatever
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Many thanks to | |
# https://gist.githubusercontent.com/elliewhatever/adbe3fba37d747fb8b04af8f835d46d2/raw/61e2bd530eb434f7ea2f595262e1922cdd057f7c/PySide6.sh | |
# Assumes brew and python are installed | |
brew install qt@6 llvm cmake ninja git | |
# Setup environment relative to current directory - | |
# this eases building in an existing Python venv. | |
mkdir -p ./.pyside6; cd ./.pyside6 | |
BUILD_DIR=${PWD} | |
git clone --recursive https://code.qt.io/pyside/pyside-setup | |
# Change to match your Qt version: | |
QT_VER=6.1.3 | |
cd pyside-setup && git checkout ${QT_VER} | |
python -m venv testenv | |
source testenv/bin/activate | |
pip install -r requirements.txt | |
# Build PySide6 in environment | |
export CLANG_INSTALL_DIR=$(brew --prefix)/opt/llvm | |
CELLAR=${HOME}/homebrew/Cellar | |
# I'm not sure why this is necessary in my environment: | |
export QT_PLUGIN_PATH=${CELLAR}/qt/${QT_VER}/share/qt/plugins | |
python setup.py build --qmake=${CELLAR}/qt/${QT_VER}/bin/qmake --build-tests --ignore-git --parallel=8 | |
python setup.py install --qmake=${CELLAR}/qt/${QT_VER}/bin/qmake --build-tests --ignore-git --parallel=8 --reuse-build | |
# Function to copy PySide6 to new environment | |
# Note the case-sensitive .../site-packages/PySide6* -- your filesystem may vary. | |
echo 'function copy-pyside { | |
export PYSIDE=${BUILD_DIR}/pyside-setup/testenv | |
export VENV=$1 | |
rsync -av $PYSIDE/bin/shiboken6* $VENV/bin; rsync -av $PYSIDE/lib/python3.9/site-packages/shiboken6* $VENV/lib/python3.9/site-packages/ | |
rsync -av $PYSIDE/bin/pyside6-* $VENV/bin; rsync -av $PYSIDE/lib/python3.9/site-packages/PySide6* $VENV/lib/python3.9/site-packages/ | |
echo You may also need to: | |
echo export QT_PLUGIN_PATH=${CELLAR}/qt/${QT_VER}/share/qt/plugins | |
}' >> ~/.zshrc | |
# Manually copy packages to required environment (works for conda) | |
# export PYSIDE=~/.pyside6/testenv/ | |
# export VENV=PATH_TO_PROJECT/venv | |
# rsync -av $PYSIDE/bin/shiboken6* $VENV/bin | |
# rsync -av $PYSIDE/bin/pyside6-* .$VENV/bin | |
# rsync -av $PYSIDE/lib/python3.9/site-packages/PySide6* $VENV/lib/python3.9/site-packages/ | |
# rsync -av $PYSIDE/lib/python3.9/site-packages/shiboken6* $VENV/lib/python3.9/site-packages |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You could also build a *.whl after you built pyside:
and install it to your venv:
pip
poetry
Your PySide, Python and macOS version may differ in the
*.whl
outputs listed above.