Skip to content

Commit 788c3da

Browse files
committed
completely remove importlib_resources dependency, rely on stdlib instead
1 parent 3508271 commit 788c3da

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ classifiers = [
2525
requires-python = ">=3.7"
2626
dependencies = [
2727
"packaging",
28-
"importlib_resources",
2928
"dbus-next;sys_platform=='linux'",
3029
"rubicon-objc;sys_platform=='darwin'",
3130
"winsdk==1.0.0b9;sys_platform=='win32'",

src/desktop_notifier/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,30 @@
1010
import logging
1111
from enum import Enum
1212
from collections import deque
13+
from pathlib import Path
1314
from typing import (
1415
Dict,
1516
Callable,
1617
Any,
1718
Deque,
1819
List,
1920
Sequence,
21+
ContextManager,
2022
)
21-
from pathlib import Path
2223

23-
from importlib_resources import files, as_file
24+
try:
25+
from importlib.resources import as_file, files
26+
27+
def resource_path(package: str, resource: str) -> ContextManager[Path]:
28+
return as_file(files(package) / resource)
29+
30+
except ImportError:
31+
from importlib.resources import path as resource_path
2432

2533

2634
logger = logging.getLogger(__name__)
2735

28-
PYTHON_ICON_PATH: Path = as_file(
29-
files("desktop_notifier.resources").joinpath("python.png") # type: ignore
30-
).__enter__()
36+
PYTHON_ICON_PATH = resource_path("desktop_notifier.resources", "python.png").__enter__()
3137

3238

3339
class AuthorisationError(Exception):

0 commit comments

Comments
 (0)