feat: llama stack show

`llama stack show` prints all required pip dependencies. It does this by using the `module` in the provider spec as the installation directory and gets all deps using the new `pyproject.toml`, providers can be installed as a package using the dependencies in the pyproject

Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
Charlie Doern 2025-07-30 18:55:22 -04:00
parent 41431d8bdd
commit 3186cca09f
6 changed files with 396 additions and 5 deletions

View file

@ -6,6 +6,8 @@
import importlib.resources
import sys
import tomllib
from pathlib import Path
from pydantic import BaseModel
from termcolor import cprint
@ -72,8 +74,13 @@ def get_provider_dependencies(
external_provider_deps.append(provider_spec.module)
else:
external_provider_deps.extend(provider_spec.module)
if hasattr(provider_spec, "pip_packages"):
deps.extend(provider_spec.pip_packages)
pyproject = Path(provider_spec.module.replace(".", "/")) / "pyproject.toml"
with open(pyproject, "rb") as f:
data = tomllib.load(f)
dependencies = data.get("project", {}).get("dependencies", [])
deps.extend(dependencies)
if hasattr(provider_spec, "container_image") and provider_spec.container_image:
raise ValueError("A stack's dependencies cannot have a container image")