wakepy
wakepy copied to clipboard
Consider making D-Bus support install optional
Wakepy has one dependency on linux: jeepney, which provides dbus support. There are yet no D-Bus free methods on linux, but there is a ticket (https://github.com/fohrloop/wakepy/issues/64) for searching for such methods on GNOME.
It could be possible to either: A) Make just the necessities install by default and have special options for adding something. B) Make everything install by default and have special options for leaving something out
Alternative A1
Consider making the jeepney dependency optional. This means,
pip install wakepy
would install only wakepy and nothing else, ever. Trying to use wakepy when non-DBus based methods are not available, would not succeed:
with keep.presenting() as k:
if not k.success:
print('Failed setting keepawake')
Installing:
pip install wakepy[dbus]
would install the supported dbus package (jeepney).
Pros:
- Installing wakepy would not need any dependencies
Cons:
- Wakepy does not work without the extras on all systems. This is an inconvenience, although it might be possible to find a set of non-DBus based methods?
Alternative B1
Keep installing a dbus python package by default when running
pip install wakepy
Users can opt-out from the dbus with
pip install wakepy --no-deps
Pros:
- Wakepy would work out of the box with easy to remember "pip install" name in more use cases
Cons:
- Not possible to determine
--no-deps
in requirements.txt (or setup.py?); Users wanting to opt-out need to install wakepy separately. - Opting out from dbus will opt-out from anything else (if something else needed some day?); this will probably not work well with
pip install wakepy[some-extra]
Alternative B2
Ideally, pip install wakepy
would install wakepy with DBus and there would be another extras which would remove the dbus python package dependency:
pip install wakepy[no-dbus]
This would be super handy as only experienced users might want to drop out this dependency. Unfortunately this does not seem to be supported by pip.
Pros:
- The cleanest solution?
Cons:
- Currently technically impossible.
Alternative B3
Taken from a SO answer: Use environment variables to determine the D-Bus need. It could be either
NODBUS=1
or making use of the DBUS_SESSION_BUS_ADDRESS
which should be set in most of the cases if D-Bus is available (if that is set, install D-Bus dependencies automatically, otherwise not). The example had a setup.py
file like this:
import os
from setuptools import setup
install_requires_base = [...]
setup(
...
install_requires=install_requires_base + ([] if os.getenv('NODBUS', False) else ['jeepney']),
...
)
I'm not sure if this would be possible with pyproject.toml or not.
Pros:
- Simple for average user, but also possible to opt-out for some extras.
Cons:
- Uses setup.py. Already transitioned to pyproject.toml, and no wishes to go back to setup.py if not absolutely required. Pyproject.toml has wider range of support, for example, for automatic dependency / reverse dependency resolution.
Alternative B4
Make
pip install wakepy
to install the default set of dependencies. Jeepney (or some other dbus python package) would be automatically included on systems like linux. This is because an average user should not have to think more than pip install wakepy
. Behind the scenes this would install some wakepy-vanilla
which is the base version and then for example jeepney
for dbus. In the future, this default set could evolve, but users could rely on the fact that anything needed for the typical use case is installed automaticlaly. This would not be same as installing "ALL" possible extras, like some move-mouse-package
(does not exist). Then, power users could then use
pip install wakepy-vanilla
For installing the vanilla version, or even using wakepy-vanilla[dbus]
for just dbus extras.
Motivation
- Most of the users (the average user) does not want to read out the documentation to make the package work with dbus based methods. The barrier for installing and using wakepy should be as low as possible to the average user.
- Wakepy should work out of the box on linux when dbus-based methods are required. As wakepy won't raise an Exception on unsuccesful wakelock set, this is even more important! It would not feel nice for the user to find out that
pip install wakepy
did not install a required package for their system and that when setting the wakelock, there was no exceptions and they have to dig out the documentation to see why their system is still going to sleep. - Power users, on the other hand, know how to read documentation and how to tweak their install scripts or requirements file. If a power user knows they will not need dbus, they can opt-out. Opting out can be more difficult than opting in, as it is not the default route, and people wanting to opt-out know what they're doing.
Pros:
- Everything is simple for the average user
- Everything is possible for the power user
Cons:
- Have to built two packages: wakepy and wakepy-vanilla.
Edit: Renamed alternatives (A, B, C, D) to (A1, B1, B2, B3). Added alternative B4.
Current conclusions
I'm leaning towards deciding the path B, more specifically to option B4.
A1: This makes the most common path more complex for making the path for power-users easier. B1: Not an option as not possible to use in requirements.txt/setup.py. B2: Not technically possible as not supported by pip B3: Not intriguing as not supported(?) by pyproject.toml B4: Makes most common path easiest for the (average) user. Makes less common options possible for the power-users.
I would like to release the 0.8.0 as soon as possible, and making decision about this can wait a bit longer. If dbus library (jeepney) install is made optional, that must be done only after there are some working methods on linux which do not require dbus. More methods will be added in the subsequent releases. Removing this from 0.8.0 milestone.