Salome HOME
PR: SALOME application (virtual links) installation based on an xml descriptor.
authorprascle <prascle>
Mon, 4 Sep 2006 06:01:15 +0000 (06:01 +0000)
committerprascle <prascle>
Mon, 4 Sep 2006 06:01:15 +0000 (06:01 +0000)
bin/Makefile.am
bin/appli_clean.sh
bin/appli_gen.py [new file with mode: 0644]
bin/config_appli.xml [new file with mode: 0644]
bin/virtual_salome.py
doc/SALOME_Application.txt

index 2120709f640edeb59a64c512528e23721b195675..f50343d1967e378d5b059af06e8a02db739dfec6 100644 (file)
@@ -51,7 +51,9 @@ dist_salomescript_SCRIPTS=\
        createAppli.sh \
        appli_install.sh \
        appli_clean.sh \
+       appli_gen.py \
        virtual_salome.py \
+       config_appli.xml \
        launchConfigureParser.py \
        showNS.py \
        addToKillList.py \
index c8cadf964187fb8522ddc26e19dabf1526bac5bc..0046e946cc96733aef2d41b8f0ee85747b726cfc 100644 (file)
@@ -20,4 +20,4 @@
 # 
 
 #clean appli
-rm -rf bin lib share doc envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession env.d
+rm -rf bin lib share doc  env.d envd setAppliPath.sh searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc
diff --git a/bin/appli_gen.py b/bin/appli_gen.py
new file mode 100644 (file)
index 0000000..977b3f5
--- /dev/null
@@ -0,0 +1,246 @@
+#!/usr/bin/env python
+"""Create a virtual Salome installation
+
+"""
+usage="""usage: %prog [options]
+Typical use is:
+  python appli_gen.py 
+Use with options:
+  python appli_gen.py --prefix=<install directory> --config=<configuration file>
+"""
+
+import os, glob, string, sys, re
+import xml.sax
+import optparse
+import virtual_salome
+
+# --- names of tags in XML configuration file
+appli_tag   = "application"
+prereq_tag  = "prerequisites"
+modules_tag = "modules"
+module_tag  = "module"
+samples_tag = "samples"
+
+# --- names of attributes in XML configuration file
+nam_att  = "name"
+path_att = "path"
+gui_att  = "gui"
+
+# -----------------------------------------------------------------------------
+
+# --- xml reader for SALOME application configuration file
+
+class xml_parser:
+    def __init__(self, fileName ):
+        print "Configure parser: processing %s ..." % fileName
+        self.space = []
+        self.config = {}
+        self.config["modules"] = []
+        self.config["guimodules"] = []
+        parser = xml.sax.make_parser()
+        parser.setContentHandler(self)
+        parser.parse(fileName)
+        pass
+
+    def boolValue( self, str ):
+        if str in ("yes", "y", "1"):
+            return 1
+        elif str in ("no", "n", "0"):
+            return 0
+        else:
+            return str
+        pass
+
+    def startElement(self, name, attrs):
+        self.space.append(name)
+        self.current = None
+        # --- if we are analyzing "prerequisites" element then store its "path" attribute
+        if self.space == [appli_tag, prereq_tag] and path_att in attrs.getNames():
+            self.config["prereq_path"] = attrs.getValue( path_att )
+            pass
+        # --- if we are analyzing "samples" element then store its "path" attribute
+        if self.space == [appli_tag, samples_tag] and path_att in attrs.getNames():
+            self.config["samples_path"] = attrs.getValue( path_att )
+            pass
+        # --- if we are analyzing "module" element then store its "name" and "path" attributes
+        elif self.space == [appli_tag,modules_tag,module_tag] and \
+            nam_att in attrs.getNames() and \
+            path_att in attrs.getNames():
+            nam = attrs.getValue( nam_att )
+            path = attrs.getValue( path_att )
+            gui = 1
+            if gui_att in attrs.getNames():
+                gui = self.boolValue(attrs.getValue( gui_att ))
+                pass
+            self.config["modules"].append(nam)
+            self.config[nam]=path
+            if gui:
+                self.config["guimodules"].append(nam)
+                pass
+            pass
+        pass
+
+    def endElement(self, name):
+        p = self.space.pop()
+        self.current = None
+        pass
+
+    def characters(self, content):
+        pass
+
+    def processingInstruction(self, target, data):
+        pass
+
+    def setDocumentLocator(self, locator):
+        pass
+
+    def startDocument(self):
+        self.read = None
+        pass
+
+    def endDocument(self):
+        self.read = None
+        pass
+
+# -----------------------------------------------------------------------------
+
+class params:
+    pass
+
+# -----------------------------------------------------------------------------
+
+def install(prefix,config_file):
+    home_dir=os.path.abspath(os.path.expanduser(prefix))
+    filename=os.path.abspath(os.path.expanduser(config_file))
+    _config={}
+    try:
+        p = xml_parser(filename)
+        _config = p.config
+    except xml.sax.SAXParseException, inst:
+        print inst.getMessage()
+        print "Configure parser: parse error in configuration file %s" % filename
+        pass
+    except xml.sax.SAXException, inst:
+        print inst.args   
+        print "Configure parser: error in configuration file %s" % filename
+        pass
+    except:
+        print "Configure parser: Error : can not read configuration file %s, check existence and rights" % filename
+        pass
+
+    for cle in _config.keys():
+        print cle, _config[cle]
+        pass
+
+    for module in _config["modules"]:
+        print "--- add module ", module, _config[module]
+        options = params()
+        options.verbose=0
+        options.clear=0
+        options.prefix=home_dir
+        options.module=_config[module]
+        virtual_salome.link_module(options)
+        pass
+
+    appliskel_dir=os.path.join(home_dir,'bin','salome','appliskel')
+
+    for fn in ('envd',
+               'setAppliPath.sh',
+               'searchFreePort.sh',
+               'runRemote.sh',
+               'runAppli',
+               'runConsole',
+               'runSession',
+               'runTests',
+               '.bashrc',
+               ):
+        virtual_salome.symlink(os.path.join(appliskel_dir, fn),os.path.join(home_dir, fn))
+        pass
+
+    if filename != os.path.join(home_dir,"config_appli.xml"):
+        command = "cp -p " + filename + ' ' + os.path.join(home_dir,"config_appli.xml")
+        os.system(command)
+        pass
+       
+    virtual_salome.mkdir(os.path.join(home_dir,'env.d'))
+    if os.path.isfile(_config["prereq_path"]):
+        command='cp -p ' + _config["prereq_path"] + ' ' + os.path.join(home_dir,'env.d','envProducts.sh')
+        os.system(command)
+        pass
+    else:
+        print "WARNING: prerequisite file does not exist"
+        pass
+
+
+    f =open(os.path.join(home_dir,'env.d','configSalome.sh'),'w')
+    for module in _config["modules"]:
+        command='export '+ module + '_ROOT_DIR=' + _config[module] +'\n'
+        f.write(command)
+        pass
+    if _config.has_key("samples_path"):
+        command='export DATA_DIR=' + _config["samples_path"] +'\n'
+        f.write(command)
+        pass
+    f.close()
+
+
+    f =open(os.path.join(home_dir,'env.d','configGUI.sh'),'w')
+    command = 'export SalomeAppConfig=' + home_dir +'\n'
+    f.write(command)
+    command = 'export SUITRoot=' + os.path.join(home_dir,'share','salome') +'\n'
+    f.write(command)
+    f.write('export DISABLE_FPE=1\n')
+    f.close()
+
+
+    f =open(os.path.join(home_dir,'SalomeApp.xml'),'w')
+    command="""<document>
+  <section name="launch">
+    <!-- SALOME launching parameters -->
+    <parameter name="gui"        value="yes"/>
+    <parameter name="splash"     value="yes"/>
+    <parameter name="file"       value="no"/>
+    <parameter name="key"        value="no"/>
+    <parameter name="interp"     value="no"/>
+    <parameter name="logger"     value="no"/>
+    <parameter name="xterm"      value="no"/>
+    <parameter name="portkill"   value="no"/>
+    <parameter name="killall"    value="no"/>
+    <parameter name="noexcepthandler"  value="no"/>
+    <parameter name="modules"    value="""
+    f.write(command)    
+    f.write('"')
+    for module in _config["guimodules"][:-1]:
+        f.write(module)
+        f.write(',')
+        pass
+    f.write(_config["guimodules"][-1])
+    f.write('"/>')
+    command="""
+    <parameter name="pyModules"  value=""/>
+    <parameter name="embedded"   value="SalomeAppEngine,study,cppContainer,registry,moduleCatalog"/>
+    <parameter name="standalone" value="pyContainer,supervContainer"/>
+  </section>
+</document>
+"""
+    f.write(command)    
+    f.close()
+
+def main():
+    parser = optparse.OptionParser(usage=usage)
+
+    parser.add_option('--prefix', dest="prefix", default='.',
+                      help="Installation directory (default .)")
+
+    parser.add_option('--config', dest="config", default='config_appli.xml',
+                      help="XML configuration file (default config_appli.xml)")
+
+    options, args = parser.parse_args()
+    install(prefix=options.prefix,config_file=options.config)
+    pass
+
+# -----------------------------------------------------------------------------
+
+if __name__ == '__main__':
+    main()
+    pass
diff --git a/bin/config_appli.xml b/bin/config_appli.xml
new file mode 100644 (file)
index 0000000..bd77993
--- /dev/null
@@ -0,0 +1,20 @@
+<application>
+<prerequisites path="/home/prascle/SALOME2/profileV322.sh"/>
+<modules>
+   <!-- variable name <MODULE>_ROOT_DIR is built with <MODULE> == name attribute value -->
+   <!-- <MODULE>_ROOT_DIR values is set with path attribute value -->
+   <!-- attribute gui (defaults = yes) indicates if the module has a gui interface -->
+   <module name="KERNEL"       gui="no"  path="/home/prascle/SALOME2/Install/KERNEL_V3_2_2"/>
+   <module name="GUI"          gui="no"  path="/home/prascle/SALOME2/Install/GUI_V3_2_2"/>
+   <module name="MED"                    path="/home/prascle/SALOME2/Install/MED_V3_2_2"/>
+   <module name="GEOM"                   path="/home/prascle/SALOME2/Install/GEOM_V3_2_2"/>
+   <module name="SMESH"                  path="/home/prascle/SALOME2/Install/SMESH_V3_2_2"/>
+   <module name="SUPERV"                 path="/home/prascle/SALOME2/Install/SUPERV_V3_2_2"/>
+   <module name="VISU"                   path="/home/prascle/SALOME2/Install/VISU_V3_2_2"/>
+   <module name="HELLO"                  path="/home/prascle/SALOME2/Install/HELLO1_V3_2_2"/>
+   <module name="PYHELLO"                path="/home/prascle/SALOME2/Install/PYHELLO1_V3_2_2"/>
+   <module name="NETGENPLUGIN" gui="no"  path="/home/prascle/SALOME2/Install/NETGENPLUGIN_V3_2_2"/>
+</modules>
+<samples path="/home/prascle/SALOME2/SAMPLES/V3_2_2/SAMPLES_SRC"/>
+</application>
+
index 8040c21c9b90dd7ebf85fec3323a1b32fb7a0266..e6458665e33d8d20141c751f2d58b94b4c063337 100644 (file)
@@ -30,6 +30,8 @@ install module KERNEL in the current directory
 import sys, os, optparse, shutil,glob,fnmatch
 py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1])
 
