-
I'm writing an app in Python and packaging it using PyInstaller. On Linux, I'd like to make a Flatpak of the app since Flatpaks can run in basically any deskop Linux distro. One of the app's dependencies is pystray, which creates a system tray icon/status indicator/app indicator. On Linux it does that primarily through For Linux, the build process for my app consists of building generic Linux binaries with PyInstaller, then packaging into a Flatpak along with dependencies (only dep. is
The line causing this error is this: # pystray/_appindicator.py
gi.require_version('AppIndicator3', '0.1') I thought this was because for whatever reason the I tried adding a hook to Repo: https://github.com/androidWG/Discord.fm (see linux branch) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
If your Flatpak sandbox has a fully-fledged Python environment with all dependencies available, why are you using PyInstaller in the first place? You could put your program's source in the sandbox and run it in Flatpak-provided python environment. PyInstaller is designed to create frozen applications that try to be isolated from the target run-time environment (as much as possible, anyway). The shared libraries are collected from the build system and bundled with the frozen application, so in general, libraries from the target system environment are not used - with exception of low-level libs, such as libc, DRM graphics stack, and so on. If the sandbox fully matched the build system (especially in terms of default library search paths), then # program.py
import gi
gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3
print(AppIndicator3)
and run it on the same system
It finds the The hooks for the So in this case: # hooks/pre_safe_import_module/hook-gi.repository.AppIndicator3.py
def pre_safe_import_module(api):
api.add_runtime_module(api.module_name) and # hooks/hook-gi.repository.AppIndicator3.py
from PyInstaller.utils.hooks.gi import GiModuleInfo
module_info = GiModuleInfo('AppIndicator3', '0.1')
if module_info.available:
binaries, datas, hiddenimports = module_info.collect_typelib_data()
The typelib and its dependencies should be properly collected now. |
Beta Was this translation helpful? Give feedback.
If your Flatpak sandbox has a fully-fledged Python environment with all dependencies available, why are you using PyInstaller in the first place? You could put your program's source in the sandbox and run it in Flatpak-provided python environment.
PyInstaller is designed to create frozen applications that try to be isolated from the target run-time environment (as much as possible, anyway). The shared libraries are collected from the build system and bundled with the frozen application, so in general, libraries from the target system environment are not used - with exception of low-level libs, such as libc, DRM graphics stack, and so on.
If the sandbox fully matched the build system (espe…