mirror of
https://gitlab.com/ita1024/waf.git
synced 2024-11-25 11:19:52 +01:00
Provide a replacement for distutils.version.LooseVersion
This commit is contained in:
parent
240555a979
commit
69c95b5341
@ -585,13 +585,12 @@ def check_python_module(conf, module_name, condition=''):
|
||||
if ret == 'unknown version':
|
||||
conf.fatal('Could not check the %s version' % module_name)
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
def num(*k):
|
||||
if isinstance(k[0], int):
|
||||
return LooseVersion('.'.join([str(x) for x in k]))
|
||||
return Utils.loose_version('.'.join([str(x) for x in k]))
|
||||
else:
|
||||
return LooseVersion(k[0])
|
||||
d = {'num': num, 'ver': LooseVersion(ret)}
|
||||
return Utils.loose_version(k[0])
|
||||
d = {'num': num, 'ver': Utils.loose_version(ret)}
|
||||
ev = eval(condition, {}, d)
|
||||
if not ev:
|
||||
conf.fatal('The %s version does not satisfy the requirements' % module_name)
|
||||
|
@ -870,6 +870,19 @@ def lib64():
|
||||
return '64'
|
||||
return ''
|
||||
|
||||
def loose_version(ver_str):
|
||||
# private for the time being!
|
||||
# see #2402
|
||||
lst = re.split(r'([.]|\\d+|[a-zA-Z])', ver_str)
|
||||
ver = []
|
||||
for i, val in enumerate(lst):
|
||||
try:
|
||||
ver.append(int(val))
|
||||
except ValueError:
|
||||
if val != '.':
|
||||
ver.append(val)
|
||||
return ver
|
||||
|
||||
def sane_path(p):
|
||||
# private function for the time being!
|
||||
return os.path.abspath(os.path.expanduser(p))
|
||||
|
Loading…
Reference in New Issue
Block a user