Skip to content

fix: allow modern PyGObject so conda-forge installs work (#1) - #18

Merged
AmitMY merged 1 commit into
mainfrom
fix/install-pygobject
Oct 7, 2026
Merged

AmitMY merged 1 commit into
mainfrom
fix/install-pygobject

Conversation

@AmitMY

@AmitMY AmitMY commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1.

What was broken

I followed the README in a fresh conda env (Python 3.12, conda-forge pycairo pygobject pango), then ran pip install ".[dev,pangocairo]". It fails:

  • pyproject.toml pins PyGObject<3.52, so pip tries to replace conda-forge's working PyGObject 3.58 with 3.50 and build it from source. The build fails because 3.50 needs girepository-1.0 headers.
  • Pinning conda-forge itself to pygobject<3.52 gets you 3.50.0, whose build ships without gi/_gi_cairo. That module is behind the original KeyError: 'could not find foreign type Context' in Add instructions for alternative installation #1.

Changes

  • pyproject.toml: drop the PyGObject<3.52 pin.
  • CI action + Dockerfile: libgirepository1.0-dev → libgirepository-2.0-dev (Ubuntu 24.04 / Debian 13 have GLib ≥ 2.80). Add gcc explicitly: pycairo and PyGObject have no Linux wheels, and the old libgirepository1.0-dev pulled gcc in as a dependency.
  • README.md: document the conda-forge route, the apt packages for pip-only installs, and the PyGObject<3.52 fallback for older systems such as Ubuntu 22.04.

Verified

Route Result
conda-forge env + pip install ".[dev,pangocairo]" (README) ✅ installs PyGObject 3.58, renders
Ubuntu 24.04 + new apt packages + uv pip install ".[dev,pangocairo]" (CI setup) ✅ 455 tests pass, including the pixel-exact regression tests
docker build . (python:3.14-slim) ✅ prints (16, 48, 3) ✅

Trade-off: a pip-only install on GLib < 2.80 (Ubuntu 22.04) now needs pip install "PyGObject<3.52" first, as documented in the README.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Fy1wuWdqcKuebgj3St8dME


Note

Low Risk
Changes affect optional pangocairo install docs and CI/Docker system packages only; runtime renderer code is unchanged, with a documented manual pin for legacy GLib systems.

Overview
Unpins PyGObject so pip install ".[pangocairo]" no longer downgrades conda-forge’s PyGObject 3.58 to 3.50 (which broke installs and gi/_gi_cairo).

Build/CI apt deps move from libgirepository-1.0 / libgirepository1.0-dev to libgirepository-2.0-dev for GLib ≥ 2.80 (Ubuntu 24.04+), drop the runtime libgirepository-1.0-1 package from the CI list, and add gcc explicitly in the Dockerfile because source builds of pycairo/PyGObject no longer pull it in transitively.

README documents the conda-forge install path, apt packages for pip-only builds on modern Debian/Ubuntu, and the PyGObject<3.52 + libgirepository1.0-dev fallback for older GLib (e.g. Ubuntu 22.04).

Reviewed by Cursor Bugbot for commit d009aef. Bugbot is set up for automated code reviews on this repo. Configure here.

The PyGObject<3.52 pin made `pip install ".[pangocairo]"` downgrade the
working conda-forge PyGObject (3.58) and try to build 3.50 from source,
which fails without girepository-1.0 headers. conda-forge's last 3.50
build also ships without gi._gi_cairo, the cause of the original
"could not find foreign type Context" error.

Drop the pin and move CI and the Dockerfile to libgirepository-2.0-dev
(available on Ubuntu 24.04 and Debian 13). gcc is now listed explicitly,
since libgirepository1.0-dev used to pull it in. The README documents the
conda-forge route and the pin for older systems.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fy1wuWdqcKuebgj3St8dME
@AmitMY
AmitMY merged commit a33acaf into main Oct 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add instructions for alternative installation

1 participant