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 (#195)
  • Loading branch information
hugovk authored Aug 6, 2024
2 parents db8185a + fe2464e commit 70bc2c1
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 @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

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

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/tinytext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import importlib.metadata
from tinytext import _version # type: ignore[attr-defined]

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


__all__ = ["__version__"]
Expand Down

0 comments on commit 70bc2c1

Please sign in to comment.