diff --git a/setup.cfg b/setup.cfg index 539a1ba..e74bfda 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ select = B,C,E,F,W,T4,B9 [isort] known_first_party=xbatcher -known_third_party=numpy,pkg_resources,pytest,setuptools,sphinx_autosummary_accessors,tensorflow,torch,xarray +known_third_party=numpy,pytest,setuptools,sphinx_autosummary_accessors,tensorflow,torch,xarray multi_line_output=3 include_trailing_comma=True force_grid_wrap=0 diff --git a/xbatcher/__init__.py b/xbatcher/__init__.py index 788b309..6bdb880 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -1,11 +1,14 @@ -from pkg_resources import DistributionNotFound, get_distribution +from importlib.metadata import ( + PackageNotFoundError as _PackageNotFoundError, + version as _version, +) from .accessors import BatchAccessor # noqa: F401 from .generators import BatchGenerator # noqa: F401 from .util.print_versions import show_versions # noqa: F401 try: - __version__ = get_distribution(__name__).version -except DistributionNotFound: # noqa: F401; pragma: no cover + __version__ = _version(__name__) +except _PackageNotFoundError: # package is not installed - pass + __version__ = 'unknown'