vkbo / novelWriter

novelWriter is an open source plain text editor designed for writing novels. It supports a minimal markdown-like syntax for formatting text. It is written with Python 3 (3.9+) and Qt 5 (5.15) for cross-platform support.
https://novelwriter.io
GNU General Public License v3.0
1.99k stars 102 forks source link

Installers and Packaging #481

Closed vkbo closed 6 months ago

vkbo commented 3 years ago

Updated on 22 August 2022

I've spent quite some time writing and rewriting the setup.py script to make it easier to install and run novelWriter.

novelWriter is released to pip, and can be installed from there on all platforms supported by pip and Python.

Windows

The setup.py script can create a single file executable installer for Windows, with dependencies and Python embedded. The installer is unsigned though, which raises a warning. I'm looking for an inexpensive way to sign the packages like I can for Ubuntu. A minimal package release is also available with some simple batch scripts for install/uninstall.

Linux

For Ubuntu, Debian and Mint, the debian packages can be installed directly or via Launchpad. AppImages are available from release 1.7. RPM-package releases are needed, see #907. A minimal package release is also available for manual install. Direct local setup from setup.py is also possible.

macOS

I know too little about macs to attempt anything related to packaging of novelWriter for macOS. Some assistance would be appreciated here. See the help wanted task #867.

jyhelle commented 3 years ago

tested on Manjaro Linux, all went OK (except the "launcher" option which is in fact "xdg-install")

vkbo commented 3 years ago

Thanks for testing.

Yes, I rewrote the launcher installer and used the proper xdg tools, so it made sense to rename it. The README is updated, but the text here is out of date. I'll update it.

singlebunglemrbungle commented 3 years ago

When I run install.bat in Windows, I run into an error message like this:

UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 40: illegal multibyte sequence

Expected Action:

What happened: I guess successful running of setup.py results in creating novelWritng.exe, but it does not. And there is no desktop shortcut.

Fortunately, the program itself can be executed by running novelWriter.pyw nonetheless.

Source of the problem: My windows locale is set to Korea, I guess unspecified encoding making the error.


Here's more latter part of the log from install.bat.

Windows Install
===============

C:\app\novelWriter>windows_install.bat

Looking for Python
Python 3.9.5
Python found. OK.
setup.py found. OK.

Requirement already satisfied: pywin32 in c:\users\gone\appdata\roaming\python\python39\site-packages (300)
Requirement already satisfied: pyqt5>=5.2.1 in c:\users\gone\appdata\roaming\python\python39\site-packages (from -r requirements.txt (line 1)) (5.15.4)
Requirement already satisfied: lxml>=4.2.0 in c:\users\gone\appdata\roaming\python\python39\site-packages (from -r requirements.txt (line 2)) (4.6.3)
Requirement already satisfied: pyenchant>=3.0.0 in c:\users\gone\appdata\roaming\python\python39\site-packages (from -r requirements.txt (line 3)) (3.2.0)
Requirement already satisfied: PyQt5-Qt5>=5.15 in c:\users\gone\appdata\roaming\python\python39\site-packages (from pyqt5>=5.2.1->-r requirements.txt (line 1)) (5.15.2)
Requirement already satisfied: PyQt5-sip<13,>=12.8 in c:\users\gone\appdata\roaming\python\python39\site-packages (from pyqt5>=5.2.1->-r requirements.txt (line 1)) (12.9.0)

Windows Install
===============

Traceback (most recent call last):
  File "C:\app\novelWriter\setup.py", line 1236, in <module>
    winInstall()
  File "C:\app\novelWriter\setup.py", line 842, in winInstall
    numVers, hexVers = extractVersion()
  File "C:\app\novelWriter\setup.py", line 54, in extractVersion
    for aLine in inFile:
UnicodeDecodeError: 'cp949' codec can't decode byte 0xe2 in position 40: illegal multibyte sequence
Press any key to continue . . .

C:\app\novelWriter>

And here is a screenshot from the directory. image

vkbo commented 3 years ago

Hi @singlebunglemrbungle, I moved your report to a separate issue thread on #805. Please see my response there. Thanks!

ak-42 commented 2 years ago

@vkbo Hi. Have you considered packaging novelWriter using one of the Linux distro-agnostic methods, such as Flatpak (via Flathub) or AppImage?

