make systemd support an optional extra

only install sdnotify and systemd-python when the "systemd" extra is requested
This commit is contained in:
Sam Schott 2019-09-15 12:43:12 +01:00
parent 882d1e8f17
commit a9f4fbd8e0
3 changed files with 14 additions and 8 deletions

View File

@ -42,12 +42,17 @@ IS_NOTIFY = os.getenv("NOTIFY_SOCKET", "") # set by systemd
IS_SYSTEMD = os.getenv("INVOCATION_ID", "") # set by systemd
if IS_SYSTEMD:
from systemd import journal
try:
from systemd import journal
except ImportError:
IS_SYSTEMD = False
if IS_NOTIFY:
import sdnotify
system_notifier = sdnotify.SystemdNotifier()
print("running under systemd as type=notify")
try:
import sdnotify
system_notifier = sdnotify.SystemdNotifier()
except ImportError:
IS_NOTIFY = False
# ========================================================================================
# Logging setup

View File

@ -7,5 +7,5 @@ u-msgpack-python
keyring>=19.0.0
keyrings.alt>=3.0.0
Pyro4
systemd-python; platform_system == 'Linux'
sdnotify; platform_system == 'Linux'
systemd-python
sdnotify

View File

@ -56,9 +56,10 @@ setup(
"requests",
"u-msgpack-python",
"watchdog",
"systemd-python; platform_system == 'Linux'",
"sdnotify; platform_system == 'Linux'",
],
extras_require={
"systemd": ["systemd-python", "sdnotify"],
},
zip_safe=False,
entry_points={
"console_scripts": ["maestral=maestral.cli:main"],