Skip to content

Commit bb52fe1

Browse files
committed
py: drop importlib.resources
Signed-off-by: Filipe Laíns <lains@riseup.net>
1 parent 0df3bfc commit bb52fe1

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ requires-python = '>= 3.8'
3535
dependencies = [
3636
'colorama; os_name == "nt"',
3737
'importlib_metadata; python_version < "3.10"',
38-
'importlib_resources; python_version < "3.10"',
3938
]
4039

4140
[project.optional-dependencies]

src/pkgconf/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
if sys.version_info >= (3, 10):
2222
import importlib.metadata as importlib_metadata
23-
import importlib.resources as importlib_resources
2423
else:
2524
import importlib_metadata
26-
import importlib_resources
2725

2826

2927
__version__ = '2.1.1-8'
@@ -54,9 +52,10 @@ def get_executable() -> pathlib.Path:
5452
else:
5553
raise NotImplementedError
5654

57-
executable = pathlib.Path(importlib_resources.files('pkgconf') / '.bin' / executable_name)
58-
if executable.exists():
59-
return executable
55+
for path in __path__:
56+
executable = pathlib.Path(path) / '.bin' / executable_name
57+
if executable.exists():
58+
return executable
6059

6160
warnings.warn('Bundled pkgconf not found, using the system executable', stacklevel=2)
6261
executable = _get_system_executable()
@@ -69,9 +68,10 @@ def get_executable() -> pathlib.Path:
6968

7069
def _get_module_paths(name: str) -> Sequence[str]:
7170
module = importlib.import_module(name)
72-
if 'NamespacePath' in module.__path__.__class__.__name__:
71+
if isinstance(module.__path__, list) or 'NamespacePath' in module.__path__.__class__.__name__:
7372
return list(module.__path__)
74-
return [os.fspath(importlib_resources.files(name))]
73+
assert isinstance(module.__path__, str), module.__path__
74+
return [module.__path__]
7575

7676

7777
def get_pkg_config_path() -> Sequence[str]:

src/pkgconf/diagnose.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import importlib.metadata
2-
import importlib.resources
32
import os
43

54
import pkgconf
@@ -13,7 +12,7 @@ def report() -> None:
1312
for entry in entrypoints:
1413
print(f' {entry.name}:')
1514
print(f' value: {entry.value}')
16-
print(f' path: {os.fspath(importlib.resources.files(entry.value))}')
15+
print(f' paths: {pkgconf._get_module_paths(entry.value)}')
1716

1817
print(f'PKG_CONFIG_PATH: {os.pathsep.join(pkgconf.get_pkg_config_path())}')
1918

0 commit comments

Comments
 (0)