feat: cleanup build script
use python 3.10 use curl over wget (pre-installed) ensure enchant is installed cleanup better to limit app bundle size fix Info.plist Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -29,7 +29,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>© 2018–2022, Veronica Berglyd Olsen <code@vkbo.net></string>
|
||||
<string>© 2018–2022, Veronica Berglyd Olsen <code@vkbo.net></string>
|
||||
<key>IFMajorVersion</key>
|
||||
<integer>0</integer>
|
||||
<key>IFMinorVersion</key>
|
||||
|
||||
Regular → Executable
+53
-16
@@ -19,6 +19,8 @@ cleanup () {
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Building in: $BUILD_DIR"
|
||||
|
||||
OLD_CWD="$(pwd)"
|
||||
|
||||
VERSION="$(awk '/^__version__/{print substr($NF,2,length($NF)-2)}' $SCRIPT_DIR/../novelwriter/__init__.py)"
|
||||
@@ -26,39 +28,61 @@ VERSION="$(awk '/^__version__/{print substr($NF,2,length($NF)-2)}' $SCRIPT_DIR/.
|
||||
|
||||
pushd "$BUILD_DIR"/ || exit 1
|
||||
|
||||
echo "Downloading Miniconda ..."
|
||||
# install Miniconda, a self-contained Python distribution
|
||||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
|
||||
curl -LO https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
|
||||
bash Miniconda3-latest-MacOSX-x86_64.sh -b -p ~/miniconda -f
|
||||
rm Miniconda3-latest-MacOSX-x86_64.sh
|
||||
export PATH="$HOME/miniconda/bin:$PATH"
|
||||
|
||||
echo "Creating conda env ..."
|
||||
# create conda env
|
||||
conda create -n novelWriter python --yes
|
||||
conda create -n novelWriter -c conda-forge python=3.10 --yes
|
||||
source activate novelWriter
|
||||
|
||||
echo "installing dictionaries ..."
|
||||
conda install -c conda-forge enchant hunspell-en --yes
|
||||
|
||||
echo "installing python deps ..."
|
||||
# install dependencies
|
||||
pip install -r "$SCRIPT_DIR/../requirements.txt"
|
||||
|
||||
# leave conda env
|
||||
source deactivate
|
||||
conda deactivate
|
||||
|
||||
echo "Building app bundle ..."
|
||||
# create .app Framework
|
||||
mkdir -p novelWriter.app/Contents/
|
||||
mkdir novelWriter.app/Contents/MacOS novelWriter.app/Contents/Resources novelWriter.app/Contents/Resources/novelWriter
|
||||
mv $SCRIPT_DIR/../macos/Info.plist novelWriter.app/Contents/Info.plist
|
||||
cp $SCRIPT_DIR/../macos/Info.plist novelWriter.app/Contents/Info.plist
|
||||
|
||||
echo "Copying miniconda env to bundle ..."
|
||||
# copy Miniconda env
|
||||
cp -R ~/miniconda/envs/novelWriter/* novelWriter.app/Contents/Resources/
|
||||
|
||||
# copy Pext
|
||||
cp -R $SCRIPT_DIR/../* novelWriter.app/Contents/Resources/novelWriter/
|
||||
echo "Copying novelWriter to bundle ..."
|
||||
# copy novelWriter
|
||||
|
||||
FILES_COPY=(
|
||||
"CHANGELOG.md" "MANIFEST.in" "CREDITS.md" "LICENSE.md"
|
||||
"CONTRIBUTING.md" "CODE_OF_CONDUCT.md" "i18n" "novelwriter"
|
||||
"novelWriter.py"
|
||||
)
|
||||
|
||||
for file in "${FILES_COPY[@]}"; do
|
||||
echo "Copying $SCRIPT_DIR/../$file ..."
|
||||
cp -R $SCRIPT_DIR/../$file novelWriter.app/Contents/Resources/novelWriter/
|
||||
done
|
||||
|
||||
cp $SCRIPT_DIR/../macos/novelwriter.icns novelWriter.app/Contents/Resources/
|
||||
#cp -R $SCRIPT_DIR/../* novelWriter.app/Contents/Resources/novelWriter/
|
||||
|
||||
|
||||
# create entry script
|
||||
cat > novelWriter.app/Contents/MacOS/novelWriter <<\EOF
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
$DIR/../Resources/bin/python -sE $DIR/../Resources/novelWriter/novelwriter $@
|
||||
$DIR/../Resources/bin/python -sE $DIR/../Resources/novelWriter/novelWriter.py $@
|
||||
EOF
|
||||
|
||||
# make executable
|
||||
@@ -67,26 +91,39 @@ chmod a+x novelWriter.app/Contents/MacOS/novelWriter
|
||||
# remove bloat
|
||||
pushd novelWriter.app/Contents/Resources || exit 1
|
||||
|
||||
echo "Cleaning unused files from bundle ..."
|
||||
# cleanup commands HERE
|
||||
find . -type d -iname '__pycache__' -print0 | xargs -0 rm -r
|
||||
|
||||
rm -rf pkgs
|
||||
rm -rf cmake
|
||||
rm -rf share/{gtk-,}doc
|
||||
|
||||
rm -rf lib/python3.1/
|
||||
|
||||
#remove web engine
|
||||
rm lib/python3.7/site-packages/PyQt5/QtWebEngine* || true
|
||||
rm -r lib/python3.7/site-packages/PyQt5/Qt/translations/qtwebengine* || true
|
||||
rm lib/python3.7/site-packages/PyQt5/Qt/resources/qtwebengine* || true
|
||||
rm -r lib/python3.7/site-packages/PyQt5/Qt/qml/QtWebEngine* || true
|
||||
rm -r lib/python3.7/site-packages/PyQt5/Qt/plugins/webview/libqtwebview* || true
|
||||
rm lib/python3.7/site-packages/PyQt5/Qt/libexec/QtWebEngineProcess* || true
|
||||
rm lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5WebEngine* || true
|
||||
rm lib/python3.*/site-packages/PyQt5/QtWebEngine* || true
|
||||
rm -r lib/python3.*/site-packages/PyQt5/Qt/translations/qtwebengine* || true
|
||||
rm lib/python3.*/site-packages/PyQt5/Qt/resources/qtwebengine* || true
|
||||
rm -r lib/python3.*/site-packages/PyQt5/Qt/qml/QtWebEngine* || true
|
||||
rm -r lib/python3.*/site-packages/PyQt5/Qt/plugins/webview/libqtwebview* || true
|
||||
rm lib/python3.*/site-packages/PyQt5/Qt/libexec/QtWebEngineProcess* || true
|
||||
rm lib/python3.*/site-packages/PyQt5/Qt/lib/libQt5WebEngine* || true
|
||||
|
||||
popd || exit 1
|
||||
popd || exit 1
|
||||
|
||||
|
||||
echo "Packageing App"
|
||||
# generate .dmg
|
||||
|
||||
brew install create-dmg
|
||||
# "--skip-jenkins" is a temporary workaround for https://github.com/create-dmg/create-dmg/issues/72
|
||||
create-dmg --skip-jenkins --volname "novelWriter $VERSION" --volicon $SCRIPT_DIR/../macos/novelwriter.icns \
|
||||
create-dmg --volname "novelWriter $VERSION" --volicon $SCRIPT_DIR/../macos/novelwriter.icns \
|
||||
--window-pos 200 120 --window-size 800 400 --icon-size 100 --icon novelWriter.app 200 190 --hide-extension novelWriter.app \
|
||||
--app-drop-link 600 185 novelWriter-"${VERSION}".dmg "$BUILD_DIR"/
|
||||
|
||||
pushd $BUILD_DIR || exit 1
|
||||
zip -qr novelWriter.app.zip novelWriter.app
|
||||
popd || exit 1
|
||||
|
||||
mv $BUILD_DIR/novelWriter.app.zip novelWriter.app.zip
|
||||
Reference in New Issue
Block a user