Skip to content

Commit 67af8c9

Browse files
authored
Use importlib.metadata instead of pkg_resources
1 parent df3b165 commit 67af8c9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pytsql/__init__.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
"""`Pytsql` allows to run mssql sripts, typically run via GUIs, via CLI."""
22

3-
import pkg_resources
3+
import importlib.metadata
4+
import warnings
45

56
from .tsql import execute, executes
67

78
try:
8-
__version__ = pkg_resources.get_distribution(__name__).version
9-
except Exception:
9+
__version__ = importlib.metadata.version(__name__)
10+
except importlib.metadata.PackageNotFoundError as e: # pragma: no cover
11+
warnings.warn(f"Could not determine version of {__name__}\n{e!s}", stacklevel=2)
1012
__version__ = "unknown"
1113

14+
1215
__all__ = ["execute", "executes"]

0 commit comments

Comments
 (0)