Skip to content

Commit b4f0542

Browse files
committed
Use versioningit's git-archive method, to support zip archive installs
https://versioningit.readthedocs.io/en/stable/configuration.html#git-archive
1 parent bfd1069 commit b4f0542

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyproject.toml export-subst

pyproject.toml

Lines changed: 3 additions & 1 deletion
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",
@@ -252,8 +253,9 @@ non_interactive = true
252253
# enable_recursive_aliases = true
253254

254255
[tool.versioningit.vcs]
255-
method = "git"
256+
method = "git-archive"
256257
default-tag = "0.0.0"
258+
describe-subst = "$Format:%(describe:tags)$"
257259

258260
# ===================
259261
# Tasks configuration

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)