Skip to content

Commit 723797c

Browse files
committed
Fix DeprecationWarning: pkg_resources is deprecated as an API
1 parent 5096eff commit 723797c

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
deps: ## Install dependencies for apio development
44
python -m pip install --upgrade pip
5-
pip install flit black flake8 pylint tox pytest semantic-version pyserial
5+
pip install flit black flake8 pylint tox pytest semantic-version pyserial importlib-metadata
66

77

88
cenv: ## Create the virtual-environment and update dependencies

apio/managers/arguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ def process_arguments(args, resources): # noqa
3434
var_idcode = args.get("idcode")
3535
var_verbose = args.get("verbose")
3636
var_topmodule = args.get("top-module")
37+
38+
# -- No user arguments given
3739
else:
3840
var_board = None
3941
var_arch = None
@@ -45,6 +47,8 @@ def process_arguments(args, resources): # noqa
4547
var_verbose = {}
4648
var_topmodule = None
4749

50+
print(f"DEBUG!!!! TOP-MODULE: {var_topmodule}")
51+
4852
if var_board:
4953
if isfile("apio.ini"):
5054
click.secho("Info: ignore apio.ini board", fg="yellow")

apio/managers/scons.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
from os.path import isfile
1616
from pathlib import Path
1717

18+
import importlib.metadata
1819
import click
19-
20-
import pkg_resources
2120
import semantic_version
2221

2322
from apio import util
@@ -270,7 +269,7 @@ def check_pip_packages(self, board_data):
270269
try:
271270
# Check pip_package version
272271
spec = semantic_version.Spec(all_pip_packages.get(pip_pkg, ""))
273-
pkg_version = pkg_resources.get_distribution(pip_pkg).version
272+
pkg_version = importlib.metadata.version(pip_pkg)
274273
version = semantic_version.Version(pkg_version)
275274
if not spec.match(version):
276275
click.secho(
@@ -284,7 +283,7 @@ def check_pip_packages(self, board_data):
284283
fg="yellow",
285284
)
286285
raise ValueError("Incorrect version number")
287-
except pkg_resources.DistributionNotFound as exc:
286+
except importlib.metadata.PackageNotFoundError as exc:
288287
click.secho(f"Error: '{pip_pkg}' is not installed", fg="red")
289288
click.secho(
290289
"Please run:\n" f" pip install -U apio[{pip_pkg}]",

0 commit comments

Comments
 (0)