How can I properly include libshumate to my project? I'm pretty new to this

this is my current manifest

{
    "id" : "csucarig.wp2.LoraMap",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "master",
    "sdk" : "org.gnome.Sdk",
    "command" : "loramapc",
    "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" : "protobuf",
            "buildsystem" : "autotools",
            "config-opts": [ "DIST_LANG=cpp" ],
            "cleanup" : [
                "/bin/protoc*",
                "/lib/libprotoc*",
                "/lib/libprotobuf-lite*"
            ],
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
                    "sha256" : "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2"
                }
            ]
        },
    	{
            "name" : "protobuf-c",
            "buildsystem" : "autotools",
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.0/protobuf-c-1.4.0.tar.gz",
                    "sha256" : "26d98ee9bf18a6eba0d3f855ddec31dbe857667d269bc0b6017335572f85bbcb"
                }
            ]
        },
        {
	    "name" : "libshumate",
	    "buildsystem": "meson",
	    "config-opts": [
		"-Ddemos=false",
		"-Dgtk_doc=false",
		"-Dvapi=false"
	    ],
	    "sources" : [
		{
		    "type" : "git",
		    "url" : "https://gitlab.gnome.org/GNOME/libshumate.git",
		    "branch" : "main"
		}
	    ]
	},

        {
            "name" : "loramapc",
            "builddir" : true,
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "git",
                    "url" : "file:///home/wp2/Projects"
                }
            ]
        }
    ]
}

building the project works fine

but adding the dependency is a different story

loramapc_sources = [
  'main.c',
  'loramapc-application.c',
  'loramapc-window.c',
]


shumate = dependency('shumate-1.0', version: '>= 1.2.alpha')

loramapc_deps = [
  dependency('gtk4'),
  dependency('libadwaita-1', version: '>= 1.4'),
  dependency('shumate-1.0')
]

loramapc_sources += gnome.compile_resources('loramapc-resources',
  'loramapc.gresource.xml',
  c_name: 'loramapc'
)

executable('loramapc', loramapc_sources,
  dependencies: [
     loramapc_deps,
  ],
       install: true,
)

i get this error message

Run-time dependency shumate-1.0 found: NO (tried pkgconfig and cmake)

../../../../../../Projects/LoraMapC/src/meson.build:8:10: ERROR: Dependency "shumate-1.0" not found, tried pkgconfig and cmake

Your usage looks fine at a glance.

If you open a build terminal in Builder (top left menu) you can poke around the filesystem to see if it installed. Also check the build logs for libshumate to see any interesting output.

I ran a dependency update and I saw this . It might be Shumate-1.0.gir that is needed

Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/libshumate-1.0.so.1.0
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/libshumate-1.0.so
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/libshumate-1.0.so.1
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/girepository-1.0/Shumate-1.0.typelib
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/girepository-1.0
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/pkgconfig/shumate-1.0.pc
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64/pkgconfig
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/lib64
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/share/gir-1.0/Shumate-1.0.gir
Removing /home/wp2/.cache/gnome-builder/projects/LoraMap/flatpak/staging/x86_64-main/files/share/gir-1.0

I need to add declare something somewere but I do not have any idea :frowning:

That part looks suspicious:

  dependencies: [
     loramapc_deps,
  ],

It’s already an array, should be like this I think:

  dependencies: loramapc_deps,

It doesn’t really matter: Meson will flatten arrays if needed.

I would like to clarify my mistakes I actually move to a clean project with python as the language. This is my current src/meson.build

pkgdatadir = get_option('prefix') / get_option('datadir') / meson.project_name()
moduledir = pkgdatadir / 'loramap'
gnome = import('gnome')

gnome.compile_resources('loramap',
  'loramap.gresource.xml',
  gresource_bundle: true,
  install: true,
  install_dir: pkgdatadir,
)

python = import('python')

conf = configuration_data()
conf.set('PYTHON', python.find_installation('python3').full_path())
conf.set('VERSION', meson.project_version())
conf.set('localedir', get_option('prefix') / get_option('localedir'))
conf.set('pkgdatadir', pkgdatadir)


configure_file(
  input: 'loramap.in',
  output: 'loramap',
  configuration: conf,
  install: true,
  install_dir: get_option('bindir'),
  install_mode: 'r-xr-xr-x'
)

loramap_sources = [
  '__init__.py',
  'main.py',
  'window.py',
]

install_data(loramap_sources, install_dir: moduledir)

this is the new error message I get

Application started at 08:39:35 PM
Traceback (most recent call last):
  File "/app/bin/loramap", line 45, in <module>
    from loramap import main
  File "/app/share/loramap/loramap/main.py", line 27, in <module>
    from .window import LoramapWindow
  File "/app/share/loramap/loramap/window.py", line 22, in <module>
    gi.require_version("Shumate", "1.0")
  File "/usr/lib/python3.12/site-packages/gi/__init__.py", line 122, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Shumate not available
Application exited

I don’t know maybe I’m missing some binding thing. I suspect that I’m missing
"gir1.2-shumate-1.0 " since all works fine when I wrote a test file in pycharm purely using system dependencies and yes when I first run my test project in pycharm in actually gave me the same error message so I installed “gir1.2-shumate-1.0” into my system and it worked.

