Linux

Since Linux users will likely be familiar with command-line tools and most distributions will come with Python and pip installed already. Using pip is the recommended method for distributing your Python applications.

If you do not wish to use pip, there are many alternatives available, depending on the particular distribution the user is running.

For steps to create an AppImage binary, check out the official AppImages GitHub repository. There's a sample Python application available here: https://github.com/AppImage/AppImages/blob/master/legacy/pythongtk3hello/Recipe.

This sample contains the shell commands which need to be run in order to package your application as an AppImage. Before following the instructions, you will need a thumbnail image for you application (tkedit.png in our case) and a .desktop file to run it.

Here is an example .desktop file for our editor (tkedit.desktop):

[Desktop Entry]
Name=tkedit
Exec=tkedit
Icon=tkedit.png
Comment=A text editor with python syntax highlighting

You will need to create the icon, tkedit.png, yourself.

With these two files ready, you can then begin the process of creating an AppImage for your editor.

  1. Download and source the helper functions from the AppImages repository:
      $ wget -q https://github.com/AppImage/AppImages/raw/master/functions      .sh -O ./functions.sh
$ source ./functions.sh
  1. Export variables which will be used throughout the script:
      $ export APP=TKEDIT
$ export LOWERAPP=tkedit
  1. Create the directory at which we will place our AppImage:
      $ mkdir -p $APP/$APP.AppDir/
$ cd $APP/$APP.AppDir
  1. Create a virtual environment named usr inside this folder:
      $ python3 -m venv usr
$ source usr/bin/activate
  1. Install our external dependency in this virtual environment:
      $ pip install PyYAML
  1. Copy your python modules into the bin directory of the virtual environment (ensure you have the tkedit.py file from the Windows section earlier):
      $ cp *.py usr/bin/
  1. Remove the file extension from tkedit.py and mark it as executable:
      $ mv usr/bin/tkedit.py usr/bin/tkedit
$ chmod +x usr/bin/tkedit
  1. Now, we can begin using the helper script functions to start doing the heavy lifting for us:
      $ get_apprun
$ get_desktopintegration tkedit
  1. You will be asked if you want to add the desktop entry to your system. This is up to you:
      $ copy_deps; copy_deps; copy_deps;
$ delete_blacklisted
$ move_lib
  1. You application will now need a version number, set as an environment variable:
      $ export VERSION=1
  1. We are now ready to package. A file named AppRun will have been created in your current directory. Run this file to test that the AppImage will work when executed:
      $ ./AppRun
  1. If all looks good, we are ready to package the AppImage:
      $ cd ..
$ generate_appimage
  1. After this command runs, you should have a new folder called out. Inside here should be a binary file called something like TKEDIT-01.glibc2.3.4-x86_64.AppImage. This is your binary file and can be run as follows:
      ./TKEDIT-01.glibc2.3.4-x86_64.AppImage
  1. If your AppImage was created successfully, you can now give this file to other people so that they can run your editor!
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset