Skip to content

Commit

Permalink
replace usages of pkg_resources with importlib.metadata
Browse files Browse the repository at this point in the history
add change log entry
  • Loading branch information
zacharyburnett committed Jul 18, 2024
1 parent b5e2131 commit e27a7cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- rename (fix typo) argument to `lcs_child_in_parent` in `CoordinateSystemManager.add_cs` \[{pull}`936`\].

- replace usages of ``pkg_resources`` with ``importlib.metadata`` [#941]

### Dependencies

- pin `weldx-widgets>=0.2.3` for viz \[{pull}`939`\].
Expand Down
4 changes: 2 additions & 2 deletions weldx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path

import asdf
import pkg_resources
import importlib.metadata
import yaml
from asdf.config import ResourceMappingProxy
from asdf.versioning import AsdfVersion, split_tag_version
Expand Down Expand Up @@ -175,7 +175,7 @@ def enable_quality_standard(name: str, version: AsdfVersion | str = None):
@staticmethod
def load_installed_standards():
"""Load all standards that are installed to the active virtual environment."""
for entry_point in pkg_resources.iter_entry_points("weldx.standard"):
for entry_point in importlib.metadata.entry_points()["weldx.standard"]:
standards = entry_point.load()()
if not isinstance(standards, list):
standards = [standards]
Expand Down
4 changes: 2 additions & 2 deletions weldx/tests/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
import pint
from pkg_resources import get_distribution
import importlib.metadata

from weldx.constants import Q_
from weldx.geometry import _vector_is_close as vector_is_close
Expand Down Expand Up @@ -130,7 +130,7 @@ def matrix_is_close(mat_a, mat_b, abs_tol=1e-9) -> bool:
return False

atol_unit = 1.0
if isinstance(mat_b, pint.Quantity) and get_distribution("pint").version >= "0.21":
if isinstance(mat_b, pint.Quantity) and tuple(int(part) for part in importlib.metadata.version("pint").split(".")) >= (0, 21):
atol_unit = mat_b.u

return np.all(np.isclose(mat_a, mat_b, atol=abs_tol * atol_unit)).__bool__()
4 changes: 2 additions & 2 deletions weldx/tests/transformations/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Any

import numpy as np
from pkg_resources import get_distribution
import importlib.metadata
from xarray import DataArray

import weldx.transformations as tf
Expand Down Expand Up @@ -79,7 +79,7 @@ def check_coordinate_system(
)

atol_unit = 1.0
if get_distribution("pint").version >= "0.21":
if tuple(int(part) for part in importlib.metadata.version("pint").split(".")) >= (0, 21):
atol_unit = coordinates_expected.u

assert np.allclose(
Expand Down

0 comments on commit e27a7cd

Please sign in to comment.