aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorEugene Kliuchnikov <eustas@google.com>2016-08-22 15:44:12 +0200
committerEugene Kliuchnikov <eustas@google.com>2016-08-22 15:44:12 +0200
commit2c2d5578a6a65819deeeea64aeaf3e911038a9f5 (patch)
treec214b8dd8d9c437f0ab4d7384ff55ce0108feb04 /setup.py
parent313066a0370ff1e713e9891d88fb28ab834d5031 (diff)
downloadbrotli-2c2d5578a6a65819deeeea64aeaf3e911038a9f5.zip
brotli-2c2d5578a6a65819deeeea64aeaf3e911038a9f5.tar.gz
brotli-2c2d5578a6a65819deeeea64aeaf3e911038a9f5.tar.bz2
Use version from common/version.h
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/setup.py b/setup.py
index 477c57e..5e4278b 100644
--- a/setup.py
+++ b/setup.py
@@ -15,14 +15,17 @@ CURR_DIR = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
def get_version():
- """ Return BROTLI_VERSION string as defined in 'tools/version.h' file. """
- brotlimodule = os.path.join(CURR_DIR, 'tools', 'version.h')
+ """ Return BROTLI_VERSION string as defined in 'common/version.h' file. """
+ brotlimodule = os.path.join(CURR_DIR, 'common', 'version.h')
+ version = 0
with open(brotlimodule, 'r') as f:
for line in f:
- m = re.match(r'#define\sBROTLI_VERSION\s"(.*)"', line)
+ m = re.match(r'#define\sBROTLI_VERSION\s+0x([0-9a-fA-F])', line)
if m:
- return m.group(1)
- return ""
+ version = int(m.group(1), 16)
+ if version == 0:
+ return ""
+ return "{0}.{1}.{2}".format(version >> 24, (version >> 12) & 0xFFF, version & 0xFFF)
class TestCommand(Command):
@@ -146,6 +149,7 @@ brotli = Extension("brotli",
"common/constants.h",
"common/dictionary.h",
"common/port.h",
+ "common/version.h",
"dec/bit_reader.h",
"dec/context.h",
"dec/huffman.h",