Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use importlib.metadata rather than pkg_resources for version metadata #97

Merged
merged 6 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 4 additions & 4 deletions xbatcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import PackageNotFoundError, version
norlandrhagen marked this conversation as resolved.
Show resolved Hide resolved

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:
norlandrhagen marked this conversation as resolved.
Show resolved Hide resolved
# package is not installed
pass
__version__ = 'unknown'
7 changes: 7 additions & 0 deletions xbatcher/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version(__name__)
except PackageNotFoundError:
# package is not installed
__version__ = 'unknown'
weiji14 marked this conversation as resolved.
Show resolved Hide resolved