From 469ecfc7f3db0e64328312cde9759d6f5d080f6b Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Tue, 16 Apr 2024 16:56:35 +1000 Subject: [PATCH] add __version__ --- esmgrids/__init__.py | 7 +++++++ esmgrids/cli.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/esmgrids/__init__.py b/esmgrids/__init__.py index e69de29..8453fa6 100644 --- a/esmgrids/__init__.py +++ b/esmgrids/__init__.py @@ -0,0 +1,7 @@ +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("esmgrids") +except PackageNotFoundError: + # package is not installed + pass diff --git a/esmgrids/cli.py b/esmgrids/cli.py index 95a7fb0..dbe9834 100644 --- a/esmgrids/cli.py +++ b/esmgrids/cli.py @@ -1,6 +1,7 @@ import os import argparse +from esmgrids import __version__ from esmgrids.util import md5sum from esmgrids.mom_grid import MomGrid from esmgrids.cice_grid import CiceGrid @@ -24,7 +25,8 @@ def cice_from_mom(): # to-do: need to input package version here runcmd = ( - f"Created using esmgrid: cice_from_mom --ocean_hgrid={ocean_hgrid} --ocean_mask={ocean_mask} " + f"Created using esmgrid {__version__}: " + f"cice_from_mom --ocean_hgrid={ocean_hgrid} --ocean_mask={ocean_mask} " f"--cice_grid={cice_grid} --cice_kmt={cice_kmt}" ) provenance_metadata = {