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