While the minimal package works fine for me, I am hesitant to rely on a program which does not receive automated updates, which seems like a return to Windows-like dark age of application updates. I understand it is likely unfeasible for you to package the program for all the various distros, and since Flatpaks and AppImages run on virtually all modern distros, this increase the reach of novelWriter and reduce troubleshooting and dependency issues (since all dependencies are generally included into Flatpaks).

vkbo commented 2 years ago

Hi!

AppImage has already been added in #1092 thanks to @Ryex, and will be available from release 1.7 RC 1, which will arrive soon. I did not backport it to the recent 1.6.3 release. I'm not sure how auto-updates are done in AppImage though. I tend to avoid those sort of distributions myself.

For Debian/Ubuntu, it is on Launchpad, and I've been tinkering with rpm-packages from time to time. Eventually I will get it done too. For Mac, I still need help since I have no access to a Mac of any kind, and for Windows I have added back the setup.exe installer without using any of the packaging tools which tend to send low-end virus software panicking.

I should update the main post here to reflect these changes.

ak-42 commented 2 years ago

That's good to hear. AppImages can self-update without a centralised repository, the relevant documentation is here.

johnblommers commented 2 years ago

IMHO it's preferred to allow the user to download updated AppImage files. This way they can have multiple versions of an application concurrently on the system.

In general I'm leery of automatic application updates because if it goes wrong the user has to figure out how to fix the mess.

I am in favor of applications checking for an update and offer to download it. But the user has to decide to switch to it and delete the old version.

ak-42 commented 2 years ago

@johnblommers If you open the link I provided above, all of those points are addressed by the 'Recommended user experience' section.

Ryex commented 2 years ago

@ak-42 I tried to come up with a comfortable way to add update information when I made my PR but there is a distinct lack of clarity when it comes to the documentation. there is also some complication in obtaining a python build that is portable enough to work in an Appimage. The current method used in the setup.py uses python-appimage which does not support generating the zsync update information. Normally I would have then gone upstream to make a PR for that and then come back, but the docs provide so little information that I couldn't see how to do it.

in theory it's as simple as lettings us pass through an -u with "zsync|https://github.com/vkbo/novelWriter/releases/latest/download/novelwriter.Appimage" to appimagetool but internally python-appimage takes some shortcuts that makes me dubious

EDIT: on further research it seems that there may be an issue using python-appimage because the pyqt5 clib deps do not get included in the Appimage?. It seems like an unlikely case that someone won't have most of then on their system already but if it's true then it will need more work...

It seems the likely solution will be to use linuxdeploy with it's conda plugin... It makes things much messier though.

EDIT 2: https://github.com/Pext/Pext/blob/master/ci/build-appimage.sh is a PyQT5 project with a seemingly working appimage build script. I'll see what I can do with it.

Ryex commented 2 years ago

As for MacOS

the same project has a script for making dmg's https://github.com/Pext/Pext/blob/master/ci/build-dmg.sh

turns out that's a relatively simple process so long as you know how to make an .app bundle https://www.maketecheasier.com/anatomy-macos-app-bundles/ https://developer.apple.com/documentation/bundleresources/placing_content_in_a_bundle

Running this kind of script in an OSX ci workflow on github should work to make a working dmg but it will need to be verified by someone with a working Mac.

vkbo commented 2 years ago

Yeah, I have looked into packaging for mac, but to be honest, since I don't have access to one, I am reluctant to release something I cannot verify. I have an old VM with an older macos that I used to tweak some of the code for mac, but it's no longer usable for proper testing beyond that.

Making all of these packages also takes a lot of time. Setting up the debian build was a huge job, and I have spent a massive amount of time redoing the Windows installer in various ways. It takes up a lot of the time I have available for developing the actual app. I'm hoping someone would take on releasing for mac and rpm.

Life would have been so much simpler if pip also worked properly for GUI apps ...

Ryex commented 2 years ago

well, good news. turns out is dead simple to run a macOS VM via docker with https://github.com/sickcodes/Docker-OSX

I have a working VM with macOS 10.15 now and I'm completely willing to work on a packaging script for it your interested

vkbo commented 2 years ago

Sure, that would be great!

vkbo commented 6 months ago

AppImages have been implemented. and flatpak may be added, and anyway has a separate ticket at #1651. I'm closing this old discussion thread.