diff --git a/Makefile b/Makefile index c8c6822..e9c946e 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,6 @@ install: submodules exit 1; \ fi @command -v uv >/dev/null 2>&1 || { echo "uv not found. Installing uv..."; curl -LsSf https://astral.sh/uv/install.sh | sh; } - @rm -f hate_crack/_version.py @UV_BIN=$$(command -v uv 2>/dev/null || echo "$$HOME/.local/bin/uv"); \ "$$UV_BIN" sync @mkdir -p "$${XDG_BIN_HOME:-$$HOME/.local/bin}" @@ -123,7 +122,7 @@ dev-reinstall: uninstall dev-install clean: -$(MAKE) -C hashcat-utils clean -@if [ -f .gitmodules ]; then git submodule deinit -f --all; fi - rm -rf .pytest_cache .ruff_cache build dist *.egg-info hate_crack/_version.py + rm -rf .pytest_cache .ruff_cache build dist *.egg-info rm -rf ~/.cache/uv find . -name "__pycache__" -type d -prune -exec rm -rf {} + diff --git a/hate_crack/__init__.py b/hate_crack/__init__.py index 6b0d048..b37cd9a 100644 --- a/hate_crack/__init__.py +++ b/hate_crack/__init__.py @@ -1,13 +1,20 @@ # hate_crack package import re as _re +from importlib.metadata import PackageNotFoundError as _PackageNotFoundError +from importlib.metadata import version as _pkg_version -from hate_crack._version import __version__ as _raw_version -from hate_crack._version import __version_tuple__ +try: + _raw_version = _pkg_version("hate_crack") +except _PackageNotFoundError: + _raw_version = "0.0.0" # Clean setuptools-scm version for display: # "2.0.post1.dev0+g05b5d6dc7.d20260214" → "2.0+g05b5d6dc7" # "2.0.post1.dev1+g1234abc" → "2.0+g1234abc" # "2.0" → "2.0" __version__ = _re.sub(r"(\.post\d+\.dev\d+|\.d\d{8})", "", _raw_version) +__version_tuple__ = tuple( + int(x) if x.isdigit() else x for x in __version__.split(".") +) __all__ = ["__version__", "__version_tuple__"] diff --git a/pyproject.toml b/pyproject.toml index 354742f..e00da6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ hate_crack = [ ] [tool.setuptools_scm] -version_file = "hate_crack/_version.py" version_scheme = "no-guess-dev" [tool.ruff]