fix: fetched latest pypi version when building documentation

This commit is contained in:
Ashwin Bharambe 2025-03-06 21:15:15 -08:00
parent 330cc9d09d
commit 4d9fe25bbf

View file

@ -13,16 +13,18 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
from docutils import nodes from docutils import nodes
import tomli # Import tomli for TOML parsing
from pathlib import Path from pathlib import Path
import requests
import json
# Read version from pyproject.toml # Read version from pyproject.toml
with Path(__file__).parent.parent.parent.joinpath("pyproject.toml").open("rb") as f: with Path(__file__).parent.parent.parent.joinpath("pyproject.toml").open("rb") as f:
pyproject = tomli.load(f) pypi_url = "https://pypi.org/pypi/llama-stack/json"
llama_stack_version = pyproject["project"]["version"] version_tag = json.loads(requests.get(pypi_url).text)["info"]["version"]
print(f"{version_tag=}")
# generate the full link including text and url here # generate the full link including text and url here
llama_stack_version_url = f"https://github.com/meta-llama/llama-stack/releases/tag/v{llama_stack_version}" llama_stack_version_url = f"https://github.com/meta-llama/llama-stack/releases/tag/v{version_tag}"
llama_stack_version_link = f"<a href='{llama_stack_version_url}'>release notes</a>" llama_stack_version_link = f"<a href='{llama_stack_version_url}'>release notes</a>"
project = "llama-stack" project = "llama-stack"
@ -77,7 +79,7 @@ myst_enable_extensions = [
myst_substitutions = { myst_substitutions = {
"docker_hub": "https://hub.docker.com/repository/docker/llamastack", "docker_hub": "https://hub.docker.com/repository/docker/llamastack",
"llama_stack_version": llama_stack_version, "llama_stack_version": version_tag,
"llama_stack_version_link": llama_stack_version_link, "llama_stack_version_link": llama_stack_version_link,
} }