Skip to content

Commit

Permalink
Generate __version__ at build to avoid slow importlib.metadata im…
Browse files Browse the repository at this point in the history
…port (#30)
  • Loading branch information
hugovk authored Oct 12, 2024
2 parents a95b471 + a6aefbf commit bdcbac2
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 bdcbac2

Please sign in to comment.