Why Does a Python + GTK Application Create .dbus-keyrings on Windows?
I noticed that running a Python + GTK on Windows application created :
%USERPROFILE%\.dbus-keyrings\org_gtk_gdbus_general
This application does not obviously use D-Bus, so I wanted to find out what was actually causing the file to appear.
Finding the trigger
Importing GTK or GIO alone does not create the file. Neither does
Gtk.init_check(), or constructing a Gtk.Application.
Initially, entering the Gtk.Application event loop appeared to
be the trigger. However, further experiments showed that this was only
because GApplication.run() calls register().
The actual minimal reproducer is:
from gi.repository import Gio
app = Gio.Application(flags=Gio.ApplicationFlags.NON_UNIQUE)
app.register(None)
This creates the same 78-byte
org_gtk_gdbus_general file, without GTK, an application ID,
or a main loop.
I also confirmed that a plain Gio.Application behaves the same
way as Gtk.Application. Using
Gio.ApplicationFlags.NON_UNIQUE and omitting the application ID
does not prevent the file from being created.
Conclusion
The file is a GDBus authentication keyring created as a side effect of
GApplication.register(). The relevant path is essentially:
GApplication.register()
→ session D-Bus connection
→ GDBus authentication
→ org_gtk_gdbus_general keyring
So the application does not need to explicitly use D-Bus for this file to appear.
Registering a GApplication is sufficient.
Test environment
- PyGObject:
3.55.0 - GTK:
3.24.51 - Windows:
10.0.26220 - Python:
3.12.9, 32-bit (MSC v.1944)