Skip to content

Commit

Permalink
Use importlib.metadata rather than pkg_resources (#97)
Browse files Browse the repository at this point in the history
* Use importlib.metadata rather than pkg_resources for dynamic version metadata

Co-authored-by: Max Jones <[email protected]>
  • Loading branch information
norlandrhagen and maxrjones authored Oct 6, 2022
1 parent 57cb69c commit c92e7d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions xbatcher/__init__.py
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit c92e7d5

Please sign in to comment.