From 6a4d089dea85373839bb04e2448d9e7fc0621236 Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:18:52 -0400 Subject: [PATCH 1/3] feat(kingfisher): Use Python 3.13 for Python apps on kingfisher-main Drop pythonX.Y-distutils, which the deadsnakes PPA doesn't build for 3.12+. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF --- pillar/kingfisher_main.sls | 3 +++ salt/python/init.sls | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pillar/kingfisher_main.sls b/pillar/kingfisher_main.sls index 803438147..7e4ffe435 100644 --- a/pillar/kingfisher_main.sls +++ b/pillar/kingfisher_main.sls @@ -162,6 +162,9 @@ docker: uid: 1005 syslog_logging: True +python: + version: '3.13' + kingfisher_collect: user: collect group: deployer diff --git a/salt/python/init.sls b/salt/python/init.sls index 993fcacdc..3e980184c 100644 --- a/salt/python/init.sls +++ b/salt/python/init.sls @@ -5,8 +5,6 @@ python: pkg.installed: - pkgs: - python{{ pillar.python.version }} - # Avoid "ModuleNotFoundError: No module named 'distutils.command'". - - python{{ pillar.python.version }}-distutils - require: - pkgrepo: python {% endif %} From 41b955af544234df6c1bce51170fc6dcc2ff42bc Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:30:26 -0400 Subject: [PATCH 2/3] fix(python): Recreate the virtual environment if the Python version changes 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 Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF --- salt/lib.sls | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/salt/lib.sls b/salt/lib.sls index 4e68e9470..23a9aff15 100644 --- a/salt/lib.sls +++ b/salt/lib.sls @@ -97,6 +97,19 @@ unset {{ setting_name }} in {{ filename }}: # Bug: The "user" parameter is ignored, unless the undocumented "runas" parameter is used. # https://github.com/saltstack/salt/issues/59088#issuecomment-912148651 {% macro virtualenv(directory, user, parent_directory, requirements_file, watch_in=None) %} +{% if salt['pillar.get']('python:version') %} +# If the Python version changes, remove the virtual environment, so that it is recreated. (A watch requisite on +# virtualenv.managed doesn't recreate it, because the state has no mod_watch function.) +{{ directory }}-virtualenv-clear: + file.absent: + - name: {{ directory }}/.ve + - onchanges: + - pkg: python + - require_in: + - virtualenv: {{ directory }}-virtualenv + - virtualenv: {{ directory }}-uv +{% endif %} + {{ directory }}-virtualenv: virtualenv.managed: - name: {{ directory }}/.ve @@ -104,13 +117,8 @@ unset {{ setting_name }} in {{ filename }}: - runas: {{ user }} - user: {{ user }} - require: {{ ([{'pkg': 'virtualenv'}] + [parent_directory])|yaml }} -{% if salt['pillar.get']('python:version') %} - # If the Python version changes, reinstall the virtual environment. - - watch: - - pkg: python -{% endif %} -# This state only differs from the *-virtualenv state by installing uv and not watching python. +# This state only differs from the *-virtualenv state by installing uv. {{ directory }}-uv: virtualenv.managed: - name: {{ directory }}/.ve From 9a875a3cff3125c330df29050b58198471376f6f Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Thu, 29 Oct 2026 23:35:19 -0400 Subject: [PATCH 3/3] chore(python): Shorten comment 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 Claude-Session: https://claude.ai/code/session_01QSfuGf81zPF23KcUdGhEaF --- salt/lib.sls | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/salt/lib.sls b/salt/lib.sls index 23a9aff15..8e7213e6b 100644 --- a/salt/lib.sls +++ b/salt/lib.sls @@ -98,8 +98,7 @@ unset {{ setting_name }} in {{ filename }}: # https://github.com/saltstack/salt/issues/59088#issuecomment-912148651 {% macro virtualenv(directory, user, parent_directory, requirements_file, watch_in=None) %} {% if salt['pillar.get']('python:version') %} -# If the Python version changes, remove the virtual environment, so that it is recreated. (A watch requisite on -# virtualenv.managed doesn't recreate it, because the state has no mod_watch function.) +# If the Python version changes, remove the virtual environment, so that it is recreated. {{ directory }}-virtualenv-clear: file.absent: - name: {{ directory }}/.ve