From 36d6838c390ae7ac20a938908411b47bf323cece Mon Sep 17 00:00:00 2001 From: soshiharami Date: Thu, 19 Sep 2024 16:21:15 +0900 Subject: [PATCH] fix: pkg_resources has been deprecated and changed importlib Signed-off-by: soshiharami --- pymilvus/client/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pymilvus/client/__init__.py b/pymilvus/client/__init__.py index 800d36b25..c84910369 100644 --- a/pymilvus/client/__init__.py +++ b/pymilvus/client/__init__.py @@ -3,16 +3,18 @@ import subprocess from contextlib import suppress -from pkg_resources import DistributionNotFound, get_distribution +try: + from importlib.metadata import version, PackageNotFoundError +except ImportError: + # For Python versions < 3.8 + from importlib_metadata import version, PackageNotFoundError log = logging.getLogger(__name__) - __version__ = "0.0.0.dev" - -with suppress(DistributionNotFound): - __version__ = get_distribution("pymilvus").version +with suppress(PackageNotFoundError): + __version__ = version("pymilvus") def get_commit(version: str = "", short: bool = True) -> str: