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

Function package_version

Android/android.py:740–759  ·  view source on GitHub ↗
(prefix_dir)

Source from the content-addressed store, hash-verified

738
739
740def package_version(prefix_dir):
741 patchlevel_glob = f"{prefix_dir}/include/python*/patchlevel.h"
742 patchlevel_paths = glob(patchlevel_glob)
743 if len(patchlevel_paths) != 1:
744 sys.exit(f"{patchlevel_glob} matched {len(patchlevel_paths)} paths.")
745
746 for line in open(patchlevel_paths[0]):
747 if match := re.fullmatch(r'\s*#define\s+PY_VERSION\s+"(.+)"\s*', line):
748 version = match[1]
749 break
750 else:
751 sys.exit(f"Failed to find Python version in {patchlevel_paths[0]}.")
752
753 # If not building against a tagged commit, add a timestamp to the version.
754 # Follow the PyPA version number rules, as this will make it easier to
755 # process with other tools.
756 if version.endswith("+"):
757 version += datetime.now(timezone.utc).strftime("%Y%m%d.%H%M%S")
758
759 return version
760
761
762def package(context):

Callers 1

packageFunction · 0.70

Calls 6

globFunction · 0.90
nowMethod · 0.80
openFunction · 0.50
exitMethod · 0.45
endswithMethod · 0.45
strftimeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…