From b48a44894ea6dd0d33dc146bc1ae634dc52ad85d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 3 Oct 2024 15:25:32 +1000 Subject: [PATCH] Force version path rather than relying on autodetect This repo has several files containing `__version__`, seeing as there's a few sample projects under `tests/` directory. Better explicitly set the path to the file we want to manage. --- pyproject.toml | 3 +++ src/buildsys_dateversion/_hooks.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index c1cb9bf..4f359f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,9 @@ dependencies = { file = "requirements.in" } [tool.isort] profile = "black" +[tool.buildsys-dateversion] +version-path = "src/buildsys_dateversion/__init__.py" + [build-system] requires = [] backend-path = ["src"] diff --git a/src/buildsys_dateversion/_hooks.py b/src/buildsys_dateversion/_hooks.py index b094f6f..9c4d977 100644 --- a/src/buildsys_dateversion/_hooks.py +++ b/src/buildsys_dateversion/_hooks.py @@ -76,6 +76,10 @@ def _find_version_path(self) -> str: if not file.endswith(".py"): continue + # TODO: revisit handling of multiple matches: + # - assume shortest path is the best? + # - give fatal error? + # - update all of them? path = os.path.join(dirpath, file) LOG.debug("Checking file %s", path) if VERSION_PATTERN.search(open(path).read()):