From e1cf1cb19446341a45a63d3c02638513c6efea1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zo=C3=A9=20Cassiop=C3=A9e=20Gauthier?= Date: Tue, 16 Apr 2024 11:44:41 -0400 Subject: [PATCH] Switch project to dynamic version based on Git commits --- .gitignore | 1 + pyproject.toml | 13 +++++++++++-- src/pogo_scaled_estimators/cli.py | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index cc23781..7b2603f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ __pycache__/ dist/ +src/pogo_scaled_estimators/_version.py *.sqlite diff --git a/pyproject.toml b/pyproject.toml index dc84956..854c443 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" [project] name = "pogo-scaled-estimators" -version = "1.0a1" +dynamic = ["version"] dependencies = [ "requests", "requests-cache", @@ -32,6 +32,12 @@ classifiers = [ [project.scripts] ase-cli = "pogo_scaled_estimators:main_cli" +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "src/pogo_scaled_estimators/_version.py" + [tool.hatch.envs.lint] detached = true dependencies = [ @@ -48,6 +54,9 @@ typing = ["pyright"] [tool.ruff] target-version = "py312" line-length = 120 +exclude = [ + "src/pogo_scaled_estimators/_version.py", +] [tool.ruff.lint] select = [ diff --git a/src/pogo_scaled_estimators/cli.py b/src/pogo_scaled_estimators/cli.py index 025acbe..2e35583 100644 --- a/src/pogo_scaled_estimators/cli.py +++ b/src/pogo_scaled_estimators/cli.py @@ -9,6 +9,7 @@ import operator import sys from functools import reduce +from pogo_scaled_estimators._version import version from pogo_scaled_estimators.calculator import Calculator, Filter @@ -23,6 +24,7 @@ def main_cli(): _ = parser.add_argument( "--no-legendary", dest="filters", action="append_const", const=Filter.DISALLOW_LEGENDARY_POKEMON ) + _ = parser.add_argument("--version", action="version", version=version) args = parser.parse_args() filters = reduce(operator.or_, args.filters or [], Filter.NO_FILTER)