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

Flatpak #341

Open
JakobDev opened this issue Jun 28, 2023 · 6 comments
Open

Flatpak #341

JakobDev opened this issue Jun 28, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@JakobDev
Copy link

I created a Flatpak for wwrando. If you don't know about Flatpak, you can think of it like Docker but for the Linux Desktop. It bundles everything needed to run the Program in a Container. Flatpaks can also be published to Flathub.

These are the files needed to build the Flatpak:

io.github.LagoLunatic.wwrando

id: io.github.LagoLunatic.wwrando
runtime: org.kde.Platform
runtime-version: '6.5'
sdk: org.kde.Sdk
command: wwrando
sdk-extensions:
  - org.freedesktop.Sdk.Extension.llvm16
build-options:
    append-path: /usr/lib/sdk/llvm16/bin
    prepend-ld-library-path: /usr/lib/sdk/llvm16/lib
finish-args:
  - --socket=fallback-x11
  - --socket=wayland
  - --share=ipc
  - --device=dri

modules:
  - python3-modules.yaml

  - name: qt-include
    # https://bugreports.qt.io/projects/PYSIDE/issues/PYSIDE-787
    buildsystem: simple
    build-commands:
      - mkdir -p /app/include/qt
      - cp -R /usr/include/Qt* /app/include/qt
    cleanup:
      - /include

  - name: PySide6
    buildsystem: cmake-ninja
    builddir: true
    config-opts:
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
      - -DBUILD_TESTS=OFF
    sources:
      - type: archive
        url: https://download.qt.io/official_releases/QtForPython/pyside6/PySide6-6.5.1.1-src/pyside-setup-everywhere-src-6.5.1.1.tar.xz
        sha256: 9741a06f0b7d4b2168818448134bc7e96ddb5efb846a3915b4177ba4159b5b78
      - type: shell
        commands:
          # use qt-include
          - sed -i 's|\(--include-paths=\)|\1/app/include/qt:|' sources/pyside6/cmake/Macros/PySideModules.cmake
          # fix python module search path
          - sed -i '/--sys-path\b/ a "${pysidebindings_BINARY_DIR}/.."' sources/pyside6/cmake/Macros/PySideModules.cmake
    cleanup:
      - /plugins
      - /include
      - /bin

  - name: wwrando
    buildsystem: simple
    build-commands:
      - sed -i "/from sys import _MEIPASS/d" wwrando/wwrando_paths.py
      - sed -i "s/_MEIPASS/os.path.dirname(os.path.realpath(__file__))/" wwrando/wwrando_paths.py
      - sed -i "s/Darwin/Linux/" wwrando/wwrando_paths.py
      - cp -r wwrando $FLATPAK_DEST
      - install -Dm755 wrapper.sh $FLATPAK_DEST/bin/wwrando
    sources:
      - type: archive
        dest: wwrando
        url: https://github.com/LagoLunatic/wwrando/archive/refs/tags/1.10.0.tar.gz
        sha256: 9d05501ff5468aa5d790cb10c7daaed50700f81b7254bc9cdbfe3c3f28c50d19

      - type: script
        dest-filename: wrapper.sh
        commands:
          - exec python /app/wwrando/wwrando.py

python3-modules.yaml

# Generated with flatpak-pip-generator --yaml --checker-data PyYAML Pillow appdirs certifi
build-commands: []
buildsystem: simple
modules:
  - name: python3-PyYAML
    buildsystem: simple
    build-commands:
      - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
        --prefix=${FLATPAK_DEST} "PyYAML" --no-build-isolation
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/36/2b/61d51a2c4f25ef062ae3f74576b01638bebad5e045f747ff12643df63844/PyYAML-6.0.tar.gz
        sha256: 68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2
        x-checker-data:
          name: PyYAML
          type: pypi
  - name: python3-Pillow
    buildsystem: simple
    build-commands:
      - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
        --prefix=${FLATPAK_DEST} "Pillow" --no-build-isolation
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/00/d5/4903f310765e0ff2b8e91ffe55031ac6af77d982f0156061e20a4d1a8b2d/Pillow-9.5.0.tar.gz
        sha256: bf548479d336726d7a0eceb6e767e179fbde37833ae42794602631a070d630f1
        x-checker-data:
          name: Pillow
          type: pypi
  - name: python3-appdirs
    buildsystem: simple
    build-commands:
      - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
        --prefix=${FLATPAK_DEST} "appdirs" --no-build-isolation
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
        sha256: a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128
        x-checker-data:
          name: appdirs
          packagetype: bdist_wheel
          type: pypi
  - name: python3-certifi
    buildsystem: simple
    build-commands:
      - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
        --prefix=${FLATPAK_DEST} "certifi" --no-build-isolation
    sources:
      - type: file
        url: https://files.pythonhosted.org/packages/9d/19/59961b522e6757f0c9097e4493fa906031b95b3ebe9360b2c3083561a6b4/certifi-2023.5.7-py3-none-any.whl
        sha256: c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716
        x-checker-data:
          name: certifi
          packagetype: bdist_wheel
          type: pypi
name: python3-modules

Here are instructions how to build

It works, but a little bit of work is needed to make it complete. Tell me, if you are interested.

@JakobDev
Copy link
Author

Ping @LagoLunatic

@LagoLunatic
Copy link
Owner

What benefit is there to using flatpak compared to downloading the executable release of the randomizer? (I don't know what docker is, either, so that comparison isn't doing anything for me.)

@JakobDev
Copy link
Author

With binary builds you have no guaranty that it works on every system. Depending which libraries (and which version the libraries) have, it may not work. PyInstaller, which are you using, has a section about this in the documentation.That's one of the reason Linux Distros typically build almost all Programs from source.

With Flatpak, you don't have such a problem. Flatpak bundles everything needed. Apps in a Flatpak don't using anything outside their Flatpak. Flatpak Apps are guaranteed to always works exactly the same on every Distro.

Flatpak is also intergrated in many Linux Distros by default. So Users can use the Tools of their Distro to manage Flatpak Apps (they can be installed/updated/removed through the Software Center of the Distro) instead of dealing with binaries.

Flatpak also has a build-in permission System like e.g. Android or IOS. So Apps have only access to the resources they need.

@LagoLunatic LagoLunatic added the enhancement New feature or request label Jul 22, 2023
@muffinjets
Copy link

Fellow Linux user, this would be great if included

@LagoLunatic
Copy link
Owner

I can look into adding Flatpak at some point, but for future reference: the Flatpak app will not be able to do non-spoiler-log races with other people since it won't have the proper encryption keys (same as if you run the randomizer from source). You have to use the binary executable for that.

@lunix33
Copy link

lunix33 commented Mar 9, 2024

You could in fact bundle within flatpak your binary release without issue. A lot of application does just that.
You can think of flatpak as a self-contained version of linux or a super lightweight version of a virtual machine.

But for sure, there would need to be some experimenting on your side to make sure everything work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants