From: Anthony Geay Date: Thu, 30 Jan 2020 09:22:13 +0000 (+0100) Subject: Revert "Revert "bos #18467 [CEA] Remove any addition to the environment at launch... X-Git-Tag: EMC2P_V_1_2_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f5ce58fd8eec1fbfd8c21ab989632e1f55922da;p=modules%2Fkernel.git Revert "Revert "bos #18467 [CEA] Remove any addition to the environment at launch done by runSalome"" This reverts commit b89278d39d8754cfd07cb3e7960eaf1d7a992239. --- diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 1a5984cd7..6c51ecc93 100644 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -832,7 +832,7 @@ Python file arguments, if any, must be comma-separated (without blank characters args = {} #def get_env(): #args = [] -def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None): +def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvironment=True): ### # Collect launch configuration files: # - The environment variable "Config" (SalomeAppConfig) which can @@ -895,19 +895,18 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None): else: dirs += re.split('[;|:]', os.getenv(config_var)) - gui_available = False - if os.getenv("GUI_ROOT_DIR"): - gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"),'share','salome','resources','gui') - if os.path.isdir(gui_resources_dir): - gui_available = True - dirs.append(gui_resources_dir) - pass - if not gui_available: - kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"),'bin','salome','appliskel') - if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir ): - dirs.append(kernel_resources_dir) - pass - os.environ[config_var] = os.pathsep.join(dirs) + if not keepEnvironment: + if os.getenv("GUI_ROOT_DIR") and os.path.isdir(os.getenv("GUI_ROOT_DIR")): + gui_resources_dir = os.path.join(os.getenv("GUI_ROOT_DIR"),'share','salome','resources','gui') + if os.path.isdir(gui_resources_dir): + dirs.append(gui_resources_dir) + pass + else: + kernel_resources_dir = os.path.join(os.getenv("KERNEL_ROOT_DIR"),'bin','salome','appliskel') + if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( kernel_resources_dir ): + dirs.append(kernel_resources_dir) + pass + os.environ[config_var] = os.pathsep.join(dirs) dirs.reverse() # reverse order, like in "path" variable - FILO-style processing @@ -992,7 +991,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None): if cmd_opts.batch is not None: args[batch_nam] = True - if not gui_available: + if not os.getenv("GUI_ROOT_DIR") or not os.path.isdir(os.getenv("GUI_ROOT_DIR")): args[gui_nam] = False if args[gui_nam]: @@ -1184,6 +1183,8 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None): args[lang_nam] = cmd_opts.language # return arguments - os.environ[config_var] = os.pathsep.join(dirs) + if not keepEnvironment: + os.environ[config_var] = os.pathsep.join(dirs) + # print("Args: ", args) return args diff --git a/bin/runSalome.py b/bin/runSalome.py index e51e08cb2..d1cdc6000 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -810,7 +810,8 @@ def main(exeName=None): sys.exit(1) from salome_utils import getHostName - args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName) + keep_env = not os.getenv('SALOME_PLEASE_SETUP_ENVIRONMENT_AS_BEFORE') + args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName, keepEnvironment=keep_env) print("runSalome running on %s" % getHostName()) kill_salome(args) @@ -828,7 +829,7 @@ def main(exeName=None): pass # -- #setenv.main() - setenv.set_env(args, modules_list, modules_root_dir) + setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env) clt = useSalome(args, modules_list, modules_root_dir) return clt,args diff --git a/bin/setenv.py b/bin/setenv.py index ec968d5e3..7ad4a8fb8 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -77,7 +77,7 @@ def get_lib_dir(): # ----------------------------------------------------------------------------- -def get_config(silent=False, exeName=None): +def get_config(silent=False, exeName=None, keepEnvironment=True): """ Get list of modules, paths. @@ -90,7 +90,7 @@ def get_config(silent=False, exeName=None): import launchConfigureParser - args = launchConfigureParser.get_env(exeName=exeName) + args = launchConfigureParser.get_env(exeName=exeName, keepEnvironment=keepEnvironment) # Check variables _ROOT_DIR @@ -140,7 +140,7 @@ def get_config(silent=False, exeName=None): # ----------------------------------------------------------------------------- -def set_env(args, modules_list, modules_root_dir, silent=False): +def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=True): """Add to the PATH-variables modules specific paths""" import os @@ -167,66 +167,68 @@ def set_env(args, modules_list, modules_root_dir, silent=False): os.putenv('SALOME_BATCH','0') if args["gui"] : modules_list = modules_list[:] + ["GUI"] - modules_list = modules_list[:] + ["KERNEL"] - for module in modules_list : - if module in modules_root_dir: - module_root_dir = modules_root_dir[module] - if module_root_dir not in modules_root_dir_list: - modules_root_dir_list[:0] = [module_root_dir] - if sys.platform == "win32": - add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), - "PATH") - elif sys.platform == "darwin": - add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), - "DYLD_LIBRARY_PATH") - else: - add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), - "LD_LIBRARY_PATH") - add_path(os.path.join(module_root_dir,"bin",salome_subdir), - "PATH") - if os.path.exists(os.path.join(module_root_dir, "examples")): - add_path(os.path.join(module_root_dir,"examples"), + if not keepEnvironment: + modules_list = modules_list[:] + ["KERNEL"] + for module in modules_list : + if module in modules_root_dir: + module_root_dir = modules_root_dir[module] + if module_root_dir not in modules_root_dir_list: + modules_root_dir_list[:0] = [module_root_dir] + if sys.platform == "win32": + add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), + "PATH") + elif sys.platform == "darwin": + add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), + "DYLD_LIBRARY_PATH") + else: + add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), + "LD_LIBRARY_PATH") + add_path(os.path.join(module_root_dir,"bin",salome_subdir), + "PATH") + if os.path.exists(os.path.join(module_root_dir, "examples")): + add_path(os.path.join(module_root_dir,"examples"), + "PYTHONPATH") + pass + add_path(os.path.join(module_root_dir,"bin",salome_subdir), "PYTHONPATH") - pass - add_path(os.path.join(module_root_dir,"bin",salome_subdir), - "PYTHONPATH") - # add lib before site-packages to load script instead of dll if any (win32 platform) - add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), - "PYTHONPATH") - add_path(os.path.join(module_root_dir,get_lib_dir(), - python_version,"site-packages", - salome_subdir), - "PYTHONPATH") - import platform - if platform.machine() == "x86_64": - add_path(os.path.join(module_root_dir,"lib64", + # add lib before site-packages to load script instead of dll if any (win32 platform) + add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), + "PYTHONPATH") + add_path(os.path.join(module_root_dir,get_lib_dir(), python_version,"site-packages", salome_subdir), "PYTHONPATH") - pass - add_path(os.path.join(module_root_dir,get_lib_dir(), - python_version,"site-packages", - salome_subdir, - "shared_modules"), - "PYTHONPATH") - - # set environment by modules from the list - if port: - try: - mod=__import__(module.lower()+"_setenv") - mod.set_env(args) + import platform + if platform.machine() == "x86_64": + add_path(os.path.join(module_root_dir,"lib64", + python_version,"site-packages", + salome_subdir), + "PYTHONPATH") pass - except: + add_path(os.path.join(module_root_dir,get_lib_dir(), + python_version,"site-packages", + salome_subdir, + "shared_modules"), + "PYTHONPATH") + + # set environment by modules from the list + if port: + try: + mod=__import__(module.lower()+"_setenv") + mod.set_env(args) + pass + except: + pass pass pass pass - pass - if sys.platform == 'win32': - os.environ["SALOMEPATH"]=";".join(modules_root_dir_list) - else: - os.environ["SALOMEPATH"]=":".join(modules_root_dir_list) + if sys.platform == 'win32': + os.environ["SALOMEPATH"]=";".join(modules_root_dir_list) + else: + os.environ["SALOMEPATH"]=":".join(modules_root_dir_list) + pass # set trace environment variable if "SALOME_trace" not in os.environ: