From fb352cfeec19cf5890906ad25097f47c6f9f472c Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Tue, 20 Apr 2021 10:26:23 -0600 Subject: [PATCH] Add __version__ (#208) Co-authored-by: Anderson Banihirwe --- cf_xarray/__init__.py | 8 ++++++++ setup.cfg | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cf_xarray/__init__.py b/cf_xarray/__init__.py index f9d08cce..a0a37531 100644 --- a/cf_xarray/__init__.py +++ b/cf_xarray/__init__.py @@ -1,2 +1,10 @@ +from pkg_resources import DistributionNotFound, get_distribution + from .accessor import CFAccessor # noqa from .helpers import bounds_to_vertices, vertices_to_bounds # noqa + +try: + __version__ = get_distribution("cf_xarray").version +except DistributionNotFound: + # package is not installed + __version__ = 'unknown' diff --git a/setup.cfg b/setup.cfg index 2236d52d..b0c2485d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,7 @@ skip_gitignore = true force_to_top = true default_section = THIRDPARTY known_first_party = cf_xarray -known_third_party = dask,matplotlib,numpy,pandas,pytest,setuptools,sphinx_autosummary_accessors,xarray +known_third_party = dask,matplotlib,numpy,pandas,pkg_resources,pytest,setuptools,sphinx_autosummary_accessors,xarray # Most of the numerical computing stack doesn't have type annotations yet. [mypy-affine.*]