From f8f245cc3c05923ab440f7110d91057218845ec9 Mon Sep 17 00:00:00 2001 From: "Sean M. Law" <7473521+seanlaw@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:47:01 -0500 Subject: [PATCH] Removed pkg_resources as a dependency (#952) --- stumpy/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stumpy/__init__.py b/stumpy/__init__.py index 24cc9bf82..76a5cfbad 100644 --- a/stumpy/__init__.py +++ b/stumpy/__init__.py @@ -1,7 +1,8 @@ import os.path +from importlib.metadata import distribution +from site import getsitepackages from numba import cuda -from pkg_resources import DistributionNotFound, get_distribution from .aamp import aamp # noqa: F401 from .aamp_mmotifs import aamp_mmotifs # noqa: F401 @@ -182,14 +183,15 @@ gpu_aamp_stimp.__doc__ = ast.get_docstring(cd) try: - _dist = get_distribution("stumpy") + # _dist = get_distribution("stumpy") + _dist = distribution("stumpy") # Normalize case for Windows systems - dist_loc = os.path.normcase(_dist.location) + dist_loc = os.path.normcase(getsitepackages()[0]) here = os.path.normcase(__file__) if not here.startswith(os.path.join(dist_loc, "stumpy")): # not installed, but there is another version that *is* - raise DistributionNotFound # pragma: no cover -except DistributionNotFound: # pragma: no cover + raise ModuleNotFoundError # pragma: no cover +except ModuleNotFoundError: # pragma: no cover __version__ = "Please install this project with setup.py" else: # pragma: no cover __version__ = _dist.version