Skip to content

Cannot add py7zr library to flatpak #11

@Allexio

Description

@Allexio

Hi there,
I'm currently trying to add support for 7zip extraction but I have some trouble getting the py7zr library included in my flatpak.

Everything works great with my initial 3 libraries: pyyaml requests rarfile but as soon as I add py7zr to the flatpak things go awry.
Of course it works in my dev python environment (like, I was able to install the pip packages and their dependencies just fine).

Initial com.nomm.Nomm.yaml

id: com.nomm.Nomm
runtime: org.gnome.Platform
runtime-version: '49' # Matching the latest stable GNOME runtime
sdk: org.gnome.Sdk
command: nomm # The name of your entry-point script
finish-args:
  # Network access for downloading images and Nexus mods
  - --share=network
  - --share=ipc
  - --socket=fallback-x11
  - --socket=wayland
  - --device=dri
  # Access to Steam and Heroic configurations
  - --filesystem=home:ro
  # Specific permission for Heroic's Flatpak config if Heroic is also a Flatpak
  - --filesystem=~/.var/app/com.heroicgameslauncher.hgl/config/heroic:ro
  - --filesystem=xdg-run/app/com.heroicgameslauncher.hgl:ro
  - --own-name=com.nomm.Nomm
  # Access to Steam
  - --filesystem=~/.local/share/Steam:ro
  # Flatpak Steam path (if the user is running Steam as a Flatpak)
  - --filesystem=~/.var/app/com.valvesoftware.Steam:ro
  - --filesystem=xdg-run/app/com.valvesoftware.Steam:ro
  # mounting points
  - --filesystem=/run/media:rw
  - --filesystem=/mnt:rw

modules:

  # Python dependencies (generated via flatpak-pip-generator)
  - python3-modules.json

  # bundling unrar because otherwise the default version in flatpak doesn't work
  - name: unrar
    buildsystem: simple
    build-commands:
      - make -f makefile
      - install -Dm755 unrar /app/bin/unrar
    sources:
      - type: archive
        url: https://www.rarlab.com/rar/unrarsrc-6.2.10.tar.gz
        sha256: 55fe6ebd5e48d6655bfda3fd19b55438ca05e13c7e69772420caad9fdb68ef42
        
  # Application
  - name: nomm
    buildsystem: simple

    build-commands:
      # Install entry point from the src folder to /app/bin
      - install -D src/launcher.py /app/bin/nomm
      
      # Install desktop file
      - install -D com.nomm.Nomm.desktop /app/share/applications/com.nomm.Nomm.desktop

      # Install metainfo
      - install -D com.nomm.Nomm.metainfo.xml /app/share/metainfo/com.nomm.Nomm.metainfo.xml

      # Install icon
      - install -D assets/nomm.png /app/share/icons/hicolor/64x64/apps/com.nomm.Nomm.png
      
      # Copy all the important stuff
      - cp src/*.py /app/bin/
      - cp src/*.yaml /app/bin/
      - cp src/*.css /app/bin/
      
      - cp -r assets /app/bin/assets
      - cp -r default_game_configs /app/bin/default_game_configs
    sources:
      - type: dir
        path: .

command to generate python3-modules.json:
./flatpak-pip-generator.py pyyaml requests rarfile py7zr
command to build flatpak:
flatpak-builder --user --install --force-clean --repo=repo build-dir com.nomm.Nomm.yaml

With this I got the following error:

ERROR: Could not find a version that satisfies the requirement backports.zstd>=1.0.0; python_version < "3.14" (from py7zr) (from versions: none)
ERROR: No matching distribution found for backports.zstd>=1.0.0; python_version < "3.14"

So I decided to manually add backports.zstd to my modules in my com.nomm.Nomm.yaml:

- name: python3-backports-zstd
    buildsystem: simple
    build-commands:
      - pip3 install --prefix=/app --no-build-isolation --no-deps .
    sources:
      - type: archive
        url: https://files.pythonhosted.org/packages/f4/b1/36a5182ce1d8ef9ef32bff69037bd28b389bbdb66338f8069e61da7028cb/backports_zstd-1.3.0.tar.gz
        sha256: e8b2d68e2812f5c9970cabc5e21da8b409b5ed04e79b4585dbffa33e9b45ebe2

(I added --no-build-isolation to avoid issues with it trying to connect to pip and failing which was generating another error)
Unfortunately this has just moved the problem to a second dependency:

creating '/tmp/pip-modern-metadata-z4kc3x4w/pyppmd-0.0.0.dist-info'
  Preparing metadata (pyproject.toml) ... done
  WARNING: Requested pyppmd>=1.3.1 from file:///run/build/python3-py7zr/pyppmd-1.3.1.tar.gz (from py7zr), but installing version 0.0.0
Discarding file:///run/build/python3-py7zr/pyppmd-1.3.1.tar.gz: Requested pyppmd>=1.3.1 from file:///run/build/python3-py7zr/pyppmd-1.3.1.tar.gz (from py7zr) has inconsistent version: expected '1.3.1', but metadata has '0.0.0'
INFO: pip is looking at multiple versions of py7zr to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement pyppmd>=1.3.1 (from py7zr) (from versions: 1.3.1)
ERROR: No matching distribution found for pyppmd>=1.3.1
Error: module python3-py7zr: Child process exited with code 1

I therefore tried to also manually include pyppmd in my modules as such:

- name: python3-pyppmd
    buildsystem: simple
    build-commands:
      # Use no-build-isolation to avoid needing internet for build-time deps
      - pip3 install --prefix=/app --no-build-isolation --no-deps .
    sources:
      - type: archive
        url: https://files.pythonhosted.org/packages/81/d7/803232913cab9163a1a97ecf2236cd7135903c46ac8d49613448d88e8759/pyppmd-1.3.1.tar.gz
        sha256: ced527f08ade4408c1bfc5264e9f97ffac8d221c9d13eca4f35ec1ec0c7b6b2e
        subdir: pyppmd-1.3.1

... but I still get the same error.
I've tried other ideas to try and get past this but nothing worked out 😔

Any help from a flatpak expert would be very much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions