Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appimage Distribution #1091

Closed
Ryex opened this issue Jul 8, 2022 · 3 comments · Fixed by #1092
Closed

Appimage Distribution #1091

Ryex opened this issue Jul 8, 2022 · 3 comments · Fixed by #1092
Assignees
Labels
enhancement Request: New feature or improvement

Comments

@Ryex
Copy link
Contributor

Ryex commented Jul 8, 2022

Proposal

I think it would be great if novelWriter was able to be downloaded as an Appimage.

Appimages are a self contained runtime much like how OSX applications are distributed but for Linux that is Distro agnostic. With an Appimage you simply download a single exactable file and run it. A filesystem is transparently mounted in the background allowing the program to run with all of it's dependencies contained.

Thanks to the tools around Appimage the only real hard part is getting a python build build that is easily portable.

Good thing the hard work has already been done for us with python-appimage

https://python-appimage.readthedocs.io/en/latest/apps/#simple-packaging

Initial Testing

I made a simple directory appimage/novelwriter under the project, copied the relevant files into it and made some small edits to them, provided the absolute path to the source via a requirements.txt, and ran the command

~/Projects/novelWriter/appimage $ python-appimage build app -p 3.11 novelwriter  
[2022-07-07 17:02:31,604] EXTRACT  python3.11.0-cp311-cp311-manylinux2010_x86_64.AppImage
[2022-07-07 17:02:34,551] BUNDLE   novelwriter.desktop
[2022-07-07 17:02:34,552] BUNDLE   novelwriter.png
[2022-07-07 17:02:36,504] BUNDLE   ~/Projects/novelWriter/
[2022-07-07 17:02:42,183] BUNDLE   entrypoint.sh
[2022-07-07 17:02:42,183] BUILD    AppDir

and out popped a working novelWriter-x86_64.AppImage running with python 3.11 that integrated with my Gnome desktop correctly via AppImageLauncher

from this It should not be difficult to automate the creation of the metadata folder and subsequent building for an Appimage

File Contents

appimage/novelwriter/entrypoint.sh

{{ python-executable }} -sE ${APPDIR}/opt/python{{ python-version }}/bin/novelwriter "$@"

novelwriter.appdata.xml

<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
    <id>novelWriter</id>
    <metadata_license>GNU General Public License v3</metadata_license>
    <project_license>GNU General Public License v3</project_license>
    <name>novelWriter</name>
    <summary>A markdown-like text editor designed for writing novels and larger projects of many smaller plain text documents.</summary>
    <description>
        <p> novelWriter is a plain text editor designed for writing novels assembled from
            many smaller text documents. It uses a minimal formatting syntax inspired by
            Markdown, and adds a meta data syntax for comments, synopsis, and
            cross-referencing. It's designed to be a simple text editor that allows for
            easy organisation of text and notes, using human readable text files as
            storage for robustness.
        </p>
    </description>
    <launchable type="desktop-id">novelWriter.desktop</launchable>
    <url type="homepage">https://novelwriter.io/</url>
    <provides>
        <binary>novelWriter</binary>
    </provides>
</component>

novelwriter.desktop

[Desktop Entry]
Type=Application
Name=novelWriter
Comment=A markdown-like text editor for planning and writing novels
Exec=novelwriter %f
Icon=novelwriter
Categories=Qt;Office;WordProcessor;
Terminal=false
MimeType=application/x-novelwriter-project;

requirements.txt

~/Projects/novelWriter/

novelwriter.png

copied from setup/novelwriter.png

@Ryex Ryex added the enhancement Request: New feature or improvement label Jul 8, 2022
@vkbo
Copy link
Owner

vkbo commented Jul 8, 2022

It would be fantastic to get this working. I simply don't have the time to make the installers for all OSes that novelWriter can run on. Thanks for doing the research.

The correct way to automate this for novelWriter is to add a function in setup.py that does all the work, and add a build-appimage command to the main function. Any files that need to be created and maintained can be put in the setup folder. The function should create the necessary build folder, copy or generate the needed files, and run the appimage build. Would you have time to implement this and make a pull request?

@vkbo vkbo added this to the Release 1.7 RC 1 milestone Jul 8, 2022
@Ryex Ryex mentioned this issue Jul 8, 2022
6 tasks
@Ryex
Copy link
Contributor Author

Ryex commented Jul 9, 2022

I've made a pull request with the added functionality.

I also made it so that the build-appimage command can configure the python build it uses in the resulting app-image
it defaults to python 3.10 and manylinux2010_x86_64 (which should be a same default as building a wheel) for the broadest compatibility. But it is trivial to let it build with any other version.

$ python setup.py build-appimage -h

Build Appimage
==============

usage: build_appimage [-h] [--linux-tag [LINUX_TAG]] [--python-version [PYTHON_VERSION]]

Build an Appimage

options:
  -h, --help            show this help message and exit
  --linux-tag [LINUX_TAG]
                        linux compatibility tag (e.g. manylinux1_x86_64) see https://python-appimage.readthedocs.io/en/latest/#available-python-appimages and
                        https://github.com/pypa/manylinux for a list of valid tags
  --python-version [PYTHON_VERSION]
                        python version (e.g. 3.10)

see https://appimage.org/ for more details

Just finished cleaning up the code a bit and double checking for anything I overlooked

@vkbo vkbo assigned Ryex Jul 9, 2022
@vkbo
Copy link
Owner

vkbo commented Jul 9, 2022

Thanks a lot! I'm in the middle of moving, so I'll look at it as soon as I have a chance.

@vkbo vkbo linked a pull request Jul 9, 2022 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Request: New feature or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants