@@ -18,14 +18,27 @@ def get_acorn_version(repo_path: Path) -> str:
1818
1919def get_brotli_version (repo_path : Path ) -> str :
2020 with open (repo_path / "deps/brotli/c/common/version.h" , "r" ) as f :
21- matches = re .search ("#define BROTLI_VERSION (?P<version>.*)" , f .read ())
21+ header_contents = f .read ()
22+ # Newer versions of brotli define MAJOR, MINOR, PATCH separately.
23+ matches = re .search (
24+ "#define BROTLI_VERSION_MAJOR (?P<major>.*)\n "
25+ "#define BROTLI_VERSION_MINOR (?P<minor>.*)\n "
26+ "#define BROTLI_VERSION_PATCH (?P<patch>.*)" ,
27+ header_contents ,
28+ re .MULTILINE ,
29+ )
2230 if matches is None :
23- raise RuntimeError ("Error extracting version number for brotli" )
24- hex_version = matches .groupdict ()["version" ]
25- major_version = int (hex_version , 16 ) >> 24
26- minor_version = int (hex_version , 16 ) >> 12 & 0xFF
27- patch_version = int (hex_version , 16 ) & 0xFFFFF
28- return f"{ major_version } .{ minor_version } .{ patch_version } "
31+ # Older versions of brotli hex encode the version as a literal.
32+ matches = re .search ("#define BROTLI_VERSION (?P<version>.*)" , header_contents )
33+ if matches is None :
34+ raise RuntimeError ("Error extracting version number for brotli" )
35+ hex_version = matches .groupdict ()["version" ]
36+ major_version = int (hex_version , 16 ) >> 24
37+ minor_version = int (hex_version , 16 ) >> 12 & 0xFF
38+ patch_version = int (hex_version , 16 ) & 0xFFFFF
39+ return f"{ major_version } .{ minor_version } .{ patch_version } "
40+ versions = matches .groupdict ()
41+ return f"{ versions ['major' ]} .{ versions ['minor' ]} .{ versions ['patch' ]} "
2942
3043
3144def get_c_ares_version (repo_path : Path ) -> str :
0 commit comments