From b89278d39d8754cfd07cb3e7960eaf1d7a992239 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 22 Jan 2020 11:15:48 +0300 Subject: [PATCH] Revert "bos #18467 [CEA] Remove any addition to the environment at launch done by runSalome" This reverts commit 9f8c8f2b2fe9c5542d9221871bb40020fa9cac10. --- bin/launchConfigureParser.py | 33 ++++++----- bin/runSalome.py | 5 +- bin/setenv.py | 108 +++++++++++++++++------------------ 3 files changed, 71 insertions(+), 75 deletions(-) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 6c51ecc93..1a5984cd7 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, keepEnvironment=True): +def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None): ### # Collect launch configuration files: # - The environment variable "Config" (SalomeAppConfig) which can @@ -895,18 +895,19 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi else: dirs += re.split('[;|:]', os.getenv(config_var)) - 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) + 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) dirs.reverse() # reverse order, like in "path" variable - FILO-style processing @@ -991,7 +992,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi if cmd_opts.batch is not None: args[batch_nam] = True - if not os.getenv("GUI_ROOT_DIR") or not os.path.isdir(os.getenv("GUI_ROOT_DIR")): + if not gui_available: args[gui_nam] = False if args[gui_nam]: @@ -1183,8 +1184,6 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi args[lang_nam] = cmd_opts.language # return arguments - if not keepEnvironment: - os.environ[config_var] = os.pathsep.join(dirs) - + os.environ[config_var] = os.pathsep.join(dirs) # print("Args: ", args) return args diff --git a/bin/runSalome.py b/bin/runSalome.py index d1cdc6000..e51e08cb2 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -810,8 +810,7 @@ def main(exeName=None): sys.exit(1) from salome_utils import getHostName - 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) + args, modules_list, modules_root_dir = setenv.get_config(exeName=exeName) print("runSalome running on %s" % getHostName()) kill_salome(args) @@ -829,7 +828,7 @@ def main(exeName=None): pass # -- #setenv.main() - setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env) + setenv.set_env(args, modules_list, modules_root_dir) clt = useSalome(args, modules_list, modules_root_dir) return clt,args diff --git a/bin/setenv.py b/bin/setenv.py index 4858eb4ce..5df8fe1af 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -77,7 +77,7 @@ def get_lib_dir(): # ----------------------------------------------------------------------------- -def get_config(silent=False, exeName=None, keepEnvironment=True): +def get_config(silent=False, exeName=None): """ Get list of modules, paths. @@ -90,7 +90,7 @@ def get_config(silent=False, exeName=None, keepEnvironment=True): import launchConfigureParser - args = launchConfigureParser.get_env(exeName=exeName, keepEnvironment=keepEnvironment) + args = launchConfigureParser.get_env(exeName=exeName) # Check variables _ROOT_DIR @@ -140,7 +140,7 @@ def get_config(silent=False, exeName=None, keepEnvironment=True): # ----------------------------------------------------------------------------- -def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=True): +def set_env(args, modules_list, modules_root_dir, silent=False): """Add to the PATH-variables modules specific paths""" import os @@ -167,68 +167,66 @@ def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment= os.putenv('SALOME_BATCH','0') if args["gui"] : modules_list = modules_list[:] + ["GUI"] - 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") - # 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), + 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") - add_path(os.path.join(module_root_dir,get_lib_dir(), + 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", python_version,"site-packages", salome_subdir), "PYTHONPATH") - import platform - if platform.machine() == "x86_64": - add_path(os.path.join(module_root_dir,"lib64", - 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) 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) - pass - except: - pass + except: 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: -- 2.39.2