Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider making D-Bus support install optional #65

Open
fohrloop opened this issue Oct 26, 2023 · 3 comments
Open

Consider making D-Bus support install optional #65

fohrloop opened this issue Oct 26, 2023 · 3 comments
Labels
Type: Feature New feature or request
Milestone

Comments

@fohrloop
Copy link
Owner

fohrloop commented Oct 26, 2023

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 (#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.

@fohrloop fohrloop added this to the wakepy 0.8.0 milestone Oct 26, 2023
@fohrloop
Copy link
Owner Author

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
Copy link
Owner Author

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.

@fohrloop fohrloop removed this from the wakepy 0.8.0 milestone Jan 16, 2024
@fohrloop fohrloop added the Type: Feature New feature or request label Apr 29, 2024
@fohrloop
Copy link
Owner Author

fohrloop commented Sep 24, 2024

Currently wakepy supports KDE + GNOME + "freedesktop compiant DEs" (those which implement the org.freedesktop.PowerManagement and org.freedesktop.ScreenSaver dbus APIs.

This could be a path for wakepy being dependency free (optionally depending on jeepney):

The above would give support already to 82.1% of linux desktop users (if linux-hardware.org stats are taken as truth). The unsupported portion would be 7.2% (LXQt, i3, COSMIC, Hyprland + others), and unknown portion would be 10.7%.

Another (additional) thing to consider is the possibility to use the dbus-python package (import name: dbus), which comes installed on many systems. This would also use the search for system packages, add the folder to sys.path and import. This way, in practically all cases jeepney would not be a requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant