From 62523f7a7e08eda4ac9fc4204bd201ab49110779 Mon Sep 17 00:00:00 2001 From: Max KvR Date: Mon, 2 Sep 2024 10:45:45 +0200 Subject: [PATCH] bug: Protoc --version dropped major version. eg. 3.27.1 --> 27.1 updated code quality --- setup.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 077d69a9..a2909284 100755 --- a/setup.py +++ b/setup.py @@ -42,11 +42,22 @@ def _find_protoc() -> str | None: def _get_protoc_version(protoc: str) -> tuple[int, int, int]: protoc_version_string = str(subprocess.check_output([protoc, "--version"])) version_search = re.search( - r"((?P(0|[1-9]\d*))\.(?P(0|[1-9]\d*))\.(?P(0|[1-9]\d*)))", + r"(((?P(0|[1-9]\d*))\.)?(?P(0|[1-9]\d*))\.(?P(0|[1-9]\d*)))", protoc_version_string, ) - return tuple(int(version_search.group(g)) for g in ("major", "minor", "patch")) # type: ignore + if version_search is None: + raise ValueError("Invalid protoc version supplied") + + return ( + int( + version_search.group("major") + if version_search.group("major") is not None + else 3 + ), + int(version_search.group("minor")), + int(version_search.group("patch")), + ) _executable: str | None _version: tuple[int, int, int] | None @@ -113,10 +124,7 @@ def make_protobuf_requirement(major: int, minor: int, patch: int) -> str: # This encodes on which minor protobuf version the major python protobuf # version was bumped - protobuf_version_mapping = ( - (3, 0), - (4, 21), - ) + protobuf_version_mapping = ((3, 0), (4, 21), (5, 26)) # We must subtract one because bisect gives the insertion point after... py_major = protobuf_version_mapping[