Skip to content

Commit

Permalink
feat: use dynamic version (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreoxmt authored Dec 23, 2024
1 parent fbdff23 commit fd423e5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,5 @@ cython_debug/

# PyCharm
.idea/

src/tidocs/VERSION
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ includes = ["src/tidocs/"]

[tool.pdm.version]
source = "scm"
write_to = "tidocs/VERSION"
14 changes: 14 additions & 0 deletions src/tidocs/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import importlib.metadata
import importlib.resources


def read_version() -> str:
try:
return importlib.metadata.version(__package__ or "tidocs")
except importlib.metadata.PackageNotFoundError:
return (
importlib.resources.files("tidocs").joinpath("VERSION").read_text().strip()
)


__version__ = read_version()
3 changes: 2 additions & 1 deletion src/tidocs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from hypercorn.config import Config

from tidocs.pandoc_wrapper import Pandoc
from tidocs.__version__ import __version__

APPS = {"merge": "Merge Release Notes"}

Expand Down Expand Up @@ -38,7 +39,7 @@ def launch_marimo_app(appname: str, host: str, port: int) -> None:


@click.command(no_args_is_help=True)
@click.version_option(version="1.0.6")
@click.version_option(version=__version__)
@click.argument("appname", type=click.Choice(list(APPS.keys())), required=True)
@click.option(
"--host",
Expand Down

0 comments on commit fd423e5

Please sign in to comment.