+# -----------------------------------------------------------------------------
+
 def mkdir(path):
     """Create a directory and all the intermediate directories if path does not exist"""
     if not os.path.exists(path):
@@ -41,6 +43,8 @@ def mkdir(path):
             pass
         pass
 
+# -----------------------------------------------------------------------------
+
 def symlink(src, dest):
     """Create a link if it does not exist"""
     if not os.path.exists(dest):
@@ -53,6 +57,8 @@ def symlink(src, dest):
         pass
     pass
 
+# -----------------------------------------------------------------------------
+
 def rmtree(dir):
     """Remove (recursive) a directory if it exists"""
     if os.path.exists(dir):
@@ -65,32 +71,18 @@ def rmtree(dir):
         pass
     pass
 
+# -----------------------------------------------------------------------------
+
 def get_lib_dir():
     """Get libraries directory according to the Linux platform being used"""
-    if os.path.exists("/usr/lib64/libc.so"):
-        return "lib64"
+    #ne marche pas sur Calibre 4.0
+    #if os.path.exists("/usr/lib64/libc.so"):
+    #    return "lib64"
     return "lib"
 
-def main():
-    usage="""usage: %prog [options]
-Typical use is:
-  python virtual_salome.py -v --prefix="." --module=/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1
-"""
-    parser = optparse.OptionParser(usage=usage)
-
-    parser.add_option('-v', '--verbose', action='count', dest='verbose',
-                      default=0, help="Increase verbosity")
-
-    parser.add_option('--prefix', dest="prefix", default='.',
-                      help="The base directory to install to (default .)")
-
-    parser.add_option('--module', dest="module", 
-                      help="The module directory to install in (mandatory)")
-
-    parser.add_option('--clear', dest='clear', action='store_true',
-        help="Clear out the install and start from scratch")
+# -----------------------------------------------------------------------------
 
-    options, args = parser.parse_args()
+def link_module(options):
     global verbose
 
     if not options.module:
@@ -104,7 +96,6 @@ Typical use is:
 
     home_dir = os.path.expanduser(options.prefix)
 
-    #module_dir="/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1"
     module_bin_dir=os.path.join(module_dir,'bin','salome')
     module_lib_dir=os.path.join(module_dir,get_lib_dir(),'salome')
     module_lib_py_dir=os.path.join(module_dir,get_lib_dir(),py_version,'site-packages','salome')
@@ -114,6 +105,7 @@ Typical use is:
     module_doc_gui_dir=os.path.join(module_dir,'doc','salome','gui')
     module_doc_tui_dir=os.path.join(module_dir,'doc','salome','tui')
     module_doc_dir=os.path.join(module_dir,'doc','salome')
+    module_sharedoc_dir=os.path.join(module_dir,'share','doc','salome')
 
     if not os.path.exists(module_lib_py_dir):
         print "Python directory %s does not exist" % module_lib_py_dir
@@ -128,39 +120,49 @@ Typical use is:
     doc_gui_dir=os.path.join(home_dir,'doc','salome','gui')
     doc_tui_dir=os.path.join(home_dir,'doc','salome','tui')
     doc_dir=os.path.join(home_dir,'doc','salome')
