Packaging apps Packaging apps is useful for running apps on multiple machines without worrying about versions. Here is a short guide on packaging Python apps, in 20 steps. It first involves "freezing" it using PyInstaller, then bundling it into an AppImage using AppImageKit's [appimagetool](https://github.com/AppImage/AppImageKit#appimagetool-usage). ----- 1. Enter your app's source directory, all following operations occur from this directory. Create a Conda environment with `conda create --name myapp` 2. Install the necessary dependencies for your app to work 3. Install PyInstaller with `conda install pyinstaller` 4. Set up variables `APP=APPNAMEHERE; LOWERAPP=${APP,,}` replacing APPNAMEHERE with your app name, like SCRIPT 4. Backup your entry point script and name it LOWERAPP.py, like script.py 4. Set up the app for freezing using `pyinstaller script.py` 5. This creates `script.spec`, a `build` folder, and a `dist` folder 6. Run `pyinstaller script.spec` to create the Unix executable. The `script.spec` file customizes the freezing process 7. `cd dist/script` to find the resultant files, locate the executable, and test it works using `./script` * It may fail if external data files were needed * If there were data files, it should have been specified in `script.spec` * Otherwise, you can also just copy necessary data files into the dist folder, `cp -R * dist/script` 8. When it works, `cd ..` 9. Helper functions can be obtained and sourced by ```bash wget -q https://github.com/probonopd/AppImages/raw/master/functions.sh -O ./functions.sh source ./functions.sh ``` 10. Create the AppDir using `mkdir -p $APP/$APP.AppDir/usr/bin/`, the specification of AppDir is [here](https://docs.appimage.org/reference/appdir.html) 11. Enter the AppDir with `cd $APP/$APP.AppDir`, all following operations occur from this directory 11. Copy the contents of step 9 into usr/bin, `cp -Rv appsource/dist/script/* usr/bin/` #!. untested 12. Make sure it is executable, `chmod a+x usr/bin/$LOWERAPP` 13. Get the AppRun file, `get_apprun` 14. In the AppDir, create a desktop entry file `vim $LOWERAPP.desktop` with the format: ``` [Desktop Entry] Name=Lector Comment=Read e-books Type=Application Terminal=false Exec=lectormain Icon=lectormain Categories=Utility;Qt;Graphics;Viewer; ``` 15. Obtain 128x128 or 256x256 PNG icon, and save it as `.DirIcon` and `$LOWERAPP.png` (both are needed), in the desktop entry, the Icon= field should have $LOWERAPP but without the extension 16. Bundle dependencies using `copy_deps; copy_deps; copy_deps` and then `delete_blacklisted; move_lib` 17. Check the app is runnable using `./AppRun` 18. When it works, `cd ..`, all following operations will occur from this directory 19. Obtain the appimage tool and mark it as executable ``` wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage" chmod a+x appimagetool-x86_64.AppImage ``` 20. With the AppDir in place, you can run `./appimagetool-x86_64.AppImage APPNAMEHERE.AppDir/` tags: code