14 version_file_data =
None
15 with open(filepath)
as fd:
16 version_file_data = fd.read()
18 patterns =
r"""#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$
19 #\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$
20 #\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$
22 regex = re.compile(patterns, re.MULTILINE)
23 version_match = regex.search(version_file_data)
25 return version_match.groups()
26 raise Exception(
"Unable to find version string.")
31 parser = argparse.ArgumentParser(description=
'Print lz4 version from lib/lz4.h')
32 parser.add_argument(
'file', help=
'path to lib/lz4.h')
33 args = parser.parse_args()
35 print(
'.'.join(version_tuple))
38 if __name__ ==
'__main__':
def find_version_tuple(filepath)