"buildsystem": "simple" for a Python Flatpak

I like the simplicity of Flatpak manifests, it seems streets ahead of other formats which require several files of different sorts. This question is about making things even simpler. I have a Flatpak which contains several dependencies which are compiled from C, then this to install the main Python program:

  • name: myapp
    buildsystem: meson
    sources:
    type: git
    tag: V1.1.1
    url: blah

This uses Meson which has a meson.build file which finds appropriate directory names and does things like this:

bindir = get_option(‘bindir’)
datadir = get_option(‘datadir’)
pkgdatadir = join_paths(get_option(‘prefix’), get_option(‘datadir’), ‘myapp’)
conf = configuration_data()
conf.set(‘pkgdatadir’, pkgdatadir)
install_data(file, install_dir: pkgdatadir)

Alternatively there is “buildsystem”: “simple”, like this (this example is for a Bash file not a Python program):

    {
        "name": "hello",
        "buildsystem": "simple",
        "build-commands": [
            "install -D hello.sh /app/bin/hello.sh"
        ],
        "sources": [
            {
                "type": "file",
                "path": "hello.sh"
            }
        ]
    }

Can I install Python program in the module in the manifest as in the above example, by using “install” plus other Bash commands, without the extra complication of using Meson?
I’m assuming that there is nothing magic about installation, all that’s needed is to discover the correct directories, then copy the files to those destination.

This is more like the actual code. My Meson.build is similar to the first bit of code below. ChatGPT suggests using the code below that in the manifest instead. That looks simpler and avoids the use of a second technology.
Will this work, in particular does it use the official Flatpak directories properly? I’m not expecting anyone to write the code for me, just to confirm that I haven’t missed something subtle that Meson does that I haven’t understood.

Current manifest

blah
blah
  - name: myapp
    buildsystem: meson
    sources:
    - type: git
      tag: main
      url: https://github.com/mysoftware/myapp

meson.build

project(
‘myapp’,
version: ‘0.0.0’,
meson_version: ‘>= 0.46.0’
)

bindir = get_option(‘bindir’)
datadir = get_option(‘datadir’)
pkgdatadir = join_paths(get_option(‘prefix’), get_option(‘datadir’), ‘myapp’)

conf = configuration_data()
conf.set(‘pkgdatadir’, pkgdatadir)

configure_file(
input: ‘myapp.py’,
output: ‘myapp’,
configuration: conf,
install_dir: bindir
)

data_files = [
‘com.github.mysoftware.myapp.png’,
‘dummy.png’
]

foreach file : data_files
install_data(file, install_dir: pkgdatadir)
endforeach

install_data(
‘com.github.mysoftware.myapp.appdata.xml’,
install_dir: join_paths(datadir, ‘metainfo’)
)

install_data(
‘com.github.mysoftware.myapp.desktop’,
install_dir: join_paths(datadir, ‘applications’)
)

install_data(
‘com.github.mysoftware.myapp.png’,
install_dir: join_paths(datadir, ‘icons’, ‘hicolor’, ‘128x128’, ‘apps’)
)

install_data(
‘com.github.mysoftware.myapp64x64.png’, rename : ‘com.github.mysoftware.myapp.png’,
install_dir: join_paths(datadir, ‘icons’, ‘hicolor’, ‘64x64’, ‘apps’)
)

install_data(
‘myapp_nl_NL.mo’, rename : ‘myapp.mo’,
install_dir: join_paths(get_option(‘prefix’), get_option(‘localedir’), ‘nl_NL’, ‘LC_MESSAGES’)
)

install_data(
‘myapp_de_DE.mo’, rename : ‘myapp.mo’,
install_dir: join_paths(get_option(‘prefix’), get_option(‘localedir’), ‘de_DE’, ‘LC_MESSAGES’)
)

New manifest

blah
blah
- name: myapp
  buildsystem: simple
  build-commands:
    # Ensure the target directories exist
    - mkdir -p /app/bin
    - mkdir -p /app/share/myapp
    - mkdir -p /app/share/metainfo
    - mkdir -p /app/share/applications
    - mkdir -p /app/share/icons/hicolor/128x128/apps
    - mkdir -p /app/share/icons/hicolor/64x64/apps
    - mkdir -p /app/share/locale/nl_NL/LC_MESSAGES
    - mkdir -p /app/share/locale/de_DE/LC_MESSAGES

    # Install the main script
    - install -m 755 popout3d.py /app/bin/popout3d

    # Install data files
    - install -m 644 com.github.mysoftware.myapp.png dummy.png /app/share/myapp

    # Install app metadata
    - install -m 644 com.github.mysoftware.myapp.appdata.xml /app/share/metainfo
    - install -m 644 com.github.mysoftware.myapp.desktop /app/share/applications

    # Install icons
    - install -m 644 com.github.mysoftware.myapp.png /app/share/icons/hicolor/128x128/apps
    - install -m 644 com.github.mysoftware.myapp64x64.png /app/share/icons/hicolor/64x64/apps/com.github.mysoftware.myapp.png

    # Install translations
    - install -m 644 myapp_nl_NL.mo /app/share/locale/nl_NL/LC_MESSAGES/myapp.mo
    - install -m 644 myapp_de_DE.mo /app/share/locale/de_DE/LC_MESSAGES/myapp.mo
  sources:
    - type: git
      tag: main
      url: https://github.com/mysoftware/myapp

Seems to work, so I’ll switch to this, as it’s much simpler than having to install and use Meson and have a meson.build file in addition to the manifest.

I think I’ve worked out what the Meson file does and why it can be replaced:

It defines directories
The get_option statements are finding the OSs directories, so it is OS neutral. There’s no need for that for this app as it will only run on Linux and it’s in a Flatpak which has fixed standards anyway. It’s therefore OK that “buildsystem: simple” hard codes them.

It copies (renaming if necessary) files into the appropriate directories. I thought “installation” was some special process. It isn’t. Install command explanation - it’s just a powerful combination of cp and mkdir commands.

So I think I can recommend someone writing a simple Flatpak to use “buildsystem: simple” and not bother with Meson.

This topic was automatically closed after 2 days. New replies are no longer allowed.