python / python/cpython

Add structured version info for modules wrapping external libraries

Open
#157,472 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.16 extension-modules type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

Several modules wrap an external library, but expose its version inconsistently: only a string, only a plain tuple, only the runtime or only the build-time version, or under a private name. gh-117404 established a pattern for zlib, bz2, lzma and compression.zstd: a string and a named tuple for the version the module was built against (XXX_VERSION, XXX_VERSION_INFO), and the same pair for the library actually loaded (xxx_version, xxx_version_info).

Other modules (existing names, with their types):

  • sqlite3 — runtime: sqlite_version (str), sqlite_version_info (plain tuple, computed in Python from the string). No build-time version.
  • pyexpat — runtime: EXPAT_VERSION (str, e.g. 'expat_2.8.4'), version_info (plain tuple). No build-time version.
  • decimal — runtime: __libmpdec_version__ (str). No tuple, no build-time version. Matters more now that only the system libmpdec is used.
  • readline — build-time: _READLINE_VERSION (int, 0x0803). Runtime: _READLINE_RUNTIME_VERSION (int), _READLINE_LIBRARY_VERSION (str). All private; backend (str) tells readline from libedit.
  • dbm.gnu — build-time: private _GDBM_VERSION (plain tuple). No runtime version (gdbm_version is not exposed).
  • dbm.ndbm — only library (str, the implementation name). No version.
  • ctypes — nothing about libffi.
  • uuid — nothing about libuuid.
  • ssl — runtime: OPENSSL_VERSION (str), OPENSSL_VERSION_INFO (plain 5-tuple), OPENSSL_VERSION_NUMBER (int). Build-time: only private _OPENSSL_API_VERSION (plain 5-tuple). The existing names conflict with the scheme above (uppercase names for the runtime version).
  • curses — runtime: ncurses_version (named tuple). No string, no build-time version. It is fine to keep only the named tuple.
  • tkinter — build-time: _tkinter.TCL_VERSION, TK_VERSION (str, only major.minor, e.g. '8.6'), and tkinter.TclVersion, TkVersion (float, 8.6, derived from them). The runtime version cannot be obtained at import time without creating a Tcl interpreter; it is available as Tcl().eval('info patchlevel').

Not all items need to be changed, and not all libraries provide both the compile-time and the runtime version. Sub-issues are opened for those that do.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading gh-117404 and comparing its zlib, bz2, lzma, and compression.zstd version API pattern with the module inventory in this issue. Review the relevant sub-issues and determine which modules can expose consistent build-time and runtime version information; done means each selected module has an agreed public interface without breaking existing names.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.