Adding a dependency to flatpak

I’m wanting to use an .odt file in my app and apparently a way to go about it is to use odfpy but whenever I add import odf to my app I get ModuleNotFoundError: No module named 'odf'.

I read through the flatpak docs and did some searches and it seems I need to add odfpy as a module in my .json file but I guess I’m missing something else, or not doing it correctly.

I’m using the template app from the Builder IDE.

This is my .json…

What am I missing? Thanks

{
    "id" : "com.github.koxt2.app",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "master",
    "sdk" : "org.gnome.Sdk",
    "command" : "app",
    "finish-args" : [
        "--share=network",
        "--share=ipc",
        "--socket=fallback-x11",
        "--device=dri",
        "--socket=wayland"
    ],
    "cleanup" : [
        "/include",
        "/lib/pkgconfig",
        "/man",
        "/share/doc",
        "/share/gtk-doc",
        "/share/man",
        "/share/pkgconfig",
        "*.la",
        "*.a"
    ],
    "modules" : [
        {
            "name" : "app",
            "builddir" : true,
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "git",
                    "url" : "file:///home/user/Projects"
                }
            ],
            "config-opts" : [
                "--libdir=lib"
            ]
        },
        {
            "name": "odfpy",
            "buildsystem": "simple",
            "build-commands": [
                "pip3 install --no-index --find-links=odfpy --prefix=/app odfpy"
            ],
            "sources": [
                {
                    "type": "file",
                    "url": "https://files.pythonhosted.org/packages/97/73/8ade73f6749177003f7ce3304f524774adda96e6aaab30ea79fd8fda7934/odfpy-1.4.1.tar.gz",
                    "sha256": "db766a6e59c5103212f3cc92ec8dd50a0f3a02790233ed0b52148b70d3c438ec"
                }
            ]
        }
    ],
    "build-options": {
        "env": {}
    }
}

In case you don’t get an answer here, you might want to ask on discourse.flathub.org as well.

1 Like

First, put your dependencies before the app module. The app module should be last.

Second, if your app uses PIP dependencies, you need to specify all used Python modules in the manifest, including dependencies of dependencies. So, you might still miss a dependency in your manifest.
Consider using the flatpak-pip-generator.

1 Like

Thanks guys - it was both these things, and flatpak-pip-generator is certainly more straight forward!