Skip to content

Commit

Permalink
Handle the version dynamically with hatch
Browse files Browse the repository at this point in the history
  • Loading branch information
hellais committed Mar 13, 2024
1 parent 86104de commit 6b7f959
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 0 additions & 2 deletions ooniapi/common/src/common/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from importlib.resources import files as importlib_files
from typing import Optional

pkg_name = "oonidataapi"


def get_pkg_version(pkg_name) -> Optional[str]:
try:
Expand Down
12 changes: 10 additions & 2 deletions ooniapi/services/oonirun/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ build-backend = "hatchling.build"

[project]
name = "oonirun"
version = "0.5.0.dev1"
description = ''
dynamic = ["version"]

dependencies = [
"fastapi ~= 0.108.0",
Expand Down Expand Up @@ -45,8 +45,15 @@ Documentation = "https://github.com/ooni/backend"
Issues = "https://github.com/ooni/backend/issues"
Source = "https://github.com/ooni/backend"

[tool.hatch.version]
path = "src/oonirun/__about__.py"

[tool.hatch.build.targets.sdist]
include = ["BUILD_LABEL"]

[tool.hatch.build.targets.wheel]
packages = ["src/oonirun"]
artifacts = ["BUILD_LABEL"]

[tool.hatch.envs.default]
dependencies = ["pytest", "pytest-cov", "click", "black", "pytest-postgresql"]
Expand All @@ -66,7 +73,8 @@ branch = true
parallel = true
source_pkgs = ["oonirun", "tests"]
omit = [
"src/oonirun/common/*"
"src/oonirun/common/*",
"src/oonirun/__about__.py"
]

[tool.coverage.paths]
Expand Down
1 change: 1 addition & 0 deletions ooniapi/services/oonirun/src/oonirun/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "0.5.0dev1"
2 changes: 1 addition & 1 deletion ooniapi/services/oonirun/src/oonirun/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import logging

pkg_name = "ooniapi.oonirun"
pkg_name = "oonirun"

pkg_version = get_pkg_version(pkg_name)
build_label = get_build_label(pkg_name)
Expand Down

0 comments on commit 6b7f959

Please sign in to comment.