pg_statviz can now ask Claude, a local Ollama model, OpenAI or Gemini to explain your PostgreSQL statistics on every distro we ship it for. Getting there took three days and a few dozen new Python packages :-)

pg_statviz is a small tool that snapshots PostgreSQL's internal statistics and draws charts from them. Its newer releases also hand those numbers to an LLM and ask for an analysis. On Fedora this just worked, because Fedora ships fresh AI SDKs. On everything else, it did not -- until last weekend!
The problem: old toolchains, new SDKs

The AI SDKs move fast; enterprise Python toolchains do not. The latest anthropic, openai and google-genai releases want recent typing-extensions, httpx2, pydantic 2 with its Rust core, and build backends that understand PEP 639 license metadata. This was our starting point:

• Amazon Linux 2023 has a python3.13 stack with setuptools 69, flit-core 3.9 and Cython 3.0, and almost none of the SDK dependencies.
• RHEL 9 has python3.12 with numpy 1.24, Cython 0.29 and packaging 23.2. pg_statviz itself was not even packaged there.
• RHEL 10 lacked jiter, the Rust JSON parser that anthropic and openai need.
• SLES 16 had no pandas, and its own ollama (0.4.7) is too old for pg_statviz.

Target: Never replace an OS package. RHEL 9's numpy stays, because scipy and the GDAL bindings are built against it.

What we did: pick the newest version that fits

For each SDK we picked the newest release that builds and runs on what the distro already has, not the newest release upstream:

- anthropic: 0.40.0 on RHEL 9, 10 / AL2023 and SLES 16
- openai : 2.28.0 on RHEL 9 / AL2023, 1.39.0 on RHEL 10, 1.39.0 (+ httpx 0.28 patch) on SLES 16
- google-genai: 1.66.0 on RHEL 9 / AL2023, 1.0.0 on RHEL 10, 1.55.0 on SLES 16
- ollama: ours on RHEL 9, 10 / AL2023 / SLES 16

Fedora keeps its own SDKs, plus our anthropic 1.11.0.

Under the SDKs sits a new stack of pgdg-python3-** packages: pydantic 2.11.10 and pydantic-core, jiter 0.17.0, maturin, httpx, httpcore, anyio, google-auth 2.47.0 and about twenty more. For RHEL 9 we also added python3.12 build tools (hatchling 1.25.0, calver, hatch-vcs), plus pandas 2.1.4 and contourpy 1.2.1, which still build against its numpy 1.24.
The Rust parts (jiter, maturin, pydantic-core) build offline from vendored crate tarballs, made with small *-vendor.sh scripts kept next to the specs (this is what I also do for other Rust packages. You can find those scripts in our git repo).

A few fixes that took longer than they look:

• AL2023 defines %fedora, so a Fedora-only BuildRequires leaked into it and broke jiter.
• An older trove-classifiers on the builders did not know the GraalPy classifier, so setuptools refused to build kiwisolver and maturin. We now strip the classifiers in %prep.
• fonttools tried to build optional Cython extensions whenever Cython was installed. They need Cython 3.1, so we turned them off.
• urllib3 left _version.py out of the wheel, so import urllib3 failed.
• pg_statviz required plac, which it does not use and which blocked installation on Fedora. We dropped it.

Testing and rollout

Every distro was tested in mock before anything reached a builder. On each one we checked that pg_statviz installs with all its dependencies, that the SDKs import and build valid API requests, and that pg_statviz analyze draws all its charts against PostgreSQL 18. Live API calls were not part of the automated test. I tested them locally on my Fedora 44 box.

Published all packages on Friday!

Where to get it, and what's next

All four AI providers are now available on Fedora 44+, RHEL 10.1 and 10.2, RHEL 9.8, Amazon Linux 2023, SLES 16.0 and openSUSE Leap 16.0.

Install pg_statviz from the PGDG repositories as usual. RHEL 9 users also need CRB and EPEL enabled. SLES users who already have the OS's python313-ollama may need zypper install --allow-vendor-change.

openai 3.x is the next hurdle. It needs httpx2, a newer anyio and typing-extensions 4.14, so we stay on 2.28.0 for now. We may also turn the SDK dependencies into weak Recommends, so users who never touch the AI features do not pull them in.

As I always say: Enjoy!

No comments

The author does not allow comments to this entry