mirror of
https://github.com/trustedsec/hate_crack.git
synced 2026-04-28 12:03:11 -07:00
fix: read version from package metadata instead of _version.py
Replaces the _version.py import with importlib.metadata.version() so the version is always read from the installed package, which setuptools-scm writes correctly during uv sync. Removes the version_file config and the stale-file workarounds from make install/clean.
This commit is contained in:
3
Makefile
3
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 {} +
|
||||
|
||||
|
||||
@@ -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__"]
|
||||
|
||||
@@ -36,7 +36,6 @@ hate_crack = [
|
||||
]
|
||||
|
||||
[tool.setuptools_scm]
|
||||
version_file = "hate_crack/_version.py"
|
||||
version_scheme = "no-guess-dev"
|
||||
|
||||
[tool.ruff]
|
||||
|
||||
Reference in New Issue
Block a user