Fix Python 3.12 incompatibility in versioneer.py#39
Open
rbaiazitovRBNT wants to merge 1 commit into
Open
Conversation
configparser.SafeConfigParser was removed in Python 3.12 (deprecated since 3.2) and RawConfigParser.readfp() was removed in 3.12 as well (deprecated since 3.2). Both are used in versioneer.py, causing pkasolver to fail to build on Python 3.12+ with: AttributeError: module 'configparser' has no attribute 'SafeConfigParser' AttributeError: 'RawConfigParser' object has no attribute 'readfp' Replacements: configparser.SafeConfigParser() → configparser.RawConfigParser() parser.readfp(f) → parser.read_file(f) Both replacements are API-compatible and have been available since Python 3.2, so this change does not affect older Python versions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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
pkasolverfails to install or build on Python 3.12+ becauseversioneer.pyuses two APIs that were removed in Python 3.12 (both had been deprecated since Python 3.2):configparser.SafeConfigParser()configparser.RawConfigParser()parser.readfp(f)parser.read_file(f)The errors at build time are:
What changed
One file, two one-line substitutions in
versioneer.py:Both replacements are fully API-compatible and have been available since Python 3.2, so this patch does not affect older Python versions.
Why it matters
Python 3.12 is now the default on many platforms (macOS Homebrew, recent Ubuntu, etc.). Without this fix, users on Python 3.12 cannot
pip installpkasolver at all — the build step errors out before any package code runs. This is a one-line versioneer maintenance fix with zero functional impact on the library itself.Test plan
pip install .succeeds on Python 3.12import pkasolverworks after install