Skip to content

Commit 6c008a2

Browse files
committed
script: replace deprecated pkg_resources with importlib.metadata
in our python linter: ``` ./test/lint/lint-python.py:12: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html import pkg_resources ``` The importlib.metadata library was added in Python 3.8, which is currently our minimum-supported Python version. For more details about importlib.metadata, see https://docs.python.org/3/library/importlib.metadata.html
1 parent c9273f6 commit 6c008a2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/lint/lint-python.py

+6-4
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

@@ -99,10 +101,10 @@
99101

100102

101103
def check_dependencies():
102-
working_set = {pkg.key for pkg in pkg_resources.working_set}
103-
104104
for dep in DEPS:
105-
if dep not in working_set:
105+
try:
106+
metadata(dep)
107+
except PackageNotFoundError:
106108
print(f"Skipping Python linting since {dep} is not installed.")
107109
exit(0)
108110

0 commit comments

Comments
 (0)