From 9d7401a15a91481f74c6310d283a37d90b63c553 Mon Sep 17 00:00:00 2001 From: aazedwick Date: Wed, 31 May 2023 14:56:00 -0500 Subject: [PATCH 1/7] Added __version__ method --- uxarray/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index e73f6d3f1..7af8a6675 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -1,2 +1,17 @@ from .grid import * from .helpers import * + + +def __version__(): + # Attempt to import the needed modules + try: + from importlib.metadata import version as version + except ImportError: + from importlib_metadata import version as version + + try: + __version = version("uxarray") + print(__version) + except AttributeError: + # Incase something happens, such as the library isn't installed + __version = "0000" From e92ab63a95003d6658ed2b8dfe245e2c6cf26686 Mon Sep 17 00:00:00 2001 From: aazedwick Date: Wed, 31 May 2023 15:45:41 -0500 Subject: [PATCH 2/7] Addressed changes requested --- uxarray/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index 7af8a6675..896a21168 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -3,6 +3,7 @@ def __version__(): + """Returns the version of uxarray currently installed.""" # Attempt to import the needed modules try: from importlib.metadata import version as version @@ -11,7 +12,8 @@ def __version__(): try: __version = version("uxarray") - print(__version) - except AttributeError: - # Incase something happens, such as the library isn't installed + except NameError: + # Placeholder version incase an error occurs, such as the library isn't installed __version = "0000" + + return __version From 80245224bbd48c0aed0198ec7302e9d9fa972332 Mon Sep 17 00:00:00 2001 From: aazedwick Date: Wed, 31 May 2023 16:10:50 -0500 Subject: [PATCH 3/7] Addressed changes requested from anissa111 --- uxarray/__init__.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index 896a21168..775d33ca9 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -1,19 +1,14 @@ from .grid import * from .helpers import * - - -def __version__(): - """Returns the version of uxarray currently installed.""" - # Attempt to import the needed modules - try: - from importlib.metadata import version as version - except ImportError: - from importlib_metadata import version as version - - try: - __version = version("uxarray") - except NameError: - # Placeholder version incase an error occurs, such as the library isn't installed - __version = "0000" - - return __version +# Sets the version of uxarray currently installed +# Attempt to import the needed modules +try: + from importlib.metadata import version as version +except ImportError: + from importlib_metadata import version as version + +try: + __version = version("uxarray") +except Exception: + # Placeholder version incase an error occurs, such as the library isn't installed + __version = "999" From 81356eaeed1ae633df5f117ba3c0ca9e15d0bc11 Mon Sep 17 00:00:00 2001 From: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com> Date: Wed, 31 May 2023 16:16:16 -0500 Subject: [PATCH 4/7] Update uxarray/__init__.py Co-authored-by: Anissa Zacharias --- uxarray/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index 775d33ca9..2998424ff 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -8,7 +8,7 @@ from importlib_metadata import version as version try: - __version = version("uxarray") + __version__ = version("uxarray") except Exception: # Placeholder version incase an error occurs, such as the library isn't installed - __version = "999" + __version__ = "999" From 5edf188e6e3c39810a433488a89d3fa0fc09a526 Mon Sep 17 00:00:00 2001 From: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com> Date: Wed, 31 May 2023 16:22:53 -0500 Subject: [PATCH 5/7] Updated Exception Name Co-authored-by: Anissa Zacharias --- uxarray/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index 2998424ff..ef3443d0b 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -4,7 +4,7 @@ # Attempt to import the needed modules try: from importlib.metadata import version as version -except ImportError: +except Exception: from importlib_metadata import version as version try: From c17832634c929d279f4650c2b3544a951c95b5df Mon Sep 17 00:00:00 2001 From: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com> Date: Wed, 31 May 2023 16:38:32 -0500 Subject: [PATCH 6/7] Update version variable name Co-authored-by: Anissa Zacharias --- uxarray/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index ef3443d0b..6cd9c4338 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -3,9 +3,9 @@ # Sets the version of uxarray currently installed # Attempt to import the needed modules try: - from importlib.metadata import version as version + from importlib.metadata import version as _version except Exception: - from importlib_metadata import version as version + from importlib_metadata import version as _version try: __version__ = version("uxarray") From 2105732c9eb7c18c598bec10993003d7085f7c1b Mon Sep 17 00:00:00 2001 From: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com> Date: Wed, 31 May 2023 16:45:41 -0500 Subject: [PATCH 7/7] Variable names updated to fit with previous change --- uxarray/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uxarray/__init__.py b/uxarray/__init__.py index 6cd9c4338..a1cfa76e0 100644 --- a/uxarray/__init__.py +++ b/uxarray/__init__.py @@ -8,7 +8,7 @@ from importlib_metadata import version as _version try: - __version__ = version("uxarray") + __version__ = _version("uxarray") except Exception: # Placeholder version incase an error occurs, such as the library isn't installed __version__ = "999"