Skip to content

Commit bdcbac2

Browse files
authored
Generate __version__ at build to avoid slow importlib.metadata import (#30)
2 parents a95b471 + a6aefbf commit bdcbac2

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy