Skip to content

feat(kingfisher): Use Python 3.13 for Python apps on kingfisher-main - #683

Merged
jpmckinney merged 3 commits into
mainfrom
python-3.13-kingfisher-main
Oct 30, 2026
Merged

jpmckinney merged 3 commits into
mainfrom
python-3.13-kingfisher-main

Conversation

@jpmckinney

@jpmckinney jpmckinney commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Python 3.10 reaches end-of-life on 2026-10-31. kingfisher-main's Python apps (Scrapyd, kingfisher-collect's incremental crawls, kingfisher-summarize and collect-generic) build their virtualenvs from the server's default Python, which is 3.10 on Ubuntu 22.04. This PR sets the python:version pillar, so their virtualenvs use Python 3.13 from the deadsnakes PPA, independently of the OS. 3.13 is Ubuntu 26.04's default (#602).

  • pillar/kingfisher_main.sls: Set python:version to '3.13'.
  • salt/python/init.sls: Drop python{version}-distutils, which deadsnakes doesn't build for 3.12+ (distutils was removed from the standard library). No other pillar sets python:version, so nothing else uses it.
  • salt/lib.sls: Recreate the virtual environment if the Python version changes. The virtualenv macro's watch: pkg: python didn't do this: virtualenv.managed has no mod_watch function, so the watch only ordered the states, and an existing .ve kept its old Python. A file.absent on .ve, with onchanges: pkg: python, now removes it only when pkg: python reports changes (i.e. when a new pythonX.Y package is installed), before the virtualenv.managed states recreate it. The existing onchanges on -requirements then reinstalls the requirements.

Testing

In an ubuntu:22.04 container, with the deadsnakes PPA:

  • python3.13 and python3.13-dev (for python.psycopg) are available. python3.13-distutils isn't.
  • virtualenv --python=/usr/bin/python3.13, as the virtualenv macro runs it, succeeds and pip install uv works. Ubuntu's virtualenv 20.13 has no bundled pip for 3.13 (python3-pip-whl is pip 22.0.2), so it downloads the latest pip, setuptools and wheel from PyPI. kingfisher-main already installs requirements from PyPI. Offline, the virtualenv creation fails.

./run.py kingfisher-main state.apply test=True renders the four *-virtualenv-clear states. In test mode, pkg.installed for python3.13 raises an exception (the PPA isn't actually added in test mode), so its dependent states report "requisite failed".

Deploy

Deploy while no Scrapyd crawls are running: recreating Scrapyd's virtualenv restarts Scrapyd. A second test=True run should then report the *-virtualenv-clear states as not run.

Follow-up

  • Update .python-version (and related settings) in collect-generic, kingfisher-collect and kingfisher-summarize to 3.13.

Part of open-contracting/software-development-handbook#153.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF

Drop pythonX.Y-distutils, which the deadsnakes PPA doesn't build for 3.12+.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF
jpmckinney and others added 2 commits October 29, 2026 23:30
…hanges

virtualenv.managed has no mod_watch function, so the watch requisite on pkg:
python didn't recreate it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF
A watch requisite on virtualenv.managed doesn't recreate the virtual environment,
because the state has no mod_watch function.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF
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.

1 participant