Skip to content

Commit 7b80dfb

Browse files
committed
merge bitcoin#28347: replace deprecated pkg_resources with importlib.metadata
1 parent 04ac20a commit 7b80dfb

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

test/lint/lint-python.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
"""
1010

1111
import os
12-
import pkg_resources
1312
import subprocess
1413
import sys
1514

15+
from importlib.metadata import metadata, PackageNotFoundError
16+
17+
1618
DEPS = ['flake8', 'lief', 'mypy', 'pyzmq']
1719
MYPY_CACHE_DIR = f"{os.getenv('BASE_ROOT_DIR', '')}/test/.mypy_cache"
1820
FILES_ARGS = ['git', 'ls-files', '--','test/functional/*.py', 'contrib/devtools/*.py', ':(exclude)contrib/devtools/github-merge.py']
@@ -95,10 +97,10 @@
9597

9698

9799
def check_dependencies():
98-
working_set = {pkg.key for pkg in pkg_resources.working_set}
99-
100100
for dep in DEPS:
101-
if dep not in working_set:
101+
try:
102+
metadata(dep)
103+
except PackageNotFoundError:
102104
print(f"Skipping Python linting since {dep} is not installed.")
103105
exit(0)
104106

0 commit comments

Comments
 (0)