Switch project to dynamic version based on Git commits

This commit is contained in:
Zoé Cassiopée Gauthier 2024-04-16 11:44:41 -04:00
parent 754fd46ee7
commit e1cf1cb194
3 changed files with 14 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
__pycache__/ __pycache__/
dist/ dist/
src/pogo_scaled_estimators/_version.py
*.sqlite *.sqlite

View File

@ -1,10 +1,10 @@
[build-system] [build-system]
requires = ["hatchling"] requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[project] [project]
name = "pogo-scaled-estimators" name = "pogo-scaled-estimators"
version = "1.0a1" dynamic = ["version"]
dependencies = [ dependencies = [
"requests", "requests",
"requests-cache", "requests-cache",
@ -32,6 +32,12 @@ classifiers = [
[project.scripts] [project.scripts]
ase-cli = "pogo_scaled_estimators:main_cli" 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] [tool.hatch.envs.lint]
detached = true detached = true
dependencies = [ dependencies = [
@ -48,6 +54,9 @@ typing = ["pyright"]
[tool.ruff] [tool.ruff]
target-version = "py312" target-version = "py312"
line-length = 120 line-length = 120
exclude = [
"src/pogo_scaled_estimators/_version.py",
]
[tool.ruff.lint] [tool.ruff.lint]
select = [ select = [

View File

@ -9,6 +9,7 @@ import operator
import sys import sys
from functools import reduce from functools import reduce
from pogo_scaled_estimators._version import version
from pogo_scaled_estimators.calculator import Calculator, Filter from pogo_scaled_estimators.calculator import Calculator, Filter
@ -23,6 +24,7 @@ def main_cli():
_ = parser.add_argument( _ = parser.add_argument(
"--no-legendary", dest="filters", action="append_const", const=Filter.DISALLOW_LEGENDARY_POKEMON "--no-legendary", dest="filters", action="append_const", const=Filter.DISALLOW_LEGENDARY_POKEMON
) )
_ = parser.add_argument("--version", action="version", version=version)
args = parser.parse_args() args = parser.parse_args()
filters = reduce(operator.or_, args.filters or [], Filter.NO_FILTER) filters = reduce(operator.or_, args.filters or [], Filter.NO_FILTER)