Commit c3ae4adc authored by Alejandro Homs Puron's avatar Alejandro Homs Puron

* Using dependency minor version as default (not strict) link policy

  + Full release version (strict) link policy left as an option in config.inc
* Added module_helper to unify link dependency version control
* Introduced macros in build/Makefile to simplify common plug-in blocks
parent 2deca678
This diff is collapsed.
adsc @ 8ecf062f
Subproject commit b44fff5d856e6e2ae522f6a23dea52b2549f8e3b
Subproject commit 8ecf062fab988b67afbe407d144e5286a227ccd6
andor @ 5f160efb
Subproject commit 297a05787af4ee228c38e1718be73fdb38cf4dbc
Subproject commit 5f160efba768e8bc9bfd9874becb641485d78698
basler @ 057c53c3
Subproject commit ffb15c22d1d09e6cc599cb882797da2226cd37fd
Subproject commit 057c53c335b3f3a55bc35f0f525a93193482acbb
espia @ 3f70f69c
Subproject commit 773356279006b425989ce4bc5529a311405e00ec
Subproject commit 3f70f69c02aee7e941ecaa96cfe67d6241892710
frelon @ 4edce4af
Subproject commit 01b8165307f202287021566699afeca212b97fb9
Subproject commit 4edce4af8a71e72f9c69ae89a15ad10946e16a0e
maxipix @ 4fdad20d
Subproject commit 47c0efca287c034b8fb44227069b1babf3ab4324
Subproject commit 4fdad20da3b936832c149768896b0004750b1bd7
mythen @ 6e6395ba
Subproject commit 2e1123f6876066434c55d6de8055b664943f1aad
Subproject commit 6e6395ba9520e14ffcf7e335981873642ec96dca
pco @ 60260861
Subproject commit 6cd9133852d5bb860da639e020fa6ef0a64e0e67
Subproject commit 602608617a17ce395d34a1e0f7652a65ee22f926
pilatus @ 3194fc78
Subproject commit 7d70cdee2c4cd3566eabc7f9d1a26a58b1a04dd6
Subproject commit 3194fc78f8c8962de7e58985b6fd778ce6e11368
prosilica @ ab571e46
Subproject commit e140eb20d38051422c5806557564818e379efca3
Subproject commit ab571e46af955348b65e87d24150ace258aae79c
roperscientific @ 598892c8
Subproject commit 5e1b9daeb55b9e5561b3da997e658b10a1ca8f49
Subproject commit 598892c8ca7236f303ad1e1607656806f5708366
......@@ -19,55 +19,23 @@
# 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()
try:
version = os.environ[env_var_name]
except KeyError:
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.Simulator.limasimulator import Simulator as _S
globals().update(_S.__dict__)
sys.setdlopenflags(ld_open_flags)
module_helper.load_cleanup(cleanup_data)
del mod_path, depends_on, has_dependent, cleanup_data
del module_helper
del root_name, mod_name, mod_path, env_var_name
del version, req_version, version_code, version_cmp
del os, sys, imp, glob, DLFCN
ueye @ 38c0597d
Subproject commit 5caf54073e181297104de3f4abca9b62f6f3a114
Subproject commit 38c0597d4b93701d793b12c11cce406053f64b4c
xpad @ 9d8e21a2
Subproject commit b2921a129c5ef940e36a22171f5e37b932a64aa4
Subproject commit 9d8e21a290276dfbf2515fb0809078717ebc9172
......@@ -19,51 +19,19 @@
# 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 = None
has_dependent = True
def version_code(s):
return map(int, s.strip('v').split('.'))
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
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))
sys.path.insert(0, mod_path)
ld_open_flags = sys.getdlopenflags()
sys.setdlopenflags(ld_open_flags | DLFCN.RTLD_GLOBAL)
cleanup_data = module_helper.load_prepare(mod_path, depends_on, has_dependent)
import processlib as Processlib
from limacore import *
from Debug import *
sys.setdlopenflags(ld_open_flags)
sys.path.remove(mod_path)
module_helper.load_cleanup(cleanup_data)
del root_name, mod_name, mod_path, env_var_name, ld_open_flags
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
......@@ -40,7 +40,7 @@ COMPILE_PHOTONICSCIENCE=0
COMPILE_CBF_SAVING=0
COMPILE_NXS_SAVING=0
COMPILE_FITS_SAVING=0
LINK_STRICT_VERSION=1
LINK_STRICT_VERSION=0
export COMPILE_CORE COMPILE_SPS_IMAGE COMPILE_SIMULATOR \
COMPILE_ESPIA COMPILE_FRELON COMPILE_MAXIPIX COMPILE_PILATUS \
COMPILE_BASLER COMPILE_PROSILICA COMPILE_ROPERSCIENTIFIC COMPILE_ADSC \
......
......@@ -52,7 +52,7 @@ INSTALL_LIBADD =
INSTALL_DEPS = install.mkdir
ifeq ($(LINK_STRICT_VERSION),0)
ENV_LINK_STRICT_VER = 'MAJOR'
ENV_LINK_STRICT_VER = 'MINOR'
else
ENV_LINK_STRICT_VER = 'FULL'
endif
......@@ -187,6 +187,8 @@ install.mkdir:
mkdir -p $(INSTALL_LIMA_DIR)
sed $(GLOB_PYTHON_INIT_SED) python/__init__.py > \
$(INSTALL_LIMA_DIR)/__init__.py
mkdir -p $(INSTALL_PLAT_DIR)
cp python/module_helper.py $(INSTALL_PLAT_DIR)
mkdir -p $(INSTALL_LIB_DIR)
mkdir -p $(INSTALL_INCLUDE_DIR)
mkdir -p $(INSTALL_PKG_CONFIG_DIR)
......
......@@ -33,16 +33,22 @@ for d in csadmin_dirs:
break
if get_os is not None:
compat_plat = os.popen(get_os).readline().strip()
for aux_plat in compat_plat.split():
plat = None
compat_plat_list = compat_plat.split()
for aux_plat in compat_plat_list:
if aux_plat.strip() in os.listdir(root_name):
plat = aux_plat
break
if plat is None:
raise ImportError, ('Could not find Lima directory for %s '
'(nor compat. %s) platform(s) at %s' %
(compat_plat_list[0],
compat_plat_list[1:], root_name))
lima_plat = os.path.join(root_name, plat)
__path__.insert(0, lima_plat)
# This mandatory variable is systematically overwritten by 'make install'
os.environ['LIMA_LINK_STRICT_VERSION'] = 'FULL'
os.environ['LIMA_LINK_STRICT_VERSION'] = 'MINOR'
if get_os is not None:
all_dirs = os.listdir(lima_plat)
......
############################################################################
# This file is part of LImA, a Library for Image Acquisition
#
# Copyright (C) : 2009-2011
# European Synchrotron Radiation Facility
# BP 220, Grenoble 38043
# FRANCE
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# 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, re, DLFCN
VSEP = '.'
version_re = re.compile('v?([0-9]+)(\\.([0-9]+)(\\.([0-9]+))?)?')
def version_code(s):
return map(int, s.strip('v').split(VSEP))
def version_cmp(x, y):
return cmp(version_code(x), version_code(y))
def good_version_dir(v, r, f):
m = version_re.match(v)
d = os.path.join(r, v)
if not (m and m.group(5) and v.startswith('v') and
(os.path.isdir(d) or os.path.islink(d))):
return False
c = version_code(v)[:len(f)]
return c == f
def load_prepare(mod_path, depends_on, has_dependent):
root_name = mod_path[0]
mod_name = os.path.basename(root_name)
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'
if version.upper() == 'LAST':
version_filter = []
elif version_re.match(version):
version_filter = version_code(version)
else:
raise ImportError('Invalid %s: %s' % (env_var_name, version))
def good_dir(v, r=root_name, f=version_filter):
return good_version_dir(v, r, f)
version_dirs = [x for x in os.listdir(root_name) if good_dir(x)]
if not version_dirs:
raise ImportError('Invalid %s: %s' % (env_var_name, version))
version_dirs.sort(version_cmp)
version = version_dirs[-1]
mod_dir = os.path.join(root_name, version)
ld_open_flags = sys.getdlopenflags()
cleanup_data = mod_path, mod_dir, ld_open_flags, has_dependent
if not depends_on:
return load_ld_prepare(cleanup_data)
cap_dep = depends_on.upper()
dep_version_fname = os.path.join(mod_dir, '%s_VERSION' % cap_dep)
dep_version_file = open(dep_version_fname, 'rt')
dep_version = dep_version_file.readline().strip()
link_strict_version = os.environ['LIMA_LINK_STRICT_VERSION']
if link_strict_version == 'MINOR':
dep_version = VSEP.join(dep_version.split(VSEP)[:2])
elif link_strict_version != 'FULL':
raise ImportError('Invalid LIMA_LINK_STRICT_VERSION var: %s' %
link_strict_version)
env_var_name = 'LIMA_%s_VERSION' % cap_dep
os.environ[env_var_name] = dep_version
return cleanup_data
def load_ld_prepare(cleanup_data):
mod_path, mod_dir, ld_open_flags, has_dependent = cleanup_data
sys.setdlopenflags(ld_open_flags | DLFCN.RTLD_GLOBAL)
if has_dependent:
sys.path.insert(0, mod_dir)
else:
mod_path.append(mod_dir)
return cleanup_data
def load_dep_cleanup(cleanup_data):
return load_ld_prepare(cleanup_data)
def load_cleanup(cleanup_data):
mod_path, mod_dir, ld_open_flags, has_dependent = cleanup_data
if has_dependent:
sys.path.remove(mod_dir)
sys.setdlopenflags(ld_open_flags)
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