Page MenuHomePhabricator

blubber: Allow users to specify version constraints for core python packages
Closed, ResolvedPublic

Description

The recently released setuptools 82.0 removed pkg_resources entirely: https://setuptools.pypa.io/en/latest/history.html

But since Blubber attempts to setuptools to install the latest version (except blacklisting 60.9.0), this makes various unrelated Python images fail. I noticed this when trying to rebuild the Thumbor plugins (which we need to do frequently to pick up the latest security fixes from Debian).

Obviously all of these need fixing, but I'd suggest to pin to e.g. 81 for now to keep all images buildable for a transition period?

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
python: Specify versions of core Python package dependenciesrepos/releng/blubber!173dduvallreview/pin-python-support-pkgsmain
Customize query in GitLab

Event Timeline

blubber pinning to the latest setuptools breaks the builds of container images deployed to production.

I e.g. fixed thumbor-plugins in https://gerrit.wikimedia.org/r/c/operations/software/thumbor-plugins/+/1243135, but that still isn't enough: The test suite also uses swiftclient as packaged in Debian Bookworm and that version obviously still uses pkg_resources as Bookworm is a stable release.

I swear someone else had the exact same issue due to Blubber installing whatever is the latest (pip install setuptools!=60.9.0).

Short of migrating out of pkg_resources and given the image uses Debian python packages, maybe you can try adding python3-setuptools to the list of packages and the version shipped by Debian should work with the packaged Swift. I am pretty sure the packages are installed before Blubber runs pip, it would find the Debian packaged version and it will fullfil the constraint (!=60.9.0), pip will not install a more recent version.

diff --git a/.pipeline/blubber.yaml b/.pipeline/blubber.yaml
index a27c7ed..7002af9 100644
--- a/.pipeline/blubber.yaml
+++ b/.pipeline/blubber.yaml
@@ -92,6 +92,7 @@ apt:
     - fonts-unfonts-extra
     - fonts-vlgothic
     - fonts-wqy-zenhei
+    - python3-setuptools
     - texlive-fonts-recommended
     - xfonts-100dpi
     - xfonts-75dpi

It is worth a shot?

If that does not work I think that would be because Blubber now uses a virtualenv without system packages exposed T357548. Done by @dancy with 0ecc6f22465fc989dd09e2e9c44a4f5ab9e9c53a. That can be turned enabled using python.use-system-site-packages = true:

diff --git a/.pipeline/blubber.yaml b/.pipeline/blubber.yaml
index a27c7ed..8201184 100644
--- a/.pipeline/blubber.yaml
+++ b/.pipeline/blubber.yaml
@@ -92,6 +92,7 @@ apt:
     - fonts-unfonts-extra
     - fonts-vlgothic
     - fonts-wqy-zenhei
+    - python3-setuptools
     - texlive-fonts-recommended
     - xfonts-100dpi
     - xfonts-75dpi
thcipriani subscribed.

@dancy could you offer @MoritzMuehlenhoff some advice here? At a glance seems like @hashar 's suggestions are right can we suggest a patch to fix?

Change #1250619 had a related patch set uploaded (by Thcipriani; author: Thcipriani):

[operations/software/thumbor-plugins@master] Blubber: add python3-setuptools + use-system-packages

https://gerrit.wikimedia.org/r/1250619

Looks like tests pass for https://gerrit.wikimedia.org/r/1250619 does rebasing on top of that change get you what you need @MoritzMuehlenhoff ?

Looks like tests pass for https://gerrit.wikimedia.org/r/1250619

It appears to still install setuptools 82.

#14 2.532 Successfully installed setuptools-82.0.1

I believe this is on account of Blubber doing pip install -U. Even with --system-site-packages on the venv, the -U flag is going to tell pip to install something newer.

@dancy and I discussed adding fields to blubber's python config to allow pinning of the core dependencies. I'm working on a patch now. I do think having blubber add a default constraint for each core dependency also makes sense. I'll add that as well.

Blubber v1.8.0 has been released and contains some new fields for setting Python package version constraints.

2026-03-11 18:27:37,040 Target 'buildkit' image published to 'docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1@sha256:4c572fff82879c2386ebbedd29ba066bbd8ce61578b4677dfacefe02e32bc43a'
2026-03-11 18:27:37,040 Target 'buildkit' image published to 'docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.8@sha256:4c572fff82879c2386ebbedd29ba066bbd8ce61578b4677dfacefe02e32bc43a'
2026-03-11 18:27:37,041 Target 'buildkit' image published to 'docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.8.0@sha256:4c572fff82879c2386ebbedd29ba066bbd8ce61578b4677dfacefe02e32bc43a'

@MoritzMuehlenhoff, you can bump the blubber version in thumbor's .pipeline/blubber.yaml (syntax line) to v1.8.0 and add the following to the python section:

setuptools-version: "~=81.0"

Thanks @dduvall that's a nice solution. Updated my change to use that.

Change #1250619 merged by Muehlenhoff:

[operations/software/thumbor-plugins@master] Blubber: bump blubber to 1.8.1; set setuptools version

https://gerrit.wikimedia.org/r/1250619

@dduvall @thcipriani Thanks so much for the quick solution. I've merged Tyler's patch and can confirm that it fixes it (confirmed via https://gerrit.wikimedia.org/r/c/operations/software/thumbor-plugins/+/1251091)

I'll leave to you to resolve the task, not sure if there's any other followup you plan for.

thcipriani renamed this task from blubber: Pin Python to setuptools 81 for now? to blubber: Allow users to specify version constraints for core python packages.Mar 12 2026, 2:57 PM
thcipriani closed this task as Resolved.
thcipriani assigned this task to dduvall.

@dduvall @thcipriani Thanks so much for the quick solution. I've merged Tyler's patch and can confirm that it fixes it (confirmed via https://gerrit.wikimedia.org/r/c/operations/software/thumbor-plugins/+/1251091)

I'll leave to you to resolve the task, not sure if there's any other followup you plan for.

Glad it worked for you @MoritzMuehlenhoff! Calling this one resolved (after a re-title that reflects the direction @dduvall went with the solution).