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

Function package_version

Platforms/Apple/__main__.py:449–469  ·  view source on GitHub ↗

Extract the Python version being built from patchlevel.h.

(prefix_path: Path)

Source from the content-addressed store, hash-verified

447
448
449def package_version(prefix_path: Path) -> str:
450 """Extract the Python version being built from patchlevel.h."""
451 for path in prefix_path.glob("**/patchlevel.h"):
452 text = path.read_text(encoding="utf-8")
453 if match := re.search(
454 r'\n\s*#define\s+PY_VERSION\s+"(.+)"\s*\n', text
455 ):
456 version = match[1]
457 # If not building against a tagged commit, add a timestamp to the
458 # version. Follow the PyPA version number rules, as this will make
459 # it easier to process with other tools. The version will have a
460 # `+` suffix once any official release has been made; a freshly
461 # forked main branch will have a version of 3.X.0a0.
462 if version.endswith("a0"):
463 version += "+"
464 if version.endswith("+"):
465 version += datetime.now(timezone.utc).strftime("%Y%m%d.%H%M%S")
466
467 return version
468
469 sys.exit("Unable to determine Python version being packaged.")
470
471
472def lib_platform_files(dirname, names):

Callers 1

create_xcframeworkFunction · 0.70

Calls 7

nowMethod · 0.80
globMethod · 0.45
read_textMethod · 0.45
searchMethod · 0.45
endswithMethod · 0.45
strftimeMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…