daedalus 0.2.0: hello - sample python script (category test) printing the greeting and app version; first registry entry with tests, README row, and daedalus.hello package

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
nvaldez
2026-11-18 21:16:07 +01:00
parent b71a513c36
commit 5d4f9417fd
7 changed files with 137 additions and 7 deletions
+44
View File
@@ -0,0 +1,44 @@
"""Print a hello line and the daedalus version.
Run via daedalus: ``daedalus hello`` (see daedalus README). A sample
script that exercises the registry, categories, the ``test`` category
listing, and the run_python_script entry end to end.
"""
from __future__ import annotations
import argparse
import importlib.metadata
import pathlib
import sys
import tomllib
UNKNOWN = "unknown"
def app_version() -> str:
"""Installed daedalus version, else the checkout pyproject, else 'unknown'."""
try:
return importlib.metadata.version("daedalus") # plain and editable installs
except importlib.metadata.PackageNotFoundError:
pass
# A checkout that is not installed: python/src/hello/hello.py -> pyproject.toml
pyproject = pathlib.Path(__file__).resolve().parents[3] / "pyproject.toml"
if pyproject.is_file():
project = tomllib.loads(pyproject.read_text(encoding="utf-8")).get("project", {})
version = project.get("version")
if isinstance(version, str) and version:
return version
return UNKNOWN
def main(argv: list[str] | None = None) -> int:
"""Print ``hello from daedalus <version>``; return the exit code."""
parser = argparse.ArgumentParser(prog="hello",
description=__doc__.splitlines()[0])
parser.parse_args(argv)
print(f"hello from daedalus {app_version()}")
return 0
if __name__ == "__main__":
sys.exit(main())