MCPcopy Create free account
hub / github.com/apple/coremltools / build_expected_version_hex

Function build_expected_version_hex

deps/pybind11/setup.py:27–48  ·  view source on GitHub ↗
(matches: dict[str, str])

Source from the content-addressed store, hash-verified

25
26
27def build_expected_version_hex(matches: dict[str, str]) -> str:
28 patch_level_serial = matches["PATCH"]
29 serial = None
30 major = int(matches["MAJOR"])
31 minor = int(matches["MINOR"])
32 flds = patch_level_serial.split(".")
33 if flds:
34 patch = int(flds[0])
35 if len(flds) == 1:
36 level = "0"
37 serial = 0
38 elif len(flds) == 2:
39 level_serial = flds[1]
40 for level in ("a", "b", "c", "dev"):
41 if level_serial.startswith(level):
42 serial = int(level_serial[len(level) :])
43 break
44 if serial is None:
45 msg = f'Invalid PYBIND11_VERSION_PATCH: "{patch_level_serial}"'
46 raise RuntimeError(msg)
47 version_hex_str = f"{major:02x}{minor:02x}{patch:02x}{level[:1]}{serial:x}"
48 return f"0x{version_hex_str.upper()}"
49
50
51# PYBIND11_GLOBAL_SDIST will build a different sdist, with the python-headers

Callers 1

setup.pyFile · 0.85

Calls 2

intClass · 0.85
lenFunction · 0.50

Tested by

no test coverage detected