8000 Generate __version__ at build to avoid slow importlib.metadata import · python/blurb@a6aefbf · GitHub
[go: up one dir, main page]

Skip to content

Commit a6aefbf

Browse files
committed
Generate __version__ at build to avoid slow importlib.metadata import
1 parent 832ff64 commit a6aefbf

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ ENV/
9090

9191
# pytest
9292
.pytest_cache/
93+
94+
# hatch-vcs
95+
src/*/_version.py

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ scripts.blurb = "blurb.blurb:main"
4242
[tool.hatch]
4343
version.source = "vcs"
4444

45+
[tool.hatch.build.hooks.vcs]
46+
version-file = "src/blurb/_version.py"
47+
4548
[tool.hatch.version.raw-options]
4649
local_scheme = "no-local-version"
4750

src/blurb/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
import importlib.metadata
2-
3-
__version__ = importlib.metadata.version(__name__)
1+
from ._version import __version__

0 commit comments

Comments
 (0)
0