Amulet-Team / Amulet-Map-Editor

A new Minecraft world editor and converter that supports all versions since Java 1.12 and Bedrock 1.7.
https://www.amuletmc.com/
1.67k stars 122 forks source link

Looking to make a FlatPak version... #1070

Open EvilSupahFly opened 1 week ago

EvilSupahFly commented 1 week ago

It's not super urgent, as I don't have much free time, but I'd like to make Amulet into a Flatpak for Linux users who don't want to mess with or understand how to work with dependencies and the like, but the Amulet project no longer uses a specifically defined "requirements.txt" file, and I was wondering if this requirement information was moved into "setup.cfg" in its entirety or if the installer makes some hard-coded assumptions. There's a lot of stuff the flatpak builder can't use or doesn't understand in "setup.cfg" meaning I can't reference it directly, so I was looking to simplify it back down to the old-school "requirements.txt", but I don't know if I need to add anything that isn't already defined in the setup file.

For what it's worth, this is what I've reduced it down to:

amulet_map_editor
amulet_core>=1.9
amulet_nbt>=2.0
black>=22.3
minecraft_resource_pack>=1.3
numpy>=1.17
packaging
Pillow>=10.0.1
platformdirs>=3.1
pre_commit>=1.11.1
pymctranslate>=1.2
pyopengl>=3.0
python_version>=3.9
Sphinx>=1.7.4
sphinx_autodoc_typehints>=1.3.0
sphinx_rtd_theme>=0.3.1
wxPython

Am I missing anything? ** Edit - Fixed some context-sensitive typos

gentlegiantJGC commented 1 week ago

I don't know too much about the flatpak format. Would each library be bundled separately or all bundled into one package?

A requirements.txt file can be generated with pip freeze which will write all the installed libraries to a requirements.txt file but that will freeze all of the requirements.

As part of our build process we freeze first party dependencies to ensure that everyone running a given version of amulet_map_editor is also running the same version of amulet_core and other first party dependencies to make debugging easier. I would like the same behaviour here. The following code installs the dependencies and calls pip freeze and extracts only first party libraries. https://github.com/Amulet-Team/Amulet-Map-Editor/blob/0.10/setup.py#L23C5-L23C24

Most of the dependencies you have listed are development requirements that are not needed to run the program.

build-time dependencies are listed here https://github.com/Amulet-Team/Amulet-Map-Editor/blob/0.10/pyproject.toml#L2

runtime dependencies are listed here https://github.com/Amulet-Team/Amulet-Map-Editor/blob/0.10/setup.cfg#L17

gentlegiantJGC commented 1 week ago

It may be easier to add linux wheels

EvilSupahFly commented 1 week ago

With a Flatpak, ideally a project can be self-contained and sandboxed with all its libraries and dependencies so it can be run on any version of Linux right out of the box, so to speak. This avoids manually creating VENs, or potentially screwing things up by skipping the virtual environment and doing a system-wide install, and also eliminates the need to muck about in the terminal or with PIP (as many Linux newcomers might not be comfortable with these). Because Flathub plugs right into the Software Manager GUI for both Gnome and KDE, users can easily install or uninstall a Flatpak with no prior understanding of anything, really.

Like GIT, it has built in version control as well, meaning users will get the newest version when they install fresh, and be notified by their system update manager when updates are available. Wheels are handy too, but still require people to do "terminal things" whether it's typing out stuff themselves, or running a script - something Flatpaks avoid. Also, wheels aren't completely sandboxed, though they can be self contained.

There's a pretty good write up about Flatpaks over on Reddit if you were curious.

Screenshot from 2024-07-01 07-38-10 Screenshot from 2024-07-01 07-44-41

gentlegiantJGC commented 1 week ago

Sounds kind of like a windows installer. We use PyInstaller to bundle the code into an executable format. An additional step is required to make a normal installer.

Is there a way to convert the output from pyinstaller to a flatpak?

Are dependencies like wxPython installed separately by the package manager or would we also bundle those with the flatpak?

EvilSupahFly commented 1 week ago

According to the official docs, Flatpak uses runtimes which provide the basic dependencies that are used by applications. Each application must be built against a runtime, and this runtime must be installed on a host system in order for the application to run, and Flatpak can automatically install the runtime required by an application.

Their entire runtime catalogue is listed on their website. My original plan was to test it first on my production box running Mint, then test it on a couple different VMs running other distros. The issue I have with Mint is that it's always based on the last LTS release of Ubuntu, but sometimes projects want newer versions of certain core libraries (libc is the most common offender) which can't just be manually installed unless you want to brick your system, and aren't brought in with Python's VENV because it (potentially) violates the library sanctity of the host OS or will break the project.

Since Flatpaks are bundled and sandboxed with their own runtimes, in theory, it fixes this.