Commit 297a0578 authored by Alejandro Homs Puron's avatar Alejandro Homs Puron

* (Core) dependency link version support: policy in [LIMA_]LINK_STRICT_VERSION

parent 0d283168
......@@ -31,9 +31,9 @@ def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
env_var_name = 'LIMA_%s_VERSION' % mod_name.upper()
try:
if env_var_name in os.environ:
version = os.environ[env_var_name]
except KeyError:
else:
version = 'LAST'
req_version = version
......@@ -42,6 +42,7 @@ if version.upper() == 'LAST':
version_dirs = [x for x in os.listdir(root_name) if x.startswith('v')]
version_dirs.sort(version_cmp)
version = version_dirs[-1]
del version_dirs, x
else:
if version[0] != 'v':
version = 'v' + version
......@@ -50,6 +51,13 @@ mod_path = os.path.join(root_name, version)
if not (os.path.isdir(mod_path) or os.path.islink(mod_path)):
raise ImportError('Invalid %s: %s' % (env_var_name, req_version))
if os.environ['LIMA_LINK_STRICT_VERSION'] == 'FULL':
core_version_fname = os.path.join(mod_path, 'CORE_VERSION')
core_version_file = open(core_version_fname, 'rt')
core_version = core_version_file.readline().strip()
os.environ['LIMA_CORE_VERSION'] = core_version
del core_version_fname, core_version_file, core_version
__path__.append(mod_path)
ld_open_flags = sys.getdlopenflags()
......@@ -60,6 +68,6 @@ globals().update(_A.__dict__)
sys.setdlopenflags(ld_open_flags)
del root_name, mod_name, mod_path, x, env_var_name
del version, req_version, version_dirs, version_code, version_cmp
del root_name, mod_name, mod_path, env_var_name
del version, req_version, version_code, version_cmp
del os, sys, imp, glob, DLFCN
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment