Subject: bug#41025: blueman does not start

From: Pierre Neidhardt <[email-masked]>
Date: Mon, 04 May 2020 10:47:22 +0200

Sorry if I misled you with the ellipsis.  You need to add
/lib/python3.7/site-packages without the "blueman" part.

With the definition below I can start blueman-services.  But all
programs report that blueman-applet fails.
Indeed, blueman-applet fails with

--8<---------------cut here---------------start------------->8---
blueman-applet version 2.1.2 starting
blueman-applet 10.41.17 ERROR    PluginManager:90 load_plugin: Unable to load plugin module NMPANSupport
Traceback (most recent call last):
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/NetworkManager.py", line 6, in <module>
    gi.require_version('NM', '1.0')
  File "/gnu/store/y4qwsw06ynvw3fjk2lrspp89mfmjzj5i-python-pygobject-3.28.3/lib/python3.7/site-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace NM not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/PluginManager.py", line 88, in load_plugin
    importlib.import_module(self.module_path.__name__ + ".%s" % plugin)
  File "/gnu/store/c0ysvb6s92kwwnmkgdhnspllxvd3f231-python-3.7.4/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/plugins/applet/NMPANSupport.py", line 3, in <module>
    from blueman.main.NetworkManager import NMPANConnection
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/NetworkManager.py", line 8, in <module>
    raise ImportError('NM python bindings not found.')
ImportError: NM python bindings not found.
blueman-applet 10.41.17 ERROR    PluginManager:90 load_plugin: Unable to load plugin module NMDUNSupport
Traceback (most recent call last):
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/NetworkManager.py", line 6, in <module>
    gi.require_version('NM', '1.0')
  File "/gnu/store/y4qwsw06ynvw3fjk2lrspp89mfmjzj5i-python-pygobject-3.28.3/lib/python3.7/site-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace NM not available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/PluginManager.py", line 88, in load_plugin
    importlib.import_module(self.module_path.__name__ + ".%s" % plugin)
  File "/gnu/store/c0ysvb6s92kwwnmkgdhnspllxvd3f231-python-3.7.4/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/plugins/applet/NMDUNSupport.py", line 3, in <module>
    from blueman.main.NetworkManager import NMDUNConnection
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/main/NetworkManager.py", line 8, in <module>
    raise ImportError('NM python bindings not found.')
ImportError: NM python bindings not found.
Traceback (most recent call last):
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/plugins/applet/StatusIcon.py", line 116, in _on_plugins_changed
    launch('blueman-tray', icon_name='blueman', sn=False)
  File "/gnu/store/1f9x9hwfjpkq4h79dwsi06m3zrzdm8fp-blueman-2.1.2/lib/python3.7/site-packages/blueman/Functions.py", line 137, in launch
    launched = appinfo.launch(files, context)
GLib.Error: g-exec-error-quark: Failed to execute child process “gio-launch-desktop” (No such file or directory) (8)
blueman-applet 10.41.17 WARNING  DiscvManager:109 update_menuitems: warning: Adapter is None
killed
--8<---------------cut here---------------end--------------->8---

It seems that network-manager bindings for python are missing.
We may need to package this: https://github.com/seveas/python-networkmanager

Maybe I'm not starting it the right way.
Have you got blueman to work on your system?  Are you using a foreign
distribution?

New package definition:

--8<---------------cut here---------------start------------->8---
(define-public blueman
  (package
    (name "blueman")
    (version "2.1.2")
    (source
     (origin
       (method url-fetch)
       (uri
        (string-append "https://github.com/blueman-project/blueman/releases/"
                       "download/2.1.2/blueman-2.1.2.tar.gz"))
       (sha256
        (base32 "0wamxdw36c8i3aqwmja5q70fajqwd7inpkvlpkldd54wdxbcd38d"))))
    (build-system glib-or-gtk-build-system)
    (arguments
     `(#:configure-flags
       (list
        "--enable-polkit"
        "--disable-appindicator"         ; Deprecated
        "--with-systemdsystemunitdir=no" ; Not required
        "--with-systemduserunitdir=no")  ; Not required
       #:phases
       (modify-phases %standard-phases
         ;; Python references are not being patched in patch-phase of build;
         ;; despite using python-wrapper as input. So patching them manually.
         (add-after 'unpack 'patch-python-references
           (lambda* (#:key inputs #:allow-other-keys)
             (for-each
              (lambda (name)
                (substitute* (format #f "apps/blueman-~a.in" name)
                  (("@PYTHON@") (string-append (assoc-ref inputs "python")
                                               "/bin/python3.7"))))
              '("adapters" "applet" "assistant" "manager" "mechanism" "report"
                "rfcomm-watcher" "sendto" "services" "tray"))
             #t))
         (add-after 'glib-or-gtk-wrap 'wrap-blueman
           (lambda* (#:key outputs #:allow-other-keys)
             (let* ((out (assoc-ref outputs "out"))
                    (bin (string-append out "/bin/blueman-"))
                    (lib (string-append out "/lib/python3.7/site-packages/")))
               (for-each
                (lambda (program)
                  (pk program)
                  (pk (string-append bin program))
                  (wrap-program (string-append bin program)
                    `("PYTHONPATH" = (,(getenv "PYTHONPATH")
                                      ,lib))
                    `("GI_TYPELIB_PATH" = (,(getenv "GI_TYPELIB_PATH")))))
                '("adapters" "applet" "assistant" "manager" "report"
                  "sendto" "services" "tray"))
               #t))))))
    (native-inputs
     `(("cython" ,python-cython)
       ("glib:bin" ,glib "bin")
       ("gtk+:bin" ,gtk+ "bin")
       ("intltool" ,intltool)
       ("libtool" ,libtool)
       ("pkg-config" ,pkg-config)))
    (inputs
     `(("adwaita-icon-theme" ,adwaita-icon-theme)
       ("bluez" ,bluez)
       ("dbus" ,dbus)
       ("gdkpixbuf" ,gdk-pixbuf)
       ("glib" ,glib)
       ("gtk+" ,gtk+)
       ("iproute2" ,iproute)
       ("net-tools" ,net-tools)
       ("pango" ,pango)
       ("polkit" ,polkit)
       ("pulseaudio" ,pulseaudio)
       ("pycairo" ,python-pycairo)
       ("pygobject" ,python-pygobject)
       ("python" ,python-wrapper)
       ("libnm" ,libnma)))
    (synopsis "GTK+ Bluetooth manager")
    (description "Blueman is a Bluetooth management utility using the Bluez
D-Bus backend.  It is designed to be easy to use for most common Bluetooth
tasks.")
    (home-page "https://github.com/blueman-project/blueman")
    (license license:gpl3+)))
--8<---------------cut here---------------end--------------->8---

--
Pierre Neidhardt
https://ambrevar.xyz/