Skip to content

fix: modernize setup.sh and CI workflows for Python 3.12+#1335

Closed
dholt wants to merge 3 commits intoNVIDIA:masterfrom
dholt:fix/setup-distutils-to-packaging
Closed

fix: modernize setup.sh and CI workflows for Python 3.12+#1335
dholt wants to merge 3 commits intoNVIDIA:masterfrom
dholt:fix/setup-distutils-to-packaging

Conversation

@dholt
Copy link
Contributor

@dholt dholt commented Feb 18, 2026

Summary

  • Replace distutils.version.LooseVersion with packaging.version.Version in setup.shdistutils was removed from Python stdlib in 3.12, breaking setup on Ubuntu 24.04+
  • Use explicit venv Python (${VENV_DIR}/bin/python3) for version checks instead of ${PYTHON_BIN} (system Python doesn't have packaging)
  • Bump jmespath 0.10.0 → 1.0.1 to match kubespray requirements
  • Update all GitHub Actions workflows: runners from ubuntu-20.04 (removed April 2025) to ubuntu-22.04, actions to v4/v3/v9, Python to 3.12
  • Add new setup.yml workflow that tests setup.sh on Ubuntu 22.04 and 24.04

Test plan

  • setup.sh tested end-to-end on Ubuntu 24.04 VM (Python 3.12) via MAAS
  • setup.yml CI passes on both Ubuntu 22.04 and 24.04
  • bash -n scripts/setup.sh syntax check passes
  • packaging.version.Version comparisons verified correct on Python 3.12

🤖 Generated with Claude Code

dholt and others added 3 commits February 18, 2026 13:00
distutils.version.LooseVersion was removed from the Python stdlib in
3.12, breaking setup.sh on Ubuntu 24.04+ and any modern Python. Switch
to packaging.version.Version (available via pip) and use the venv
python3 instead of PYTHON_BIN so the import resolves correctly.

Also bump jmespath 0.10.0 to 1.0.1 to match kubespray requirements,
and add packaging to the explicit pip install list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
- Update runners from ubuntu-20.04 (removed) to ubuntu-22.04
- Bump actions to current versions (checkout@v4, setup-python@v4,
  codeql-action@v3, stale@v9)
- Update Python 3.9 to 3.12, Ansible 4.8.0 to 9.13.0 in CI
- Add setup.yml workflow to test setup.sh on Ubuntu 22.04 and 24.04
- Use explicit venv python path in setup.sh version checks

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
- Keep ansible==4.8.0 for lint job (ansible-lint 5.4.0 is incompatible
  with ansible-core 2.16); use Python 3.10 for compatibility
- Use molecule-plugins[docker] instead of molecule[docker] (driver
  moved to separate package in newer molecule versions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Douglas Holt <dholt@nvidia.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request modernizes the DeepOps setup infrastructure to support Python 3.12+ and current Ubuntu LTS releases. The changes address the removal of distutils from Python 3.12 stdlib and update CI infrastructure to use current GitHub Actions runner versions and action versions.

Changes:

  • Replace deprecated distutils.version.LooseVersion with packaging.version.Version for version comparisons in setup.sh
  • Update all GitHub Actions workflows to use ubuntu-22.04 runners and current action versions (v4/v3/v9)
  • Add new setup.yml workflow to test setup.sh on Ubuntu 22.04 and 24.04
  • Bump jmespath from 0.10.0 to 1.0.1 and add packaging as an explicit dependency

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/setup.sh Migrates from distutils to packaging module for version comparisons; updates jmespath version; adds packaging dependency
.gitignore Adds virtualenv and development tool artifacts to ignore list
.github/workflows/stale.yml Updates actions/stale from v3 to v9
.github/workflows/setup.yml New workflow to test setup.sh on Ubuntu 22.04 and 24.04
.github/workflows/molecule.yml Updates runner to ubuntu-22.04, Python to 3.12, actions to v4, ansible to 9.13.0, and molecule plugin syntax
.github/workflows/codeql.yml Updates actions to v4 and CodeQL actions to v3
.github/workflows/ansible-lint-roles.yml Updates runner to ubuntu-22.04, actions to v4, Python to 3.10 (intentional for ansible-lint compatibility)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +103 to +108
if "${VENV_DIR}/bin/python3" -c "from packaging.version import Version; print(Version('$current_version') >= Version('$ANSIBLE_TOO_NEW'))" | grep True 2>&1 >/dev/null; then
echo "Ansible version ${current_version} too new for DeepOps"
echo "Please uninstall any ansible, ansible-base, and ansible-core packages and re-run this script"
exit 1
fi
if "${PYTHON_BIN}" -c "from distutils.version import LooseVersion; print(LooseVersion('$current_version') < LooseVersion('$ANSIBLE_VERSION'))" | grep True 2>&1 >/dev/null; then
if "${VENV_DIR}/bin/python3" -c "from packaging.version import Version; print(Version('$current_version') < Version('$ANSIBLE_VERSION'))" | grep True 2>&1 >/dev/null; then
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The packaging module is imported on lines 103 and 108 to perform version comparisons, but it is not installed until line 118. This will cause the version checks to fail with an ImportError when ansible is already installed in the venv.

The packaging module should be installed before attempting to use it for version comparisons. Consider either:

  1. Installing packaging first (before the version checks), then installing the rest of the packages
  2. Installing packaging separately before line 100
  3. Using a different version comparison method that doesn't require the packaging module for the initial checks

Copilot uses AI. Check for mistakes.
@dholt
Copy link
Contributor Author

dholt commented Feb 18, 2026

Closing — will resubmit as a combined PR with Phase 1 (Ansible 9.x role compatibility fixes) so everything ships together.

@dholt dholt closed this Feb 18, 2026
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

Comments