From 9b9aa386f6bbee252f6fc9fd38936866500fcbc4 Mon Sep 17 00:00:00 2001 From: Raphael Hagen Date: Fri, 23 Sep 2022 12:54:52 -0700 Subject: [PATCH 1/5] issue #89. Use importlib.metadata rather than pkg_resources --- setup.cfg | 2 +- xbatcher/__init__.py | 9 +-------- xbatcher/_version.py | 7 +++++++ 3 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 xbatcher/_version.py 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..3008cf0 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -1,11 +1,4 @@ -from pkg_resources import DistributionNotFound, get_distribution - +from ._version import __version__ # noqa: F401 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 - # package is not installed - pass diff --git a/xbatcher/_version.py b/xbatcher/_version.py new file mode 100644 index 0000000..c12e5d7 --- /dev/null +++ b/xbatcher/_version.py @@ -0,0 +1,7 @@ +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version(__name__) +except PackageNotFoundError: + # package is not installed + __version__ = 'unknown' From 25595fbe13902e343734705d6c10bab9fa152285 Mon Sep 17 00:00:00 2001 From: Raphael Hagen Date: Tue, 27 Sep 2022 09:37:49 -0700 Subject: [PATCH 2/5] moved version into __init__.py --- xbatcher/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/xbatcher/__init__.py b/xbatcher/__init__.py index 3008cf0..d9f18c7 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -1,4 +1,11 @@ -from ._version import __version__ # noqa: F401 +from importlib.metadata import PackageNotFoundError, version + from .accessors import BatchAccessor # noqa: F401 from .generators import BatchGenerator # noqa: F401 from .util.print_versions import show_versions # noqa: F401 + +try: + __version__ = version(__name__) +except PackageNotFoundError: + # package is not installed + __version__ = 'unknown' From ed7f863405c0fc95adad145565728f6d7e8c4282 Mon Sep 17 00:00:00 2001 From: Raphael Hagen Date: Fri, 30 Sep 2022 11:10:01 -0600 Subject: [PATCH 3/5] deleted old _version.py file --- xbatcher/_version.py | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 xbatcher/_version.py diff --git a/xbatcher/_version.py b/xbatcher/_version.py deleted file mode 100644 index c12e5d7..0000000 --- a/xbatcher/_version.py +++ /dev/null @@ -1,7 +0,0 @@ -from importlib.metadata import PackageNotFoundError, version - -try: - __version__ = version(__name__) -except PackageNotFoundError: - # package is not installed - __version__ = 'unknown' From 05e3cf04f03ca6276dd0274475350368a39bd6eb Mon Sep 17 00:00:00 2001 From: Raphael Hagen Date: Thu, 6 Oct 2022 10:03:17 -0600 Subject: [PATCH 4/5] Update xbatcher/__init__.py Co-authored-by: Max Jones --- xbatcher/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbatcher/__init__.py b/xbatcher/__init__.py index d9f18c7..eba4db5 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -5,7 +5,7 @@ from .util.print_versions import show_versions # noqa: F401 try: - __version__ = version(__name__) -except PackageNotFoundError: + __version__ = _version(__name__) +except _PackageNotFoundError: # package is not installed __version__ = 'unknown' From 9cb3652b599a37dbe373011365f60f5511fe9d74 Mon Sep 17 00:00:00 2001 From: Raphael Hagen Date: Thu, 6 Oct 2022 10:03:21 -0600 Subject: [PATCH 5/5] Update xbatcher/__init__.py Co-authored-by: Max Jones --- xbatcher/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xbatcher/__init__.py b/xbatcher/__init__.py index eba4db5..6bdb880 100644 --- a/xbatcher/__init__.py +++ b/xbatcher/__init__.py @@ -1,4 +1,7 @@ -from importlib.metadata import PackageNotFoundError, version +from importlib.metadata import ( + PackageNotFoundError as _PackageNotFoundError, + version as _version, +) from .accessors import BatchAccessor # noqa: F401 from .generators import BatchGenerator # noqa: F401