MCPcopy Index your code
hub / github.com/python/cpython / get_header_version_info

Function get_header_version_info

Doc/tools/extensions/patchlevel.py:33–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31
32
33def get_header_version_info() -> version_info:
34 # Capture PY_ prefixed #defines.
35 pat = re.compile(r"\s*#define\s+(PY_\w*)\s+(\w+)", re.ASCII)
36
37 defines = {}
38 patchlevel_h = PATCHLEVEL_H.read_text(encoding="utf-8")
39 for line in patchlevel_h.splitlines():
40 if (m := pat.match(line)) is not None:
41 name, value = m.groups()
42 defines[name] = value
43
44 return version_info(
45 major=int(defines["PY_MAJOR_VERSION"]),
46 minor=int(defines["PY_MINOR_VERSION"]),
47 micro=int(defines["PY_MICRO_VERSION"]),
48 releaselevel=RELEASE_LEVELS[defines["PY_RELEASE_LEVEL"]],
49 serial=int(defines["PY_RELEASE_SERIAL"]),
50 )
51
52
53def format_version_info(info: version_info) -> tuple[str, str]:

Callers 2

get_version_infoFunction · 0.85
patchlevel.pyFile · 0.85

Calls 6

version_infoClass · 0.85
compileMethod · 0.45
read_textMethod · 0.45
splitlinesMethod · 0.45
matchMethod · 0.45
groupsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…