[MINOR] Fix Python 3.12+ compatibility (drop distutils, six, pkg_resources)#52
Open
[MINOR] Fix Python 3.12+ compatibility (drop distutils, six, pkg_resources)#52
Conversation
The pinned invoke==0.22.0 (2017) and direct uses of removed/deprecated stdlib APIs prevent invoke-release from running on modern Python: - distutils removed in Python 3.12 -> use packaging.version.Version - pkg_resources.parse_version deprecated -> use packaging.version.parse - wheel.archive removed in wheel 0.32 -> lazy import in `wheel` task only - six no longer needed for py3-only -> use stdlib (input, str, importlib.reload, urllib.request) - Old invoke pin breaks on py3.12+ (uses removed `imp`) -> widen pin Backwards-compatible to Python 3.6+ and to invoke 1.x where the env still supports it (pip picks the latest compatible invoke per environment). The `wheel` task gracefully reports a clear error if `wheel.archive` is not available rather than crashing at import time. Note: complementary to #51, which drops Py2 boilerplate but leaves the actual Py 3.12+ breakage in place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pinned
invoke==0.22.0(2017) and direct use of removed/deprecated stdlib APIs preventinvoke-releasefrom running on Python 3.12+ (and partially on 3.11). This PR makes the tool work on modern Python while staying backwards-compatible to Python 3.6+.What breaks today
distutils.version.LooseVersionImportErrorat module loadpkg_resources.parse_versionDeprecationWarning, removal pendingwheel.archive.make_wheelfile_innerwheel0.32ImportErrorat module loadinvoke==0.22.0(vendoredsix.moves)ModuleNotFoundError: invoke.vendor.six.movesimp.load_module(used by old invoke)invoke <task>Changes
setup.py:invoke~=0.22.0->invoke>=1.0,<3.0six~=1.11.0packaging>=20.0python/invoke_release/tasks.py:distutils.version.LooseVersion->packaging.version.Version(using.releaseinstead of.version)pkg_resources.parse_version->packaging.version.parsefrom wheel import archive(top-level) -> lazy try/except inside thewheel()task. If running onwheel<0.32the task still works; on modern wheel it raises a clearReleaseFailurepointing topython -m build --wheel.six.text_type->str;six.moves.input->input;six.moves.reload_module->importlib.reload;six.moves.urllib-> stdliburllib.request.subprocess.check_output(...)forgit remote get-urlnow usesuniversal_newlines=True(3.0+ alias fortext=) so we get astrdirectly instead of relying onsix.text_typeto coerce bytes.Compatibility
importlib.reloadwhich is 3.4+,packagingavailable everywhere,universal_newlines=Trueworks on all py3).invoke: pin widened to>=1.0,<3.0so pip picks the latest version compatible with the host Python (1.x on older Py, 2.x on Py 3.6+).wheel: floor unchanged at>=0.31.1. Modern wheel works for everything except theinvoke wheeltask — which has been broken anyway since wheel 0.32.Validated on
Python 3.14.4, fresh venv, editable install,
invoke versionagainst an actual ebutils checkout:invoke --help releaseandinvoke --listboth render correctly.Note on PR #51
PR #51 (Aug 2025) covers some of the same ground — it drops
sixcalls and Py 2 boilerplate. However it leaves the actual Py 3.12+ breakage in place:distutils,pkg_resources,wheel.archive, and uses a barereload()call that does not exist as a builtin in Python 3 (it wouldNameErrorat runtime in the rollback-release task). This PR is complementary; rebasing onto #51 if it lands is a small mechanical job.Test plan
pip install -e .succeeds on Python 3.6, 3.9, 3.12, 3.14invoke versionruns in a project withtasks.py+version.py+CHANGELOG.txtinvoke release --no-stashproduces the expected commit shape (manually verified by reading the patched code paths against ebutils' history; not yet end-to-end tested against a real release)invoke wheelraises a clear error message on modern wheel; still works ifwheel<0.32is pinned