Salome HOME
b3240bfa2bd8557ecc7c6566f7cf546cb13cb0ed
[modules/smesh.git] / bin / smesh_setenv.py
1 #!/usr/bin/env python
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23
24 import os, sys
25 from setenv import add_path, get_lib_dir, salome_subdir
26
27 # -----------------------------------------------------------------------------
28
29 def set_env(args):
30     """Add to the PATH-variables modules specific paths"""
31
32     python_version="python%d.%d" % sys.version_info[0:2]
33
34     os.environ["SMESH_MeshersList"]="StdMeshers"
35     if not os.environ.has_key("SALOME_StdMeshersResources"):
36         os.environ["SALOME_StdMeshersResources"] \
37         = os.environ["SMESH_ROOT_DIR"]+"/share/"+salome_subdir+"/resources/smesh"
38         pass
39     if args.has_key("SMESH_plugins"):
40         for plugin in args["SMESH_plugins"]:
41             plugin_root = ""
42             if os.environ.has_key(plugin+"_ROOT_DIR"):
43                 plugin_root = os.environ[plugin+"_ROOT_DIR"]
44             else:
45                 # workaround to avoid modifications of existing environment
46                 if os.environ.has_key(plugin.upper()+"_ROOT_DIR"):
47                     plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"]
48                     pass
49                 pass
50             if plugin_root != "":
51                 os.environ["SMESH_MeshersList"] \
52                 = os.environ["SMESH_MeshersList"]+":"+plugin
53                 if not os.environ.has_key("SALOME_"+plugin+"Resources"):
54                     os.environ["SALOME_"+plugin+"Resources"] \
55                     = plugin_root+"/share/"+salome_subdir+"/resources/"+plugin.lower()
56                     add_path(os.path.join(plugin_root,get_lib_dir(),python_version, "site-packages",salome_subdir), "PYTHONPATH")
57                     add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PYTHONPATH")
58                     
59                     if sys.platform == "win32":
60                         add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH")
61                     else:
62                         add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH")
63                         add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH")
64                         add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH")
65                         pass
66                     pass
67                 pass
68             pass