2018-04-14 13:21:35 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-07-26 18:53:32 +00:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
if ! [[ $# -eq 2 ]]; then
|
|
|
|
echo "Usage: $0 [appdir] [pyside_major]"
|
2018-04-14 13:21:35 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-02-28 13:56:54 +00:00
|
|
|
python_prefix=$(pkg-config --variable=prefix python3)
|
2024-07-26 18:53:32 +00:00
|
|
|
|
|
|
|
python_version=`$python_prefix/bin/python3 --version`
|
|
|
|
python_version=${python_version##* }
|
|
|
|
python_version=python${python_version%.*}
|
|
|
|
|
|
|
|
pyside_major=$2
|
2019-02-28 13:56:54 +00:00
|
|
|
appdir=$1
|
2018-04-14 13:21:35 +00:00
|
|
|
|
|
|
|
echo "Embedding Python from prefix $python_prefix in appdir $appdir"
|
|
|
|
|
2019-02-28 13:56:54 +00:00
|
|
|
mkdir -p "$appdir/usr"
|
2018-04-14 13:21:35 +00:00
|
|
|
cd "$appdir/usr/" || exit 1
|
|
|
|
|
2019-02-28 13:56:54 +00:00
|
|
|
cp -RT "$python_prefix" "." || exit 1
|
2018-04-14 13:21:35 +00:00
|
|
|
echo "Cleaning up embedded Python"
|
|
|
|
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
|
2019-02-28 13:56:54 +00:00
|
|
|
rm -r lib/$python_version/test lib/$python_version/idlelib lib/$python_version/curses lib/$python_version/lib2to3
|
|
|
|
|
2024-07-26 18:53:32 +00:00
|
|
|
echo "Checking if PySide is available"
|
2019-02-28 13:56:54 +00:00
|
|
|
|
2024-07-26 18:53:32 +00:00
|
|
|
pyside_prefix=$(pkg-config --variable=prefix pyside$pyside_major)
|
2019-02-28 13:56:54 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
2024-07-26 18:53:32 +00:00
|
|
|
echo "PySide is not available, ignoring."
|
2019-02-28 13:56:54 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "PySide is at $pyside_prefix"
|
|
|
|
|
|
|
|
if [ "$pyside_prefix" == "$python_prefix" ]; then
|
|
|
|
echo "Prefixes are equal, not copying anything from lib"
|
|
|
|
else
|
|
|
|
cp -RT "$pyside_prefix/lib/$python_version" "lib/$python_version" || exit 1
|
|
|
|
fi
|