How to package a Python app?

I could really use some help getting my Python/QT5 based app packaged as a flatpak. I have managed to get it to work if I first package it with Pyinstaller then Flatpak that, now I’m trying to package it as the actual Github release for eventual upload onto Flathub.

This is what I have so far.

I’m trying to build this with the following command:

flatpak-builder --force-clean --user build-dir io.github.riftr.intelpy.yml

I’m getting an error saying that it can’t find pip, but pip is most definitely installed on my system and nothing I’ve tried resolves it. I’ve been at this for a few hours and tearing my hair out so any help is appreciated.

Why do you have com.riverbankcomputing.PyQt.BaseApp commented out? Also, PIP installed on your system doesn’t matter - build is inside the container

It’s commented out because with it I get the error “Failed to init: Unable to find app com.riverbankcomputing.PyQt.BaseApp version master”

How do I get pip inside the container?

Define base-version as well. AFAIK pip is provided by that baseapp

Okay I feel like we’re hopefully on the right track but no luck yet.

I’ve got in the yml file:

base: com.riverbankcomputing.PyQt.BaseApp
base-version: "5.15-23.08"

I’ve also installed it using:

flatpak install flathub com.riverbankcomputing.PyQt.BaseApp//5.15-23.08

But sadly still getting the error that pip is not found. Even changing “pip3” to “pip” in the file doesn’t matter.

Output:

$ flatpak-builder --force-clean --user build-dir io.github.riftr.intelpy.yml
Emptying app dir 'build-dir'
Downloading sources
Fetching git repo https://github.com/Riftr/intelpy.git, ref refs/tags/1.2b3
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
Starting build of io.github.riftr.intelpy
Cache miss, checking out last cache hit
========================================================================
Building module setuptools in /home/rob/Code/intelpy/buildscripts/flatpak-scripts/.flatpak-builder/build/setuptools-13
========================================================================
Running: pip install setuptools-69.2.0-py3-none-any.whl
/bin/sh: line 1: pip: command not found
Error: module setuptools: Child process exited with code 127

This might be incorrect: --env=PYTHONPATH=/app/site-packages. Also, did you generate your dependency list using flatpak pip generator or manually?

I got a little further by changing the sdk: line to sdk: org.kde.Sdk and installing the matching SDK from flathub. It’s seeing pip now (yay!) but now it’s unhappy about the PyQt5 version (I’m using the latest on PyPI 5.15.10)

I have manually created the dependency list based on what my app normally uses.

Running: pip3 install PyQt5-5.15.10-cp37-abi3-manylinux_2_17_x86_64.whl
Defaulting to user installation because normal site-packages is not writeable
Processing ./PyQt5-5.15.10-cp37-abi3-manylinux_2_17_x86_64.whl
Requirement already satisfied: PyQt5-sip<13,>=12.13 in /app/lib/python3.11/site-packages (from PyQt5==5.15.10) (12.13.0)
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 0x7fd6c2e8c710>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyqt5-qt5/
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 0x7fd6c35298d0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyqt5-qt5/
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 0x7fd6c2e97b50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyqt5-qt5/
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 0x7fd6c2e96950>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyqt5-qt5/
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 0x7fd6c2ea5350>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution')': /simple/pyqt5-qt5/
INFO: pip is looking at multiple versions of pyqt5 to determine which version is compatible with other requirements. This could take a while.
ERROR: Could not find a version that satisfies the requirement PyQt5-Qt5>=5.15.2 (from pyqt5) (from versions: none)
ERROR: No matching distribution found for PyQt5-Qt5>=5.15.2
Error: module pyqt5: Child process exited with code 1

PyQt5 is in the base runtime. No need to install it yourself