One Note: I actually solved my initial problem with the “clang” version of my project by adding the “include_directories” for shumate-1.0 but since I’m in python now… well I really need some help

This is very confusing, because you’re using a Flatpak manifest and then you’re referring to packages. Flatpak does not have packages.

The libshumate project generates and installs the typelib that is consumed by Python under the prefix you used—/app in this case. You have to ensure that pygobject is going to find the typelib file you built into your application. This is usually done by adding /app/lib/girepository-1.0 to the GI_TYPELIB_PATH environment variable.

after reading the build messages
i found the path for the shumate typelib

"build-options": {
        "env": {
      	   "GI_TYPELIB_PATH": "/app/lib/girepository-1.0:$GI_TYPELIB_PATH:/app/lib64/girepository-1.0"
    	}
    },
    "finish-args" : [
        "--share=network",
        "--share=ipc",
        "--socket=fallback-x11",
        "--device=dri",
        "--socket=wayland",
         "--env=GI_TYPELIB_PATH=/app/lib/girepository-1.0:$GI_TYPELIB_PATH:/app/lib64/girepository-1.0"
    ],

haven’t tested yet but no error so far

when I imported shumate everything works fine but then when declared a simple map

m = Shumate.SimpleMap()

I got this error instead

** (loramap:2): WARNING **: 22:18:30.664: Failed to load shared library 'libshumate-1.0.so.1' referenced by the typelib: libshumate-1.0.so.1: cannot open shared object file: No such file or directory
/app/share/loramap/loramap/window.py:40: Warning: cannot retrieve class for invalid (unclassed) type 'void'
  m = Shumate.SimpleMap()
Traceback (most recent call last):
  File "/app/share/loramap/loramap/main.py", line 48, in do_activate
    win = LoramapWindow(application=self)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/share/loramap/loramap/window.py", line 40, in __init__
    m = Shumate.SimpleMap()
        ^^^^^^^^^^^^^^^^^^^
TypeError: could not get a reference to type class

@ebassi
This is my Manifest file that finally fixed it

{
    "id" : "csucarig.wp2.LoraMap",
    "runtime" : "org.gnome.Platform",
    "runtime-version" : "master",
    "sdk" : "org.gnome.Sdk",
    "command" : "loramap",
    "build-options": {
                "env": {
                   "GI_TYPELIB_PATH": "/app/lib/girepository-1.0:/app/lib64/girepository-1.0:/app/lib64"
	         }
	     },
    "finish-args" : [
        "--share=network",
        "--share=ipc",
        "--socket=fallback-x11",
        "--device=dri",
        "--socket=wayland",
        "--env=GI_TYPELIB_PATH=/app/lib/girepository-1.0:/app/lib64/girepository-1.0:/app/lib64"
    ],
    "cleanup" : [
        "/include",
        "/lib/pkgconfig",
        "/man",
        "/share/doc",
        "/share/gtk-doc",
        "/share/man",
        "/share/pkgconfig",
        "*.la",
        "*.a"
    ],
    "modules" : [

    	{
            "name" : "protobuf",
            "buildsystem" : "autotools",
            "config-opts": [ "DIST_LANG=cpp" ],
            "cleanup" : [
                "/bin/protoc*",
                "/lib/libprotoc*",
                "/lib/libprotobuf-lite*"
            ],
            "sources" : [
                {
                    "type" : "archive",
                    "url" : "https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz",
                    "sha256" : "77ad26d3f65222fd96ccc18b055632b0bfedf295cb748b712a98ba1ac0b704b2"
                }
            ]
        },
    	{
    	    "name" : "protobuf-c",
    	    "buildsystem" : "autotools",
    	    "sources" : [
    	    	{
    	    	    "type" : "archive",
    	    	    "url"  : "https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.1/protobuf-c-1.4.1.tar.gz",
    	    	    "sha256" : "4cc4facd508172f3e0a4d3a8736225d472418aee35b4ad053384b137b220339f"
    	    	}
    	    ]
    	},
    	{
    	    "name" : "libshumate",
    	    "buildsystem" : "meson",
    	    "build-options": {
                "env": {
                   "GI_TYPELIB_PATH": "/app/lib/girepository-1.0:/app/lib64/girepository-1.0:/app/lib64"
	         }
	     },
    	    "config-opts" : [
    	    	"-Ddemos=false",
    	    	"-Dvapi=false",
    	    	"-Dgtk_doc=true"
    	    ],
    	    "sources" : [
    	   	{
    	   	    "type" : "git",
    	   	    "url"  : "https://gitlab.gnome.org/GNOME/libshumate.git",
    	   	    "branch" : "main"
    	   	}
    	    ],
    	    "post-install": [
               "ln -s /app/lib64/libshumate-1.0.so.1 /app/lib/libshumate-1.0.so.1",
               "ln -s /app/lib64/libshumate-1.0.so /app/lib/libshumate-1.0.so"
            ]
    	},
        {
            "name" : "loramap",
            "builddir" : true,
            "buildsystem" : "meson",
            "sources" : [
                {
                    "type" : "git",
                    "url" : "file:///home/wp2/Projects"
                }
            ]
        }
    ]
}

*** My only problem now is that Is that I cannot use it in my window.ui file

Try to register the class you want to use before building the template with: GObject.type_register(Shumate.SimpleMap)