Flatpaking a VPN app written in Python

I want to Flatpak this VPN app. The installation steps and dependencies are listed in their wiki.

The Python requirements are also listed. So simply running flatpak-pip-generator --yaml --requirements-file=doc/requirements.txt and then include that python3-requirements.yaml file as a module is a piece of cake.

I’ve went through the basic tutorial and a more elaborate one from YouTube. But I’m still left with a few questions and hurdles that block me from completing the Flatpak.

1 Like

Sorry, as a new user I couldn’t create this post in one go, I can only include a limited amount of links, so here is part 2

When looking at the runtimes and what they bundle, it seems like I should need the GNOME runtime. Since that one seem to perfectly align with most of the dependencies listed such as; notify, secret, introspection, dbus (since the GNOME runtime builds upon the FreeDesktop runtime) and gobject.

So with that information I guess the first bit of the Flatpak file is:

id: org.eduvpn.www
runtime: org.gnome.Platform
runtime-version: 44
sdk: org.gnome.Sdk
command: eduvpn-gui

  - python3-requirements.yaml

But what would be the next sensible step? Apparently the eduvpn-client[gui] packages pulls in the required dependency dbus-python, which fails with dbus-gmain| Run-time dependency dbus-1 found: NO (tried pkgconfig and cmake). So, I cannot just generate another list of pip requirements in a Flatpak format. With some DNF magic I think the file that’s needed is /usr/include/dbus-1.0/dbus/dbus-python.h, which is provided by dbus-python-devel and is also listed by the EduVPN project as a dependency.

How would I package something like this? dbus-python-devel is a package provided by python3-dbus, which seems to be the same pip package (dbus-python). So I’m a bit stuck in this recursive loop, or am I?

Any help would be appreciated.

Ah, this did it of course.

id: org.eduvpn.www
runtime: org.gnome.Platform
runtime-version: '44'
sdk: org.gnome.Sdk
command: eduvpn-gui
  - --device=dri
  - --share=ipc
  - --share=network
  - --socket=wayland
  - --socket=fallback-x11
  # To store credentials
  - --talk-name=org.freedesktop.secrets
  - --talk-name=org.gtk.vfs.*
  - --filesystem=xdg-run/gvfsd
  # To check the Network Manager status on the host system
  - --system-talk-name=org.freedesktop.NetworkManager
  # The downloaded OpenVPN profile hardcodes the certificate path
  # --filesystem=~/.cert/nm-openvpn:create
  # For DBus daemon reconnector
  - --system-talk-name=org.freedesktop.login1

  - python3-requirements.yaml

  - name: eduvpn-client
    buildsystem: simple
      - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
        --prefix=${FLATPAK_DEST} "eduvpn-client" --no-build-isolation
      - type: file
        url: https://files.pythonhosted.org/packages/20/ba/2353b67996f18af557c6c8f2d9fb04db4dc2d1c487129fa1567317366c51/eduvpn_client-4.1.1-py2.py3-none-any.whl
        sha256: e89f0d5ad19488a7923b4b2e5d7936371b6a72dc825fb8fbdba684ab46f0257b
      - type: file
        url: https://files.pythonhosted.org/packages/52/13/aba67ef397a97b6f671f5361bc14a5fbd68492cdec83f56ce2ad34737154/eduvpn_common-1.1.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl
        sha256: fa4d14d1602e4bfc89de0369ff423ca3fa7980eb628efa20d6ee1e0a45a4fa1c

Now I only have to solve some internal application errors. Which for now is in this piece of code. Apparently it doesn’t look in /app?

flatpak run --command=sh --devel org.eduvpn.www and ran it interactively.

F: Running '/usr/bin/bwrap --args 40 eduvpn-gui'
Traceback (most recent call last):
  File "/app/bin/eduvpn-gui", line 5, in <module>
    from eduvpn.ui.__main__ import eduvpn
  File "/app/lib/python3.10/site-packages/eduvpn/ui/__main__.py", line 12, in <module>
    from eduvpn.i18n import country
  File "/app/lib/python3.10/site-packages/eduvpn/i18n.py", line 7, in <module>
    from eduvpn.settings import COUNTRY, COUNTRY_MAP, LANGUAGE
  File "/app/lib/python3.10/site-packages/eduvpn/settings.py", line 5, in <module>
    prefix = get_prefix()
  File "/app/lib/python3.10/site-packages/eduvpn/utils.py", line 67, in get_prefix
    raise Exception("Can't find eduVPN installation")
Exception: Can't find eduVPN installation

The docs threw me off I guess. I shouldn’t run flatpak run, but just launch the application from the GNOME shell. Then it seems to work fine.