+    sharedoc_dir=os.path.join(home_dir,'share','doc','salome')
 
     verbose = options.verbose
 
     if options.clear:
         rmtree(bin_dir)
         rmtree(lib_dir)
+        rmtree(lib_py_dir)
         rmtree(share_dir)
         rmtree(doc_dir)
+        rmtree(sharedoc_dir)
         pass
     
     #directory bin/salome : create it and link content
-    mkdir(bin_dir)
-    for fn in os.listdir(module_bin_dir):
-        # if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded
-        symlink(os.path.join(module_bin_dir, fn), os.path.join(bin_dir, fn))
+    if os.path.exists(module_bin_dir):
+        mkdir(bin_dir)
+        for fn in os.listdir(module_bin_dir):
+            symlink(os.path.join(module_bin_dir, fn), os.path.join(bin_dir, fn))
+            pass
         pass
+    else:
+        print module_bin_dir, " doesn't exist"
+        pass    
     
     #directory lib/salome : create it and link content
-    mkdir(lib_dir)
-    for fn in os.listdir(module_lib_dir):
-        symlink(os.path.join(module_lib_dir, fn), os.path.join(lib_dir, fn))
-
+    if os.path.exists(module_lib_dir):
+        mkdir(lib_dir)
+        for fn in os.listdir(module_lib_dir):
+            symlink(os.path.join(module_lib_dir, fn), os.path.join(lib_dir, fn))
+            pass
+        pass
+    else:
+        print module_lib_dir, " doesn't exist"
+        pass    
+    
     #directory lib/py_version/site-packages/salome : create it and link content
     mkdir(lib_py_shared_dir)
     for fn in os.listdir(module_lib_py_dir):
-        # if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded
-        if os.path.split(fn)[1] != "shared_modules":
-            symlink(os.path.join(module_lib_py_dir, fn), os.path.join(lib_py_dir, fn))
-            pass
-        pass
+        if fn == "shared_modules": continue
+        symlink(os.path.join(module_lib_py_dir, fn), os.path.join(lib_py_dir, fn))
+        pass    
     if os.path.exists(module_lib_py_shared_dir):
         for fn in os.listdir(module_lib_py_shared_dir):
-            # if os.path.splitext(fn)[1] not in (".pyc",".pyo"): #Compiled python are excluded
             symlink(os.path.join(module_lib_py_shared_dir, fn), os.path.join(lib_py_shared_dir, fn))
             pass
         pass
@@ -168,6 +170,15 @@ Typical use is:
         print module_lib_py_shared_dir, " doesn't exist"
         pass    
 
+    #directory share/doc/salome (KERNEL doc) : create it and link content
+    if os.path.exists(module_sharedoc_dir):
+        mkdir(sharedoc_dir)
+        for fn in os.listdir(module_sharedoc_dir):
+            symlink(os.path.join(module_sharedoc_dir, fn), os.path.join(sharedoc_dir, fn))
+            pass
+        pass
+    pass
+
 
     #directory share/salome/resources : create it and link content
     mkdir(share_dir)
