Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use dynamic version #4

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading