Help in building Flatpak for Pyside6+Python app

Hello. I want to build (and later publish this app in Flathub) that is written in Python with PySide6. I successfully built Snap package, but I have problems with Flatpak.

Project structure:

├── flatpak
├── requirements.txt
├── setup.py
├── snap
│   ├── gui
│   │   ├── tabela.desktop
│   │   └── tabela.png
│   └── snapcraft.yaml
├── tabela
│   ├── addItemDialog.py
│   ├── fileProcessing.py
│   ├── __init__.py
│   ├── LICENSE
│   ├── main.py
│   ├── mainwindow.py
│   ├── myTableModel.py
│   ├── README.md
│   └── saveDataDialog.py
└── tabela.json

setup.py:

from setuptools import setup

package_name = 'tabela'
filename = 'tabela/__init__.py'

setup(
    name='tabela',
    version='1.0',
    description='Simple app that shows CSV content in table.',
    author='cichy1173',
    author_email='grzegorz@cichy1173.eu',
    packages=['tabela'],
    install_requires=[
        'pyside6',  # Add any other dependencies your app requires
    ],
    entry_points={
        'console_scripts': [
            'tabela=tabela.main:main',  # Replace 'yourappname' with the desired command
        ],
    },
)

tabela.json (flatpak manifest):

{
  "app-id": "eu.cichy1173.tabela",
  "runtime": "org.kde.Platform",
  "runtime-version": "6.2",
  "sdk": " org.kde.Sdk",
  "command": "tabela",
  "finish-args": ["--share=ipc", "--share=x11", "--share=wayland", "filesystem=host", "device=dri"],
  "modules": [
    {
      "name": "tabela",
      "buildsystem": "simple",
      "build-commands": [
        "python -m pip install ."
      ],
      "sources": [
        {
          "type": "dir",
          "path": "/home/cichy1173/Projekty/Tabela"
        }
      ],
      "build-extensions": ["org.freedesktop.Sdk.Extension.python3.8"]
    }
  ]
}

I am trying to build flatpak with command flatpak-builder --user --install flatpak tabela.json but I have this error:

(flatpak-builder:364858): flatpak-builder-WARNING **: 13:04:45.674: Unknown property build-extensions for type BuilderModule
error: Invalid id  org.kde.Sdk: Name can't start with  
Failed to init: Unable to find sdk  org.kde.Sdk version 6.2

But if I check installed sdks:

[cichy1173@starbook Tabela]$ flatpak list | grep org.kde.Sdk
KDE Software Development Kit    org.kde.Sdk             5.15-21.08      flathub system
KDE Software Development Kit    org.kde.Sdk             6.2     flathub system

I think, the lack of org.kde.Sdk (but i have it) it is not the only issue. My app is really basic, it uses only one dependency (PySide6), but I still have a lot of problems with building Flatpak. How can I do this in the right way?

It seems the issue is that you have added a space at the start of:

"sdk": "org.kde.Sdk",

so that it is instead:

"sdk": " org.kde.Sdk",

I even had to diff the manifest with a known good one to notice the issue.

It might be useful for flatpak-builder to check stuff like this, as i dont think runtime-id can have spaces in them in the first place.

Yes. Thank you. Now I can build app with GNOME Builder. I had to also change finish-args, because it wouldnt let me start the app.

{
  "app-id": "eu.cichy1173.tabela",
  "runtime": "org.kde.Platform",
  "runtime-version": "6.2",
  "sdk": "org.kde.Sdk",
  "command": "tabela",
  "finish-args": ["--share=ipc", "--share=network"],
  "modules": [
    {
      "name": "tabela",
      "buildsystem": "simple",
      "build-commands": [
        "python -m pip install ."
      ],
      "sources": [
        {
          "type": "dir",
          "path": "/home/cichy1173/Projekty/Tabela"
        }
      ],
      "build-extensions": ["org.freedesktop.Sdk.Extension.python3.8"]
    }
  ]
}

But now I have this issue:

bwrap: execvp tabela: No such file or directory
Application exited

But If i try build an app in VSCodium using terminal and command flatpak-builder --user --install flatpak tabela.json I have this issue:

Processing /run/build/tabela
  Preparing metadata (setup.py) ... done
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fe7360e1820>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyside6/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fe7360ff130>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyside6/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fe7360ff580>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyside6/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fe7360ffeb0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyside6/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fe7360fff70>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyside6/
ERROR: Could not find a version that satisfies the requirement PySide6 (from tabela) (from versions: none)
ERROR: No matching distribution found for PySide6
WARNING: There was an error checking the latest version of pip.
Error: module tabela: Proces potomny został zakończony z kodem 1

How can i fix this?

Flatpak-builder builds the application without network access, so you cant download the dependencies during the build step. So you will need to tell flatpak-builder to download the sources beforehand.

As i can see you have a requiremets.txt file you can use this:

To automatically generate a json file with the necessary modules you can then include in your manifest to handle dependency downloads.

Another python app also adds --prefix=${FLATPAK_DEST} to build commands for python components, so that might be related to the error with Gnome Builder see: