From 565bf9d95b2f17cd1a8e76ad76cfcd1555d8f53c Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 5 Jan 2024 16:39:27 -0800 Subject: [PATCH 1/5] update to add version string to package (needs testing) --- src/python/library/tritonclient/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python/library/tritonclient/__init__.py b/src/python/library/tritonclient/__init__.py index 0fe49ac32..674b238f1 100755 --- a/src/python/library/tritonclient/__init__.py +++ b/src/python/library/tritonclient/__init__.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright 2023-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -25,3 +25,9 @@ # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +from importlib.metadata import version + +__version__ = version("tritonclient") + +del version From 4c1ed337707b8f441c9e31d691127dce1b818a48 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 5 Jan 2024 16:44:37 -0800 Subject: [PATCH 2/5] update to guard in case package not installed --- src/python/library/tritonclient/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/python/library/tritonclient/__init__.py b/src/python/library/tritonclient/__init__.py index 674b238f1..a19914f30 100755 --- a/src/python/library/tritonclient/__init__.py +++ b/src/python/library/tritonclient/__init__.py @@ -26,8 +26,13 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -from importlib.metadata import version +from importlib.metadata import PackageNotFoundError, version -__version__ = version("tritonclient") +__version__ = "UNKNOWN" + +try: + __version__ = version("tritonclient") +except PackageNotFoundError: + pass del version From a0a4552e9322e3c9d56b2d328c52e6bd92001012 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 5 Jan 2024 16:46:35 -0800 Subject: [PATCH 3/5] remove imported class --- src/python/library/tritonclient/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/library/tritonclient/__init__.py b/src/python/library/tritonclient/__init__.py index a19914f30..8e340a25a 100755 --- a/src/python/library/tritonclient/__init__.py +++ b/src/python/library/tritonclient/__init__.py @@ -36,3 +36,4 @@ pass del version +del PackageNotFoundError From 2dc4dba8d97b5c5ddbe9d85d6c1f42b8b0f7be08 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 5 Jan 2024 16:49:49 -0800 Subject: [PATCH 4/5] updated with comment --- src/python/library/tritonclient/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python/library/tritonclient/__init__.py b/src/python/library/tritonclient/__init__.py index 8e340a25a..824c4e97d 100755 --- a/src/python/library/tritonclient/__init__.py +++ b/src/python/library/tritonclient/__init__.py @@ -33,6 +33,7 @@ try: __version__ = version("tritonclient") except PackageNotFoundError: + # ignore if not an installed package pass del version From cfafae11ad6198a502ad4dba8d5779dacbd52834 Mon Sep 17 00:00:00 2001 From: nnshah1 Date: Fri, 5 Jan 2024 16:53:31 -0800 Subject: [PATCH 5/5] update with comment --- src/python/library/tritonclient/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/library/tritonclient/__init__.py b/src/python/library/tritonclient/__init__.py index 824c4e97d..7606d2179 100755 --- a/src/python/library/tritonclient/__init__.py +++ b/src/python/library/tritonclient/__init__.py @@ -30,10 +30,10 @@ __version__ = "UNKNOWN" +# unknown version if package is not installed try: __version__ = version("tritonclient") except PackageNotFoundError: - # ignore if not an installed package pass del version