Skip to content

Commit

Permalink
Fix DeprecationWarning: pkg_resources is deprecated as an API
Browse files Browse the repository at this point in the history
  • Loading branch information
Obijuan committed Feb 12, 2024
1 parent 5096eff commit 723797c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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


cenv: ## Create the virtual-environment and update dependencies
Expand Down
4 changes: 4 additions & 0 deletions apio/managers/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def process_arguments(args, resources): # noqa
var_idcode = args.get("idcode")
var_verbose = args.get("verbose")
var_topmodule = args.get("top-module")

# -- No user arguments given
else:
var_board = None
var_arch = None
Expand All @@ -45,6 +47,8 @@ def process_arguments(args, resources): # noqa
var_verbose = {}
var_topmodule = None

print(f"DEBUG!!!! TOP-MODULE: {var_topmodule}")

if var_board:
if isfile("apio.ini"):
click.secho("Info: ignore apio.ini board", fg="yellow")
Expand Down
7 changes: 3 additions & 4 deletions apio/managers/scons.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
from os.path import isfile
from pathlib import Path

import importlib.metadata
import click

import pkg_resources
import semantic_version

from apio import util
Expand Down Expand Up @@ -270,7 +269,7 @@ def check_pip_packages(self, board_data):
try:
# Check pip_package version
spec = semantic_version.Spec(all_pip_packages.get(pip_pkg, ""))
pkg_version = pkg_resources.get_distribution(pip_pkg).version
pkg_version = importlib.metadata.version(pip_pkg)
version = semantic_version.Version(pkg_version)
if not spec.match(version):
click.secho(
Expand All @@ -284,7 +283,7 @@ def check_pip_packages(self, board_data):
fg="yellow",
)
raise ValueError("Incorrect version number")
except pkg_resources.DistributionNotFound as exc:
except importlib.metadata.PackageNotFoundError as exc:
click.secho(f"Error: '{pip_pkg}' is not installed", fg="red")
click.secho(
"Please run:\n" f" pip install -U apio[{pip_pkg}]",
Expand Down

0 comments on commit 723797c

Please sign in to comment.