fohrloop / wakepy

Cross-platform keep-awake with python
MIT License
170 stars 13 forks source link

Consider making D-Bus support install optional #65

Open fohrloop opened 8 months ago

fohrloop commented 8 months ago

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:

Cons:

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:

Cons:

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:

Cons:

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:

Cons:

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

Pros:

Cons:

Edit: Renamed alternatives (A, B, C, D) to (A1, B1, B2, B3). Added alternative B4.

fohrloop commented 8 months ago

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.

fohrloop commented 6 months ago

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.