:param value str: the value to append to key
:param sep str: the separator string
"""
- for c in [";", ":"]: # windows or linux path separators
- if c in value:
- raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
+ # check that value so no contain the system separator
+ separator=os.pathsep
+ if separator in value:
+ raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator))
+
# check if the key is already in the environment
if key in self.environ:
value_list = self.environ[key].split(sep)
:param value str: the value to prepend to key
:param sep str: the separator string
"""
- for c in [";", ":"]: # windows or linux path separators
- if c in value:
- raise Exception("Environ prepend key '%s' value '%s' contains forbidden character '%s'" % (key, value, c))
+ # check that value so no contain the system separator
+ separator=os.pathsep
+ if separator in value:
+ raise Exception("Environ append key '%s' value '%s' contains forbidden character '%s'" % (key, value, separator))
+
# check if the key is already in the environment
if key in self.environ:
value_list = self.environ[key].split(sep)
else:
return ""
+ def get_value(self, key):
+ """\
+ Get the value of the environment variable "key"
+ This method is added for API compatibility with FileEnviron class
+
+ :param key str: the environment variable
+ """
+ return self.get(key)
+
def command_value(self, key, command):
"""\
Get the value given by the system command "command"
self.for_package = for_package
self.enable_simple_env_script = enable_simple_env_script
self.silent = False
+ self.has_python = False
def __repr__(self):
"""easy almost exhaustive quick resume for debug print"""
"""
return self.environ.get(key)
+ def get_value(self, key):
+ """\
+ Get the real value of the environment variable "key"
+ This method is added for API compatibility with FileEnviron class
+
+ :param key str: the environment variable
+ """
+ if key in self.environ:
+ return self.environ[key]
+ else:
+ return ""
+
def set(self, key, value):
"""\
Set the environment variable "key" to value "value"
self.python_lib0 = self.get('PYTHON_LIBDIR0')
self.python_lib1 = self.get('PYTHON_LIBDIR1')
+ self.has_python = True
def get_names(self, lProducts):
"""\
lProdName.append(ProdName)
return lProdName
- def set_application_env(self, logger, no_PRODUCT_ROOT_DIR=False):
+ def set_application_env(self, logger):
"""\
Sets the environment defined in the APPLICATION file.
:param logger Logger: The logger instance to display messages
"""
- # add variable PRODUCT_ROOT_DIR as $workdir in APPLICATION.environ section if not present
- # but if sat launcher or sat package do not duplicate line context.setVariable(r"PRODUCT_ROOT_DIR", ...
- # no_PRODUCT_ROOT_DIR used only for write_cfgForPy_file
- if not no_PRODUCT_ROOT_DIR: # do not duplicate context.setVariable(r"PRODUCT_ROOT_DIR"
- try:
- tmp = self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR
- except:
- self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR = src.pyconf.Reference(self.cfg, src.pyconf.DOLLAR, "workdir")
- DBG.write("set_application_env: add APPLICATION.environ.PRODUCT_ROOT_DIR", self.cfg.APPLICATION.environ)
-
+ if self.for_package:
+ self.set("PRODUCT_ROOT_DIR", "out_dir_Path")
+ else:
+ self.cfg.APPLICATION.environ.PRODUCT_ROOT_DIR = src.pyconf.Reference(self.cfg, src.pyconf.DOLLAR, "workdir")
+
+ # these sensitive variables are reset to avoid bad environment interactions
+ self.add_line(1)
+ self.add_comment("reset these sensitive variables to avoid bad environment interactions")
+ self.add_comment("comment these to lines if you wish a different behaviour")
+ self.set("LD_LIBRARY_PATH", "")
+ self.set("PYTHONPATH", "")
+ self.add_line(1)
+
# Set the variables defined in the "environ" section
if 'environ' in self.cfg.APPLICATION:
# we write PRODUCT environment it in order to conform to
lib_path = os.path.join(envcompo_root_dir, 'lib', 'salome')
l_binpath_libpath.append( (bin_path, lib_path) )
+
if src.get_property_in_product_cfg(pi, "fhs"):
lib_path = os.path.join(env_root_dir, 'lib')
- pylib1_path = os.path.join(env_root_dir, self.python_lib0)
- pylib2_path = os.path.join(env_root_dir, self.python_lib1)
bin_path = os.path.join(env_root_dir, 'bin')
+ if self.has_python:
+ # if the application doesn't include python, we don't need these two lines
+ pylib1_path = os.path.join(env_root_dir, self.python_lib0)
+ pylib2_path = os.path.join(env_root_dir, self.python_lib1)
else:
lib_path = os.path.join(env_root_dir, 'lib', 'salome')
- pylib1_path = os.path.join(env_root_dir, self.python_lib0, 'salome')
- pylib2_path = os.path.join(env_root_dir, self.python_lib1, 'salome')
bin_path = os.path.join(env_root_dir, 'bin', 'salome')
+ if self.has_python:
+ # if the application doesn't include python, we don't need these two lines
+ pylib1_path = os.path.join(env_root_dir, self.python_lib0, 'salome')
+ pylib2_path = os.path.join(env_root_dir, self.python_lib1, 'salome')
# Construct the paths to prepend to PATH and LD_LIBRARY_PATH and
# PYTHONPATH
else :
self.prepend('LD_LIBRARY_PATH', lib_path)
- l = [ bin_path, lib_path, pylib1_path, pylib2_path ]
- self.prepend('PYTHONPATH', l)
+ l = [ bin_path, lib_path ]
+ if not src.product.product_is_wheel(pi):
+ if self.has_python:
+ l.append(pylib1_path)
+ l.append(pylib2_path)
+ self.prepend('PYTHONPATH', l)
def set_cpp_env(self, product_info):
"""\
else :
self.prepend('LD_LIBRARY_PATH', lib_path)
- l = [ bin_path, lib_path,
- os.path.join(env_root_dir, self.python_lib0),
- os.path.join(env_root_dir, self.python_lib1)
- ]
+ l = [ bin_path, lib_path ]
+ if self.has_python:
+ l.append(os.path.join(env_root_dir, self.python_lib0))
+ l.append(os.path.join(env_root_dir, self.python_lib1))
self.prepend('PYTHONPATH', l)
def load_cfg_environment(self, cfg_env):
# Get the informations corresponding to the product
pi = src.product.get_product_config(self.cfg, product)
+
+ # skip compile time products at run time
+ if not self.forBuild:
+ if src.product.product_is_compile_time(pi):
+ return
# skip mesa products (if any) at run time,
# unless use_mesa property was activated
source_dir_save = pi.source_dir
name_save = pi.name
pi.install_dir = os.path.join(self.cfg.APPLICATION.workdir,
- "INSTALL",
+ config.INTERNAL.config.install_dir,
pi.component_name)
if self.for_package:
pi.install_dir = os.path.join("out_dir_Path",
product_info.install_dir,
product_info.version)
else:
- # at least this one is mandatoryi,
+ # at least this one is mandatory,
# if set_env_build and set_env_build are not defined
pyproduct.set_env(self,
product_info.install_dir,
# set product environ
self.set_application_env(logger)
- self.set_python_libdirs()
+ if "Python" in env_info:
+ self.set_a_product("Python", logger)
+ self.set_python_libdirs()
# set products
for product in env_info:
+ if product == "Python":
+ continue
self.set_a_product(product, logger)
class FileEnvWriter:
else:
# set env from PRODUCT
- env.set_application_env(self.logger, no_PRODUCT_ROOT_DIR=True)
+ env.set_application_env(self.logger)
# The list of products to launch
lProductsName = env.get_names(self.config.APPLICATION.products.keys())
# set the products
env.set_products(self.logger, src_root=self.src_root)
- DBG.write("set_application_env without PRODUCT_ROOT_DIR", self.config.APPLICATION.environ)
# Add the additional environment if it is not empty
if len(additional_env) != 0: