[Debian 13/Trixie] psutil.users() always returns empty list
Summary
- OS: Debian 13 (Trixie)
- Architecture: amd64
- Psutil version: 7.0.0
- Python version: 3.13.3
- Type: new-api (I guess?)
Description
python3 -c 'import psutil;print(psutil.users())'
Always returns an empty list on Debian 13, without complaining. Reason probably being that Debian now compiles systemd without utmp support:
https://salsa.debian.org/systemd-team/systemd/-/blob/105837d0baad88ee7473261b418b1c72935af93c/debian/changelog#L483
This is a tricky issue. It means installing a new dep (apt-get install libsystemd-dev), which I've tried on my Linux Mint kernel 6.8.0, but some of these APIs are missing:
sd_get_sessions()
sd_session_get_uid()
sd_session_get_tty()
sd_session_get_remote_host()
sd_session_get_timestamp()
Maybe it's because they were introduced in a more recent libsystemd version? No idea. Regardless, it gets quite tricky because we have to check either at runtime, compile time, or both, whether they are available, whether to fallback on using the old implementation, etc. A pain in the ass...
See https://github.com/giampaolo/psutil/pull/2300.