main: more detailed --version output
This commit is contained in:
@@ -105,20 +105,27 @@
|
||||
default = self.packages.${system}.worblehat;
|
||||
worblehat = let
|
||||
inherit (pkgs) python3Packages;
|
||||
inherit (self) sourceInfo;
|
||||
pyproject = lib.pipe ./pyproject.toml [
|
||||
builtins.readFile
|
||||
builtins.fromTOML
|
||||
];
|
||||
in python3Packages.buildPythonApplication {
|
||||
pname = pyproject.project.name;
|
||||
version = pyproject.project.version;
|
||||
version = "0.1";
|
||||
src = lib.cleanSource ./.;
|
||||
|
||||
format = "pyproject";
|
||||
|
||||
build-system = with python3Packages; [ hatchling ];
|
||||
build-system = with python3Packages; [ setuptools setuptools-scm ];
|
||||
dependencies = deps pkgs.python3Packages;
|
||||
|
||||
env.SETUPTOOLS_SCM_PRETEND_METADATA = (x: "{${x}}") (lib.concatStringsSep ", " [
|
||||
"node=\"${sourceInfo.rev or (lib.substring 0 64 sourceInfo.dirtyRev)}\""
|
||||
"node_date=${lib.substring 0 4 sourceInfo.lastModifiedDate}-${lib.substring 4 2 sourceInfo.lastModifiedDate}-${lib.substring 6 2 sourceInfo.lastModifiedDate}"
|
||||
"dirty=${if sourceInfo ? dirtyRev then "true" else "false"}"
|
||||
]);
|
||||
|
||||
meta.mainProgram = "worblehat";
|
||||
};
|
||||
});
|
||||
|
||||
+4
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "worblehat"
|
||||
version = "0.1.0"
|
||||
dynamic = ["version"]
|
||||
description = "Worblehat is a simple library management system written specifically for Programvareverkstedet"
|
||||
authors = [
|
||||
{ name = "Programvareverkstedet", email = "projects@pvv.ntnu.no" }
|
||||
@@ -55,6 +55,9 @@ include = ["worblehat*"]
|
||||
[tool.setuptools.package-dir]
|
||||
"" = "src"
|
||||
|
||||
[tool.setuptools_scm]
|
||||
version_file = "src/worblehat/_version.py"
|
||||
|
||||
[tool.poe.tasks]
|
||||
clean = """
|
||||
rm -rf
|
||||
|
||||
+8
-11
@@ -18,14 +18,10 @@ from .services import (
|
||||
|
||||
|
||||
def _print_version() -> None:
|
||||
from importlib.metadata import PackageNotFoundError, version
|
||||
from ._version import commit_id, version
|
||||
|
||||
try:
|
||||
__version__ = version("worblehat")
|
||||
except PackageNotFoundError:
|
||||
__version__ = "unknown"
|
||||
|
||||
print(f"Worblehat version {__version__}")
|
||||
print(f"Worblehat version {version}, commit {commit_id if commit_id else '<unknown>'}")
|
||||
return
|
||||
|
||||
|
||||
def _connect_to_database(**engine_args) -> Session:
|
||||
@@ -43,6 +39,11 @@ def _connect_to_database(**engine_args) -> Session:
|
||||
|
||||
def main() -> None:
|
||||
args = arg_parser.parse_args()
|
||||
|
||||
if args.version:
|
||||
_print_version()
|
||||
exit(0)
|
||||
|
||||
Config.load_configuration(vars(args))
|
||||
|
||||
if Config["logging.debug"]:
|
||||
@@ -50,10 +51,6 @@ def main() -> None:
|
||||
else:
|
||||
logging.basicConfig(encoding="utf-8", level=logging.INFO)
|
||||
|
||||
if args.version:
|
||||
_print_version()
|
||||
exit(0)
|
||||
|
||||
if args.print_config:
|
||||
print(f"Configuration:\n{pformat(vars(args))}")
|
||||
exit(0)
|
||||
|
||||
Reference in New Issue
Block a user