Commit 5f160efb authored by Alejandro Homs Puron's avatar Alejandro Homs Puron

* Using module_helper to handle link dependency version control

parent 297a0578
......@@ -19,55 +19,22 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################
import os, sys, imp, glob, DLFCN
from Lima import module_helper
root_name = __path__[0]
mod_name = os.path.basename(root_name)
mod_path = __path__
depends_on = 'Core'
has_dependent = False
def version_code(s):
return map(int, s.strip('v').split('.'))
cleanup_data = module_helper.load_prepare(mod_path, depends_on, has_dependent)
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
from Lima import Core
env_var_name = 'LIMA_%s_VERSION' % mod_name.upper()
if env_var_name in os.environ:
version = os.environ[env_var_name]
else:
version = 'LAST'
req_version = version
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
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()
sys.setdlopenflags(ld_open_flags | DLFCN.RTLD_GLOBAL)
cleanup_data = module_helper.load_dep_cleanup(cleanup_data)
from Lima.Andor.limaandor import Andor as _A
globals().update(_A.__dict__)
sys.setdlopenflags(ld_open_flags)
module_helper.load_cleanup(cleanup_data)
del root_name, mod_name, mod_path, env_var_name
del version, req_version, version_code, version_cmp
del os, sys, imp, glob, DLFCN
del mod_path, depends_on, has_dependent, cleanup_data
del module_helper
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