Skip to content

Fix Python 3.12 incompatibility in versioneer.py#39

Open
rbaiazitovRBNT wants to merge 1 commit into
mayrf:mainfrom
rbaiazitovRBNT:fix/python312-configparser-compat
Open

Fix Python 3.12 incompatibility in versioneer.py#39
rbaiazitovRBNT wants to merge 1 commit into
mayrf:mainfrom
rbaiazitovRBNT:fix/python312-configparser-compat

Conversation

@rbaiazitovRBNT
Copy link
Copy Markdown

Summary

pkasolver fails to install or build on Python 3.12+ because versioneer.py uses two APIs that were removed in Python 3.12 (both had been deprecated since Python 3.2):

Removed API Replacement
configparser.SafeConfigParser() configparser.RawConfigParser()
parser.readfp(f) parser.read_file(f)

The errors at build time are:

AttributeError: module 'configparser' has no attribute 'SafeConfigParser'
AttributeError: 'RawConfigParser' object has no attribute 'readfp'

What changed

One file, two one-line substitutions in versioneer.py:

-    parser = configparser.SafeConfigParser()
+    parser = configparser.RawConfigParser()
     with open(setup_cfg, "r") as f:
-        parser.readfp(f)
+        parser.read_file(f)

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 install pkasolver 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.12
  • import pkasolver works after install
  • pKa predictions return expected values (tested against literature values for common aliphatic amines)

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>
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