Skip to content

Commit

Permalink
Merge pull request #99 from morevnaproject-org/appimage
Browse files Browse the repository at this point in the history
Script for generating Linux AppImage package
  • Loading branch information
steveway committed Aug 1, 2021
2 parents bf4caf5 + faaaced commit d9c7daa
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -5,7 +5,8 @@ ffmpeg.exe
.idea/

venv/
/build/
/build/linux-appimage/build
/build/linux-appimage/*.AppImage
/dist/
/.github/
/output/
60 changes: 60 additions & 0 deletions build/linux-appimage/build.sh
@@ -0,0 +1,60 @@
#!/bin/sh

# https://github.com/AppImage/AppImageKit/wiki/Bundling-Python-apps

SCRIPTPATH=$(cd `dirname "$0"`; pwd)
SOURCES_DIR="${SCRIPTPATH}/../../"

#PYTHON_APPIMAGE_URL="https://github.com/niess/python-appimage/releases/download/python3.10/python3.10.0-cp310-cp310-manylinux2010_x86_64.AppImage"
PYTHON_APPIMAGE_URL="https://github.com/niess/python-appimage/releases/download/python3.7/python3.7.11-cp37-cp37m-manylinux2010_x86_64.AppImage"
PYTHON_APPIMAGE_FILENAME=`basename "${PYTHON_APPIMAGE_URL}"`

# Detect package management system.
YUM=$(which yum 2>/dev/null)
APT_GET=$(which apt-get 2>/dev/null)

echo "Installing required build tools."
# libffi is required by cffi python package, which in turn is required by sounddevice
if [[ ! -z $YUM ]]; then
sudo yum install -y gcc libffi-devel
elif [[ ! -z $APT_GET ]]; then
sudo apt-get install -y build-essential libffi-dev
fi


[ -d "${SCRIPTPATH}/build" ] || mkdir -p "${SCRIPTPATH}/build"
cd "${SCRIPTPATH}/build"
wget "${PYTHON_APPIMAGE_URL}"
chmod +x "${PYTHON_APPIMAGE_FILENAME}"
"./${PYTHON_APPIMAGE_FILENAME}" --appimage-extract

#export PATH="$(pwd)/squashfs-root/usr/bin:$PATH"
./squashfs-root/AppRun -m pip install torch==1.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
./squashfs-root/AppRun -m pip install -r "${SOURCES_DIR}requirements.txt"
#./squashfs-root/AppRun -m pip install $(grep -ivE "allosaurus" "${SOURCES_DIR}requirements.txt")


#find "${SOURCES_DIR}" -type f -not -iname '*/not-from-here/*' -exec cp -rf '{}' '/dest/{}' ';'
rsync -av --progress "${SOURCES_DIR}" "squashfs-root/opt/papagayo-ng" --exclude build

cp "${SCRIPTPATH}/files/papagayo-ng" squashfs-root/usr/bin/
rm squashfs-root/usr/share/applications/*.desktop
rm squashfs-root/*.desktop
cp "${SCRIPTPATH}/files/papagayo-ng.desktop" squashfs-root/usr/share/applications/
cp "${SCRIPTPATH}/files/papagayo-ng.desktop" squashfs-root/
cp "${SOURCES_DIR}/rsrc/papagayo-ng.png" squashfs-root/
rm squashfs-root/usr/share/metainfo/*

# Change AppRun so that it launches papagayo-ng
sed -i -e 's|/opt/python3.7/bin/python3.7|/usr/bin/papagayo-ng|g' ./squashfs-root/AppRun

# Convert back into an AppImage
wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-*.AppImage
#
# The following line does not work quite yet due to https://github.com/probonopd/go-appimage/issues/30
# ./appimagetool-*-x86_64.AppImage deploy squashfs-root/usr/share/applications/taguette.desktop
./appimagetool-*-x86_64.AppImage squashfs-root/ # Replace "1" with the actual version/build number
mv Papagayo_NG-*-x86_64.AppImage ../
cd ..
rm -rf build
5 changes: 5 additions & 0 deletions build/linux-appimage/files/papagayo-ng
@@ -0,0 +1,5 @@
#!/bin/bash

SCRIPT_DIR=$(cd `dirname "$0"`; pwd)
cd "$SCRIPT_DIR/../../opt/papagayo-ng"
"$SCRIPT_DIR/python" ./papagayo-ng.py "$@"
13 changes: 13 additions & 0 deletions build/linux-appimage/files/papagayo-ng.desktop
@@ -0,0 +1,13 @@
[Desktop Entry]
Encoding=UTF-8
Name=Papagayo NG
Comment=Lipsync tool
Exec=papagayo-ng
Icon=papagayo-ng
Terminal=false
Type=Application
Categories=Graphics;Application;
MimeType=application/x-papagayo;application/x-extension-pgo;
X-Desktop-File-Install-Version=0.15
X-AppImage-Version=bf4caf5

3 changes: 2 additions & 1 deletion requirements.txt
Expand Up @@ -6,4 +6,5 @@ anytree
PySide2
audioread
allosaurus >= 1.0.1
appdirs
appdirs
pyyaml
2 changes: 0 additions & 2 deletions setup_ubuntu.sh

This file was deleted.

0 comments on commit d9c7daa

Please sign in to comment.