Skip to content

Commit b78c1ac

Browse files
committed
bug fix: _min_version_required was not comparing version numbers correctly
1 parent b535890 commit b78c1ac

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/make-bundle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface for those not familiar with the python
1212
ecosystem.
1313
1414
"""
15+
import functools
1516
import os
1617
import sys
1718
import time
@@ -155,13 +156,14 @@ def verify_preconditions():
155156
def _min_version_required(min_version, actual_version, name):
156157
# precondition: min_version is major.minor.patch
157158
# actual_version is major.minor.patch
158-
min_split = min_version.split('.')
159-
actual_split = actual_version.split('.')
160-
for minimum, actual in zip(min_split, actual_split):
161-
if int(actual) < int(minimum):
162-
raise ValueError("%s requires at least version %s, but "
163-
"version %s was found." % (name, min_version,
164-
actual_version))
159+
min_split = map(int, min_version.split('.'))
160+
actual_split = map(int, actual_version.split('.'))
161+
comp = map(cmp, actual_split, min_split)
162+
result = functools.reduce((lambda x, y: x*2 + y), comp)
163+
if result < 0:
164+
raise ValueError("%s requires at least version %s, but "
165+
"version %s was found." % (name, min_version,
166+
actual_version))
165167

166168

167169
def main():

0 commit comments

Comments
 (0)