@@ -199,7 +210,34 @@ Typical use is:
             symlink(os.path.join(module_doc_tui_dir, fn), os.path.join(doc_tui_dir, fn))
             pass
         pass
+
+# -----------------------------------------------------------------------------
+
+def main():
+    usage="""usage: %prog [options]
+Typical use is:
+  python virtual_salome.py -v --prefix="." --module=/local/chris/SALOME2/RELEASES/Install/KERNEL_V3_1_0b1
+"""
+    parser = optparse.OptionParser(usage=usage)
+
+    parser.add_option('-v', '--verbose', action='count', dest='verbose',
+                      default=0, help="Increase verbosity")
+
+    parser.add_option('--prefix', dest="prefix", default='.',
+                      help="The base directory to install to (default .)")
+
+    parser.add_option('--module', dest="module", 
+                      help="The module directory to install in (mandatory)")
+
+    parser.add_option('--clear', dest='clear', action='store_true',
+        help="Clear out the install and start from scratch")
+
+    options, args = parser.parse_args()
+    link_module(options)
+    pass
     
+# -----------------------------------------------------------------------------
+
 if __name__ == '__main__':
     main()
     pass
index ab6c52b96cc544ea5877f8f8bf062511a3fc4af0..0abcaed1ee66737c28753dba0dbd2c374ab47e42 100644 (file)
@@ -74,19 +74,29 @@ configure his own application. These files are described after, the list is:
 - CatalogResources.xml
 - SalomeApp.xml
 
-Second way - one single virtual install directory
-'''''''''''''''''''''''''''''''''''''''''''''''''
-
-The user must create an application directory in which he copies
-appli_install.sh, appli_clean.sh and virtual_salome.py,
-from ${KERNEL_ROOT_DIR}/bin/salome.
-
-appli_install.sh needs to be edited, to define a list of modules with their
-install paths.
-Then, the script appli_install.sh creates a virtual installation of SALOME
-in the application directory (bin, lib, doc, share...), with,
-for each file (executable, script, data,library, resources...),
-symbolic links to the actual file.
+Second and easiest way - one single virtual install directory
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The user must create a SALOME application configuration file by modifying a
+copy of ${KERNEL_ROOT_DIR}/bin/salome/config_appli.xml.
+The file describes the list of SALOME modules used in the application, with
+their respective installation path. The configuration file also defines the
+path of an existing script which sets the SALOME prerequisites,
+and optionnaly, the path of samples directory (SAMPLES_SRC).
+The following command::
+
+    python <KERNEL_ROOT_DIR>/bin/salome/appli_gen.py --prefix=<install directory> --config=<configuration file>
+
+creates a virtual installation of SALOME in the application directory ${APPLI}
+(bin, lib, doc, share...), with, for each file (executable, script, data,
+library, resources...), symbolic links to the actual file.
+
+Providing an existing an existing script for SALOME prerequisites (the same one
+used for modules compilation, or given with the modules installation), the
+installation works without further modification for a single computer (unless
+some modules needs a special environment not defined in the above script).
+For a distributed application (several computers), one must copy and adapt
+CatalogResources.xml from ${KERNEL_ROOT_DIR}/bin/salome/appliskel (see below).
 
 General rules
 -------------
@@ -108,15 +118,12 @@ script is used by run scripts.
 
 env.d scripts
 ~~~~~~~~~~~~~
+With the first way of installation, each user **must define** his own
+configuration for these scripts, following the above rules.
+With the virtual installation (second way, above), env.d
+scripts are built automatically.
 
-Each user **must define** his own configuration for these scripts, following
-the above rules. With the virtual installation (second way, above), env.d
-scripts are built by appli_install.sh (given it's parameters). Otherwise, the
-scripts must be manually defined.
-
-
- **The following is only an example proposed by createAppli.sh,
- not working as it is**.
+ **The following is only an example proposed by createAppli.sh, (first way of installation) not working as it is**.
 
 atFirst.sh
     Sets the computer configuration not directly related to SALOME,
@@ -184,7 +191,7 @@ SalomeApp.xml
 
 
 CatalogRessources.xml
-   This files describes all the computer the application can use. The given
+   This files describes all the computers the application can use. The given
    example is minimal and suppose ${APPLI} is the same relative path
    to ${HOME}, on all the computers. A different directory can be set on a
    particular computer with a line::