+def set_env(args, modules_list, modules_root_dir):
+ """Add to the PATH-variables modules specific paths"""
+
+ python_version="python%d.%d" % sys.version_info[0:2]
+ modules_root_dir_list = []
+ modules_list = modules_list[:] + ["GUI"]
+ modules_list = modules_list[:] + ["KERNEL"]
+ for module in modules_list :
+ if modules_root_dir.has_key(module):
+ module_root_dir = modules_root_dir[module]
+ modules_root_dir_list[:0] = [module_root_dir]
+ add_path(os.path.join(module_root_dir,"lib",salome_subdir),
+ "LD_LIBRARY_PATH")
+ add_path(os.path.join(module_root_dir,"bin",salome_subdir),
+ "PATH")
+ if os.path.exists(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_path(os.path.join(module_root_dir,"lib",
+ python_version,"site-packages",
+ salome_subdir),
+ "PYTHONPATH")
+ add_path(os.path.join(module_root_dir,"lib",salome_subdir),
+ "PYTHONPATH")
+ add_path(os.path.join(module_root_dir,"lib",
+ python_version,"site-packages",
+ salome_subdir,
+ "shared_modules"),
+ "PYTHONPATH")
+ pass
+ pass
+
+
+ os.environ["SALOMEPATH"]=":".join(modules_root_dir_list)
+
+ # set trace environment variable
+
+ if not os.environ.has_key("SALOME_trace"):
+ os.environ["SALOME_trace"]="local"
+ if args['file']:
+ os.environ["SALOME_trace"]="file:"+args['file'][0]
+ if args['logger']:
+ os.environ["SALOME_trace"]="with_logger"
+
+ # set environment for SMESH plugins
+
+ if "SMESH" in modules_list:
+ os.environ["SMESH_MeshersList"]="StdMeshers"
+ if not os.environ.has_key("SALOME_StdMeshersResources"):
+ os.environ["SALOME_StdMeshersResources"] \
+ = modules_root_dir["SMESH"]+"/share/"+args["appname"]+"/resources"
+ pass
+ if args.has_key("SMESH_plugins"):
+ for plugin in args["SMESH_plugins"]:
+ plugin_root = ""
+ if os.environ.has_key(plugin+"_ROOT_DIR"):
+ plugin_root = os.environ[plugin+"_ROOT_DIR"]
+ else:
+ # workaround to avoid modifications of existing environment
+ if os.environ.has_key(plugin.upper()+"_ROOT_DIR"):
+ plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"]
+ pass
+ pass
+ if plugin_root != "":
+ os.environ["SMESH_MeshersList"] \
+ = os.environ["SMESH_MeshersList"]+":"+plugin
+ if not os.environ.has_key("SALOME_"+plugin+"Resources"):
+ os.environ["SALOME_"+plugin+"Resources"] \
+ = plugin_root+"/share/"+args["appname"]+"/resources"
+ add_path(os.path.join(plugin_root,"lib",python_version,
+ "site-packages",salome_subdir),
+ "PYTHONPATH")
+ add_path(os.path.join(plugin_root,"lib",salome_subdir),
+ "PYTHONPATH")
+ add_path(os.path.join(plugin_root,"lib",salome_subdir),
+ "LD_LIBRARY_PATH")
+ add_path(os.path.join(plugin_root,"bin",salome_subdir),
+ "PYTHONPATH")
+ add_path(os.path.join(plugin_root,"bin",salome_subdir),
+ "PATH")
+ pass
+ pass
+
+ # set environment for SUPERV module
+ os.environ["ENABLE_MACRO_NODE"]="1"
+ # set resources variables if not yet set
+ if os.getenv("GUI_ROOT_DIR"):
+ if not os.getenv("SUITRoot"): os.environ["SUITRoot"] = os.getenv("GUI_ROOT_DIR") + "/share/salome"
+ if not os.getenv("SalomeAppConfig"): os.environ["SalomeAppConfig"] = os.getenv("GUI_ROOT_DIR") + "/share/salome/resources"
+ pass
+
+ # set CSF_PluginDefaults variable only if it is not customized
+ # by the user
+ if not os.getenv("CSF_PluginDefaults"):
+ os.environ["CSF_PluginDefaults"] \
+ = os.path.join(modules_root_dir["KERNEL"],"share",
+ salome_subdir,"resources")
+ os.environ["CSF_SALOMEDS_ResourcesDefaults"] \
+ = os.path.join(modules_root_dir["KERNEL"],"share",
+ salome_subdir,"resources")
+
+ if "GEOM" in modules_list:
+ print "GEOM OCAF Resources"
+ os.environ["CSF_GEOMDS_ResourcesDefaults"] \
+ = os.path.join(modules_root_dir["GEOM"],"share",
+ salome_subdir,"resources")
+ print "GEOM Shape Healing Resources"
+ os.environ["CSF_ShHealingDefaults"] \
+ = os.path.join(modules_root_dir["GEOM"],"share",
+ salome_subdir,"resources")