Skip to content

Support modern Python (3.12/3.13): replace pkg_resources and distutils - #276

Merged
nahumtimerman merged 4 commits into
masterfrom
fix/modern-python-support
Sep 6, 2026
Merged

Support modern Python (3.12/3.13): replace pkg_resources and distutils#276
nahumtimerman merged 4 commits into
masterfrom
fix/modern-python-support

Conversation

@nahumtimerman

Copy link
Copy Markdown
Collaborator

Problem

shellfoundry crashes at bootstrap (ModuleNotFoundError: No module named 'pkg_resources') on:

  • Python 3.12+ — venvs no longer bundle setuptools. The setuptools; python_version >= '3.12' requirement marker never reaches pip because releases are sdist-only.
  • Any Python with setuptools ≥81 (mid-2025) — pkg_resources was removed from setuptools entirely, so even 3.9–3.11 environments break after a routine setuptools upgrade.

distutils.version.StrictVersion (removed from stdlib in 3.12) was one setuptools-shim away from being a second crash.

Changes

  • pkg_resources.get_distribution(...).versionimportlib.metadata.version(...) (stdlib since 3.8)
  • pkg_resources.parse_version / vendored Versionpackaging.version (new explicit packaging dependency)
  • distutils.version.StrictVersionpackaging.version.Version
  • requirements: +packaging, drop the now-unneeded conditional setuptools marker
  • setup.py: python_requires>=3.8, classifiers refreshed to 3.9–3.13 (2.7 was already impossible — cloudshell-rest-api~=9.0 requires ≥3.7)

Verification

  • Python 3.13: shellfoundry version, all touched modules import, shellfoundry new --template gen2/resource runs up to the CloudShell-server connection step. Note: full 3.13 support also needs Fix Python 3.13 support: import BinaryIO from typing (typing.io removed) cloudshell-rest-api#32 (typing.io removed in 3.13).
  • Python 3.9 (current documented version): shellfoundry version works — no regression.
  • Unit tests on 3.13: 197 passed; the 9 failures are pre-existing (reproduced identically on master with Python 3.9) and unrelated to this change.

Follow-ups (out of scope here)

  • test_requirements.txt needs modernization: the pinned pyfakefs doesn't import on 3.12+ (pathlib._Flavour), and httpretty is dead on 3.12+ (ssl.wrap_socket) — 3 test modules can't even collect.
  • Publish a wheel (or add pyproject.toml) so metadata reliably reaches pip.
  • Release + docs: the dev guide still instructs installing Python 2.7.18/3.9.9.

🤖 Generated with Claude Code

nahumtimerman and others added 4 commits September 6, 2026 09:17
- pkg_resources -> importlib.metadata (version lookup) and
  packaging.version (parse/Version). Python 3.12 venvs no longer bundle
  setuptools, and setuptools >=81 removed pkg_resources entirely, so
  shellfoundry crashed at bootstrap on any modern environment.
- distutils.version.StrictVersion -> packaging.version.Version
  (distutils removed in 3.12; only worked via the setuptools shim).
- requirements: add packaging, drop the setuptools>=3.12 marker
  (no longer needed once pkg_resources is gone).
- setup.py: python_requires>=3.8, refresh classifiers to 3.9-3.13.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- version.txt 1.2.29 (satisfies check-version; release vehicle for the
  modern-Python fixes)
- CI: package-tox-py-37-39 -> package-tox-py-39; ubuntu-latest runners
  can no longer install Python 3.7, and this branch sets
  python_requires>=3.8 anyway. tox envlist follows.
- black on bootstrap.py (this branch) and shell_package_installer.py
  (pre-existing from #275; pre-commit runs --all-files so CI was red on
  master too)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nahumtimerman
nahumtimerman merged commit efe5501 into master Sep 6, 2026
4 checks passed
@nahumtimerman
nahumtimerman deleted the fix/modern-python-support branch September 6, 2026 06:38
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