Skip to content

Commit 69fdae7

Browse files
committed
Add sqlalchemy.__version__ attribute
1 parent b60b40a commit 69fdae7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ dependencies = [
8484
"backports.zoneinfo<1; python_version<'3.9'",
8585
"crate>=2,<3",
8686
"geojson<4,>=2.5",
87+
"importlib-metadata; python_version<'3.8'",
8788
"importlib-resources; python_version<'3.9'",
8889
"sqlalchemy<2.1,>=1",
8990
"verlib2<0.3",

src/sqlalchemy_cratedb/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,22 @@
5252
monkeypatch_add_exec_driver_sql()
5353

5454

55+
try:
56+
from importlib.metadata import PackageNotFoundError, version
57+
except (ImportError, ModuleNotFoundError): # pragma:nocover
58+
from importlib_metadata import ( # type: ignore[assignment,no-redef,unused-ignore]
59+
PackageNotFoundError,
60+
version,
61+
)
62+
63+
try:
64+
__version__ = version("sqlalchemy-cratedb")
65+
except PackageNotFoundError: # pragma: no cover
66+
__version__ = "unknown"
67+
68+
5569
__all__ = [
70+
__version__,
5671
dialect,
5772
FloatVector,
5873
Geopoint,

0 commit comments

Comments
 (0)