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 11, 2024
1 parent 832ff64 commit a6aefbf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@ ENV/

# pytest
.pytest_cache/

# hatch-vcs
src/*/_version.py
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ scripts.blurb = "blurb.blurb:main"
[tool.hatch]
version.source = "vcs"

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

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

Expand Down
4 changes: 1 addition & 3 deletions src/blurb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import importlib.metadata

__version__ = importlib.metadata.version(__name__)
from ._version import __version__

0 comments on commit a6aefbf

Please sign in to comment.