Skip to content

Commit

Permalink
Generate __version__ at build to avoid slow importlib.metadata import
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Oct 12, 2024
1 parent 52565cb commit a0878c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,6 @@ $RECYCLE.BIN/
*.lnk

# End of https://www.gitignore.io/api/git,linux,pydev,python,windows,pycharm+all,jupyternotebook,vim,webstorm,emacs

# hatch-vcs
cherry_picker/_version.py
4 changes: 2 additions & 2 deletions cherry_picker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

from __future__ import annotations

import importlib.metadata
from ._version import __version__

__version__ = importlib.metadata.version(__name__)
__all__ = ["__version__"]
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ source = "vcs"
# Change regex to match tags like "cherry-picker-v2.2.0".
tag-pattern = '^cherry-picker-(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$'

[tool.hatch.build.hooks.vcs]
version-file = "cherry_picker/_version.py"

[tool.hatch.version.raw-options]
local_scheme = "no-local-version"

Expand Down

0 comments on commit a0878c6

Please sign in to comment.