Skip to content

Commit ccd9d98

Browse files
committed
Use setuptools_scm & tags for versioning
1 parent 2aab33c commit ccd9d98

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "warnet"
3-
version = "1.1.11"
3+
dynamic = ["version"]
44
description = "Monitor and analyze the emergent behaviours of bitcoin networks"
55
readme = "README.md"
66
requires-python = ">=3.9"
@@ -56,3 +56,8 @@ include = ["warnet*", "test_framework*", "resources*"]
5656

5757
[tool.setuptools.package-data]
5858
"resources" = ["**/*"]
59+
60+
[tool.setuptools_scm]
61+
write_to = "src/warnet/_version.py"
62+
version_scheme = "post-release"
63+
local_scheme = "dirty-tag"

src/warnet/_version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is automatically generated by setuptools_scm
2+
# Do not edit! See pyproject.toml for configuration.
3+
__version__ = "0.0.0" # Will be replaced during build

src/warnet/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ def cli():
2424
def version() -> None:
2525
"""Display the installed version of warnet"""
2626
try:
27-
version = importlib.metadata.version("warnet")
27+
from warnet._version import __version__
28+
version = __version__
29+
# If running from source/git, setuptools_scm will append git info
30+
# e.g. "1.1.11.dev1+g123456[.dirty]"
2831
click.echo(f"warnet version {version}")
29-
except importlib.metadata.PackageNotFoundError:
32+
except ImportError:
3033
click.echo("warnet version unknown (package not installed)")
3134

3235

0 commit comments

Comments
 (0)