chore(build): copy version.txt

This commit is contained in:
Javier Martinez
2026-06-03 00:27:00 +08:00
parent ecd4369fef
commit bb1ea2f1d6
2 changed files with 14 additions and 6 deletions

View File

@@ -1,8 +1,15 @@
from __future__ import annotations
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path
def get_version() -> str:
with open("version.txt", "r+") as version_file:
try:
return version("private-gpt")
except PackageNotFoundError:
version_file = Path(__file__).resolve().parents[2] / "version.txt"
try:
release_version = version_file.read()
version_file.close()
return release_version
except OSError as e:
raise ImportError("Version file not found") from e
return version_file.read_text(encoding="utf-8").strip()
except OSError as exc:
raise ImportError("Version metadata not found") from exc

View File

@@ -348,6 +348,7 @@ packages = ["private_gpt"]
[tool.hatch.build.targets.wheel.force-include]
"settings.yaml" = "settings.yaml"
"version.txt" = "version.txt"
"ui" = "ui"
"scripts" = "scripts"