diff --git a/jaraco/home/trap-watcher.py b/jaraco/home/trap-watcher.py index 8eea59b..3579f45 100644 --- a/jaraco/home/trap-watcher.py +++ b/jaraco/home/trap-watcher.py @@ -1,17 +1,20 @@ +import sys +from typing import TYPE_CHECKING + +if sys.platform != "darwin" and TYPE_CHECKING: + assert False # https://github.com/python/mypy/issues/9025#issuecomment-1087270212 + import asyncio import pathlib import subprocess -import sys import keyring -import rumps import typer import victor_smart_kill as vsk from . import contact from .compat.py38 import resources - app = typer.Typer() @@ -63,4 +66,12 @@ def main(ctx: typer.Context, update: bool = False): TrapWatch() -__name__ == '__main__' and app() +if __name__ == '__main__': + # This check and import must be delayed as to not break pytest discovery + if sys.platform != "darwin": + print("This app is only available on MacOS.") + sys.exit(1) + + import rumps + + app() diff --git a/newsfragments/3.bugfix.rst b/newsfragments/3.bugfix.rst new file mode 100644 index 0000000..f5f0bcc --- /dev/null +++ b/newsfragments/3.bugfix.rst @@ -0,0 +1 @@ +Fix build on non-Darwin machines -- by :user:`Avasam` diff --git a/pyproject.toml b/pyproject.toml index 0222de2..ac5fe3a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ 'importlib_resources; python_version < "3.9"', "jaraco.compat>=4.1", "tempora>=5.7", - "rumps", + "rumps; sys_platform == 'darwin'", "typer", ] dynamic = ["version"]