X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fenvironment.py;h=a0cb5bbce93372b63776b4ab126c916031e9f728;hb=3c1c5dcad98da4acea722edd5698cba492478c5e;hp=6e2888b960741c93eabb4a1f8bd86bd5c39b468e;hpb=a13a4b1a040e45dae0eec813f20ec6a4ee43e78a;p=tools%2Fsat.git diff --git a/src/environment.py b/src/environment.py index 6e2888b..a0cb5bb 100644 --- a/src/environment.py +++ b/src/environment.py @@ -167,7 +167,7 @@ class SalomeEnviron: """Class to manage the environment of SALOME. """ - def __init__(self, cfg, environ, forBuild=False): + def __init__(self, cfg, environ, forBuild=False, for_package=None): '''Initialization. :param cfg Config: the global config @@ -175,10 +175,13 @@ class SalomeEnviron: to store the environment variables :param forBuild bool: If true, it is a launch environment, else a build one + :param for_package str: If not None, produce a relative environment + designed for a package. ''' self.environ = environ self.cfg = cfg self.forBuild = forBuild + self.for_package = for_package self.silent = False def __repr__(self): @@ -339,7 +342,8 @@ class SalomeEnviron: self.add_line(1) # If there is profile (SALOME), then define additional variables - if 'profile' in self.cfg.APPLICATION: + if ('profile' in self.cfg.APPLICATION and + "product" in self.cfg.APPLICATION.profile): profile_product = self.cfg.APPLICATION.profile.product product_info_profile = src.product.get_product_config(self.cfg, profile_product) @@ -372,12 +376,13 @@ class SalomeEnviron: elif not self.silent: logger.write(" " + _("No install_dir for product %s\n") % product_info.name, 5) - - # set source dir, unless no source dir - if not src.product.product_is_fixed(product_info): - src_dir = product_info.name + "_SRC_DIR" - if not self.is_defined(src_dir): - self.set(src_dir, product_info.source_dir) + + if not self.for_package: + # set source dir, unless no source dir + if not src.product.product_is_fixed(product_info): + src_dir = product_info.name + "_SRC_DIR" + if not self.is_defined(src_dir): + self.set(src_dir, product_info.source_dir) def set_salome_generic_product_env(self, product): """Sets the generic environment for a SALOME product. @@ -474,10 +479,13 @@ class SalomeEnviron: :param product str: The product name :param logger Logger: The logger instance to display messages """ - + # Get the informations corresponding to the product pi = src.product.get_product_config(self.cfg, product) + if self.for_package: + pi.install_dir = os.path.join(self.for_package, pi.name) + # Do not define environment if the product is native if src.product.product_is_native(pi): return @@ -487,6 +495,12 @@ class SalomeEnviron: self.add_line(1) self.add_comment('setting environ for ' + product) + + # Set an additional environment for SALOME products + if src.product.product_is_salome(pi): + # set environment using definition of the product + self.set_salome_minimal_product_env(pi, logger) + self.set_salome_generic_product_env(product) # Put the environment define in the configuration of the product if "environ" in pi: @@ -499,11 +513,7 @@ class SalomeEnviron: if 'env_script' in pi.environ: self.run_env_script(pi, logger) - # Set an additional environment for SALOME products - if src.product.product_is_salome(pi): - # set environment using definition of the product - self.set_salome_minimal_product_env(pi, logger) - self.set_salome_generic_product_env(product) + def run_env_script(self, product_info, logger=None): @@ -667,24 +677,32 @@ class FileEnvWriter: return env_file.name - def write_cfgForPy_file(self, filename, additional_env = {}): + def write_cfgForPy_file(self, + filename, + additional_env = {}, + for_package = None): """Append to current opened aFile a cfgForPy environment (SALOME python launcher). :param filename str: the file path :param additional_env dict: a dictionary of additional variables to add to the environment + :param for_package str: If not None, produce a relative environment + designed for a package. """ if not self.silent: self.logger.write(_("Create configuration file %s\n") % - src.printcolors.printcLabel(aFile.name), 3) + src.printcolors.printcLabel(filename.name), 3) # create then env object tmp = src.fileEnviron.get_file_environ(filename, "cfgForPy", {}) # environment for launch - env = SalomeEnviron(self.config, tmp, forBuild=False) + env = SalomeEnviron(self.config, + tmp, + forBuild=False, + for_package=for_package) env.silent = self.silent if self.env_info is not None: