]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Some updates for salome_on_demand:
authorDUC ANH HOANG <duc-anh-externe.hoang@edf.fr>
Tue, 28 Mar 2023 12:17:03 +0000 (14:17 +0200)
committerDUC ANH HOANG <duc-anh-externe.hoang@edf.fr>
Fri, 14 Apr 2023 08:29:17 +0000 (10:29 +0200)
minimize environment variable of base modules at the start:
     we need only the pythonpath to the python script who launche salome

Install all external binaries in salome_common_dir "__SALOME_EXT__/SALOME"

update Salome_Common_env.py for salome tools and prerequisites

remove the SALOME sub-directory from SALOME_EXT

remove subdirectory SALOME from SALOME_EXT

Base_env.py:update for common directory of extensions

Create 3dparty package including all of prerequisites of salome

update to minimize salome launcher dependencies

bin/SalomeOnDemandTK/3dparty.salomexb [new file with mode: 0644]
bin/SalomeOnDemandTK/3dparty.salomexd [new file with mode: 0644]
bin/SalomeOnDemandTK/3dparty_env.py [new file with mode: 0644]
bin/SalomeOnDemandTK/Base_env.py
bin/SalomeOnDemandTK/extension_builder.py
bin/SalomeOnDemandTK/extension_unpacker.py
bin/launchConfigureParser.py
bin/runSalome.py
bin/runSalomeOnDemand.py
bin/setenv.py

diff --git a/bin/SalomeOnDemandTK/3dparty.salomexb b/bin/SalomeOnDemandTK/3dparty.salomexb
new file mode 100644 (file)
index 0000000..7525e5d
--- /dev/null
@@ -0,0 +1,85 @@
+Python/bin
+Python/lib
+Python/share
+gcc/bin
+gcc/lib
+gcc/lib64
+gcc/libexec
+gcc/share
+lapack/lib
+openmpi/bin
+openmpi/lib
+hdf5/bin
+hdf5/lib
+cgns/bin
+cgns/lib
+tbb/lib
+nlopt/lib
+libxml2/bin
+libxml2/lib
+netcdf/bin
+netcdf/lib
+gdal/bin
+gdal/lib
+gdal/share
+boost/lib
+omniORB/bin
+omniORB/lib
+cppunit/bin
+cppunit/lib
+LIBBATCH/lib
+freetype/bin
+freetype/lib
+qt/plugins
+qt/bin
+qt/lib
+sip/bin
+sip/lib
+PyQt/bin
+PyQt/lib
+PyQt/sip
+freeimage/bin
+freeimage/lib
+CAS/bin
+CAS/lib
+CAS/share
+qwt/lib
+matplotlib/lib
+embree/lib
+rkCommon/lib
+openVKL/lib
+ospray/lib
+cminpack/bin
+cminpack/lib
+cminpack/share
+FMILibrary/bin
+FMILibrary/lib
+PyFMI/lib
+openturns/bin
+openturns/lib
+catalyst/lib
+ParaView/bin
+ParaView/lib
+graphviz/bin
+graphviz/lib
+pmml/bin
+pmml/lib
+opencv/bin
+opencv/lib
+tcl/bin
+tcl/lib
+planegcs/lib
+medfile/bin
+medfile/lib
+metis/bin
+metis/lib
+metis/bin
+petsc/lib
+TTK/bin
+TTK/lib
+C3PO/bin
+C3PO/lib
+root/bin
+root/lib
+zeromq/bin
+zeromq/lib
\ No newline at end of file
diff --git a/bin/SalomeOnDemandTK/3dparty.salomexd b/bin/SalomeOnDemandTK/3dparty.salomexd
new file mode 100644 (file)
index 0000000..d5ede7b
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "name": "3dparty",
+    "descr": "SALOME extension",
+    "depends_on": [],
+    "author": "SALOME Team",
+    "components": [ "Python", "gcc", "lapack", "openmpi", "hdf5", "cgns", "tbb", "nlopt", "libxml2", "netcdf", "gdal", "boost", "omniORB", "cppunit", "LIBBATCH", "freetype", "qt", "sip", "PyQt", "freeimage", "CAS", "qwt", "matplotlib", "embree", "rkCommon", "openVKL", "ospray", "cminpack", "FMILibrary", "PyFMI", "openturns", "catalyst", "ParaView", "graphviz", "pmml", "opencv", "tcl", "planegcs", "medfile", "metis", "petsc", "TTK", "C3PO", "root", "zeromq" ]
+}
+
diff --git a/bin/SalomeOnDemandTK/3dparty_env.py b/bin/SalomeOnDemandTK/3dparty_env.py
new file mode 100644 (file)
index 0000000..161fc9b
--- /dev/null
@@ -0,0 +1,92 @@
+
+#!/usr/bin/env python3
+# -*- coding:utf-8 -*-
+
+"""
+SALOME application environment.
+"""
+
+import os
+import sys
+from SalomeOnDemandTK.extension_query import ext_info_dict
+
+
+def init(context, ext_root_dir):
+    """
+    Set an environment for SALOME app.
+
+    Args:
+        context - an SalomeContext object.
+        ext_root_dir - a path to __SALOME_EXT__ directory.
+
+    Returns:
+        None.
+    """
+
+    BINDIR = os.path.join(ext_root_dir, 'bin')
+    LIBDIR = os.path.join(ext_root_dir, 'lib')
+    python_version = '{}.{}'.format(sys.version_info[0], sys.version_info[1])
+    python_libdir = os.path.join('lib', 'python' + python_version, 'site-packages')
+
+    reinitialise_paths = True
+
+    #[SALOME_COMMON]
+
+    out_dir_Path=os.path.dirname(os.path.realpath(__file__))
+
+    # Seting SALOME modules environment
+    modules = ext_info_dict(out_dir_Path)
+    for module in modules:
+        print
+        for component in modules[module][2].split(', '):
+            context.setVariable('%s_ROOT_DIR'%component, ext_root_dir, overwrite=True)
+    # Seting SALOME prerequis and tools environment
+    context.addToPath(BINDIR)
+    context.addToLdLibraryPath(LIBDIR)
+    context.addToPythonPath(BINDIR)
+    context.addToPythonPath(LIBDIR)
+    context.addToPythonPath(os.path.join(ext_root_dir, python_libdir))
+    context.addToPythonPath(os.path.join(ext_root_dir, 'lib', 'python' + python_version))
+
+    #[Python]
+    context.setVariable(r"PYTHON_VERSION", python_version, overwrite=True)
+    context.addToPath(ext_root_dir)
+    context.setVariable(r"PYTHONBIN", os.path.join(BINDIR,'python3'), overwrite=True)
+    
+    #[gcc]
+    context.addToLdLibraryPath(os.path.join(ext_root_dir, 'lib64'))
+
+    #[openmpi]
+    context.setVariable(r"MPIEXEC_EXECUTABLE", os.path.join(BINDIR, 'mpiexec'), overwrite=True)
+    context.addToPath(os.path.join(ext_root_dir,'include'))
+
+    #[qt]
+    context.setVariable(r"QTDIR", ext_root_dir, overwrite=True)
+    context.setVariable(r"QT5_ROOT_DIR", ext_root_dir, overwrite=True)
+    context.setVariable(r"QT_PLUGIN_PATH", os.path.join(ext_root_dir,'plugins'), overwrite=True)
+    context.setVariable(r"QT_QPA_PLATFORM_PLUGIN_PATH", os.path.join(ext_root_dir,'plugins'), overwrite=True)
+
+    #[PyQt]
+    context.addToPythonPath(os.path.join(ext_root_dir, 'sip',python_libdir))
+
+    #[CAS]
+    context.setVariable(r"CSF_ShadersDirectory", os.path.join( ext_root_dir, 'share/opencascade/resources/Shaders'), overwrite=True)
+    context.setVariable(r"CSF_UnitsLexicon", os.path.join( ext_root_dir, 'share/opencascade/resources/UnitsAPI/Lexi_Expr.dat'), overwrite=True)
+    context.setVariable(r"CSF_UnitsDefinition", os.path.join( ext_root_dir, 'share/opencascade/resources/UnitsAPI/Units.dat'), overwrite=True)
+    context.setVariable(r"CSF_SHMessage", os.path.join( ext_root_dir, 'share/opencascade/resources/SHMessage'), overwrite=True)
+    context.setVariable(r"CSF_XSMessage", os.path.join( ext_root_dir, 'share/opencascade/resources/XSMessage'), overwrite=True)
+    context.setVariable(r"CSF_MDTVTexturesDirectory", os.path.join( ext_root_dir, 'share/opencascade/resources/Textures'), overwrite=True)
+    context.setVariable(r"MMGT_REENTRANT", r"1", overwrite=True)
+    context.setVariable(r"CSF_StandardDefaults", os.path.join( ext_root_dir, 'share/opencascade/resources/StdResource'), overwrite=True)
+    context.setVariable(r"CSF_PluginDefaults", os.path.join( ext_root_dir, 'share/opencascade/resources/StdResource'), overwrite=True)
+    context.addToPath(ext_root_dir)
+
+    #[ParaView]
+    context.setVariable(r"PV_PLUGIN_PATH", os.path.join(LIBDIR,'paraview-5.11'), overwrite=True)
+    context.addToVariable(r"PV_PLUGIN_PATH", os.path.join(LIBDIR,'paraview-5.11','plugins'),separator=":")
+    context.addToPythonPath(os.path.join(LIBDIR,'paraview-5.11', 'site-packages'))
+    context.addToPythonPath(os.path.join(LIBDIR,'paraview-5.11', 'site-packages', 'vtk'))
+    context.addToPath(os.path.join(ext_root_dir,'include', 'paraview-5.11'))
+    context.addToLdLibraryPath(os.path.join(LIBDIR,'paraview-5.11'))
+    context.addToPythonPath(os.path.join(LIBDIR,'paraview-5.11'))
+    context.addToPythonPath(python_libdir)
\ No newline at end of file
index ea4a6559ebebea0ee19791a4d7cba26ca13a9fdb..dda72b73b569763dff57306a09cad984785856b1 100644 (file)
@@ -1,21 +1,23 @@
+
 #!/usr/bin/env python3
 # -*- coding:utf-8 -*-
 
 """
-Add a custom environment to the SALOME extension.
+SALOME application environment.
 """
 
 import os
 import sys
+from SalomeOnDemandTK.extension_query import ext_info_dict
 
 
-def init(context, root_dir):
+def init(context, ext_root_dir):
     """
-    Set an environment for an extension on start of SALOME app.
+    Set an environment for SALOME app.
 
     Args:
         context - an SalomeContext object.
-        root_dir - a path to __SALOME_EXT__ directory.
+        ext_root_dir - a path to __SALOME_EXT__ directory.
 
     Returns:
         None.
@@ -26,26 +28,31 @@ def init(context, root_dir):
 
     reinitialise_paths = True
 
-    #[KERNEL]
-    kernel_root_dir = os.path.join(root_dir, 'KERNEL')
-    context.setVariable('KERNEL_ROOT_DIR', kernel_root_dir, overwrite=True)
-    context.addToPath(os.path.join(kernel_root_dir, 'bin', 'salome'))
-    context.addToLdLibraryPath(os.path.join(kernel_root_dir, 'lib', 'salome'))
-    context.addToPythonPath(os.path.join(kernel_root_dir, 'bin', 'salome'))
-    context.addToPythonPath(os.path.join(kernel_root_dir, 'lib', 'salome'))
-    context.addToPythonPath(os.path.join(kernel_root_dir, python_libdir, 'salome'))
-
-    #[GUI]
-    gui_root_dir = os.path.join(root_dir, 'GUI')
-    context.setVariable('GUI_ROOT_DIR', gui_root_dir, overwrite=True)
-    context.addToPath(os.path.join(gui_root_dir, 'bin', 'salome'))
-    context.addToLdLibraryPath(os.path.join(gui_root_dir, 'lib', 'salome'))
-    context.addToPythonPath(os.path.join(gui_root_dir, 'bin', 'salome'))
-    context.addToPythonPath(os.path.join(gui_root_dir, 'lib', 'salome'))
-    context.addToPythonPath(os.path.join(gui_root_dir, python_libdir, 'salome'))
-
-    gui_res_dir = os.path.join(gui_root_dir, 'share', 'salome', 'resources', 'gui')
+    #[SALOME_COMMON]
+
+    out_dir_Path=os.path.dirname(os.path.realpath(__file__))
+
+    # Seting SALOME modules environment
+    modules = ext_info_dict(out_dir_Path)
+    for module in modules:
+        print
+        for component in modules[module][2].split(', '):
+            context.setVariable('%s_ROOT_DIR'%component, ext_root_dir, overwrite=True)
+    context.addToPath(os.path.join(ext_root_dir, 'bin', 'salome'))
+    context.addToLdLibraryPath(os.path.join(ext_root_dir, 'lib', 'salome'))
+    context.addToPythonPath(os.path.join(ext_root_dir, 'bin', 'salome'))
+    context.addToPythonPath(os.path.join(ext_root_dir, 'lib', 'salome'))
+    context.addToPythonPath(os.path.join(ext_root_dir, python_libdir, 'salome'))
+
+    # Seting SALOME prerequis and tools environment
+    context.addToPath(os.path.join(ext_root_dir, 'bin'))
+    context.addToLdLibraryPath(os.path.join(ext_root_dir, 'lib'))
+    context.addToPythonPath(os.path.join(ext_root_dir, 'bin'))
+    context.addToPythonPath(os.path.join(ext_root_dir, 'lib'))
+    context.addToPythonPath(os.path.join(ext_root_dir, python_libdir))
+
+    res_dir = os.path.join(ext_root_dir, 'share', 'salome', 'resources', 'gui')
     if reinitialise_paths:
-        context.setVariable('SalomeAppConfig', gui_res_dir, overwrite=True)
+        context.setVariable('SalomeAppConfig', res_dir, overwrite=True)
     else:
-        context.addToVariable('SalomeAppConfig', gui_res_dir, separator=os.pathsep)
+        context.addToVariable('SalomeAppConfig', res_dir, separator=os.pathsep)
index c2a70b0a85e275115cda64e3ee132483c0c20dd7..cb62a87f8e05ea7071a2a83df93574f07f627119 100644 (file)
@@ -128,6 +128,12 @@ def create_salomex(salomexb, salomexd, env_py, top_repository):
             # List of the files those actually written to the archive.
             # It goes to the salomexc file then.
             files_abs, files_rel = list_files_filter(top_repository, included_files_patterns)
+            id = 0
+            for f in files_rel:
+                fsplit = f.split('/')
+                del fsplit[0]
+                files_rel[id] = '/'.join(fsplit)
+                id +=1
             add_files(ext, files_abs, files_rel)
 
             # Write the control file - list of the files inside extension's dir
index 08b45d40facdbcb0a9c568f97ee14315d1648937..0f7f1d1a2d8f6f9dcbcdef6070a28d8c1b3ed8ce 100644 (file)
@@ -42,7 +42,6 @@ from .extension_utilities import logger, \
     isvalid_filename, isvalid_dirname, ext_info_bykey, set_selext_env, get_app_root, \
     check_if_installed
 
-
 def unpack_salomex(salome_root, salomex):
     """
     Unpack a given salome extension archive into SALOME install root.
index fde0362886a9005fa1fe8a4b122265076a560c71..2d754a396caed60c39d145429ee91060eeb070a8 100644 (file)
@@ -880,21 +880,21 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
     global args
     config_var = appname+'Config'
 
+    ############################
+    # parse command line options
+    pars = CreateOptionParser(exeName=exeName)
+    cmd_opts = pars.parse_args(sys.argv[1:])
+    ############################
+
     # check KERNEL_ROOT_DIR
     kernel_root_dir = os.environ.get("KERNEL_ROOT_DIR", None)
-    if kernel_root_dir is None:
+    if kernel_root_dir is None and not cmd_opts.on_demand:
         print("""
         For each SALOME module, the environment variable <moduleN>_ROOT_DIR must be set.
         KERNEL_ROOT_DIR is mandatory.
         """)
         sys.exit(1)
 
-    ############################
-    # parse command line options
-    pars = CreateOptionParser(exeName=exeName)
-    cmd_opts = pars.parse_args(sys.argv[1:])
-    ############################
-
     # Process --print-port option
     if cmd_opts.print_port:
         from searchFreePort import searchFreePort
@@ -918,7 +918,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
         else:
             dirs += re.split('[;|:]', os.getenv(config_var))
 
-    if not keepEnvironment:
+    if not keepEnvironment and not cmd_opts.on_demand:
         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):
@@ -1014,7 +1014,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 os.getenv("GUI_ROOT_DIR") or not os.path.isdir(os.getenv("GUI_ROOT_DIR")) ) and not cmd_opts.on_demand:
         args[gui_nam] = False
 
     if args[gui_nam]:
@@ -1158,23 +1158,24 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
 
     # now modify SalomeAppConfig environment variable
     # to take into account the SALOME modules
-    if os.sys.platform == 'win32':
-        dirs = re.split('[;]', os.environ[config_var] )
-    else:
-        dirs = re.split('[;|:]', os.environ[config_var] )
-    for module in args[modules_nam]:
-        if module not in ["KERNEL", "GUI", ""] and os.getenv("{0}_ROOT_DIR".format(module)):
-            d1 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources",module.lower())
-            d2 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources")
-            #if os.path.exists( "%s/%s.xml"%(d1, appname) ):
-            if os.path.exists( os.path.join(d1,"{0}.xml".format(salomeappname)) ):
-                dirs.append( d1 )
-            #elif os.path.exists( "%s/%s.xml"%(d2, appname) ):
-            elif os.path.exists( os.path.join(d2,"{0}.xml".format(salomeappname)) ):
-                dirs.append( d2 )
+    if not args[on_demand_nam]:
+        if os.sys.platform == 'win32':
+            dirs = re.split('[;]', os.environ[config_var] )
         else:
-            # print("* '"+m+"' should be deleted from ",args[modules_nam])
-            pass
+            dirs = re.split('[;|:]', os.environ[config_var] )
+        for module in args[modules_nam]:
+            if module not in ["KERNEL", "GUI", ""] and os.getenv("{0}_ROOT_DIR".format(module)):
+                d1 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources",module.lower())
+                d2 = os.path.join(os.getenv("{0}_ROOT_DIR".format(module)),"share","salome","resources")
+                #if os.path.exists( "%s/%s.xml"%(d1, appname) ):
+                if os.path.exists( os.path.join(d1,"{0}.xml".format(salomeappname)) ):
+                    dirs.append( d1 )
+                #elif os.path.exists( "%s/%s.xml"%(d2, appname) ):
+                elif os.path.exists( os.path.join(d2,"{0}.xml".format(salomeappname)) ):
+                    dirs.append( d2 )
+            else:
+                # print("* '"+m+"' should be deleted from ",args[modules_nam])
+                pass
 
     # Test
     if cmd_opts.test_script_file is not None:
index 6094707b499292f629db757da41db49de3fb2687..1a0e1134bf88c84baee812b6ed0771c3913b928d 100755 (executable)
@@ -24,7 +24,6 @@
 #
 
 import sys, os, string, glob, time, pickle, re
-import orbmodule
 import setenv
 from server import process_id, Server
 import json
@@ -185,6 +184,9 @@ def main(exeName=None):
     # Setup extension's env in salome on demand case
     if args[on_demand_nam]:
         runSalomeOnDemand.set_ext_env()
+        # Reset up module_list and modules_root_dir, if we dont want to define SalomeAppConfig on salome.py.
+        # We must remove the "else" on "if os.sys.platform == 'win32':" in launcheConfigureParser.py too.
+        args, _, __ = setenv.get_config(exeName=exeName, keepEnvironment=keep_env)
 
     setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
     ior_fakens_filename = useSalome(args, modules_list, modules_root_dir)
@@ -227,8 +229,8 @@ def foreGround(args, ior_fakens_filename):
         logger.warn("No file {} set to host IOR of the fake naming server does not exit !")
         return
     import CORBA
-    import Engines
-    import SALOME
+    #import Engines
+    #import SALOME
     from time import sleep
     orb = CORBA.ORB_init([''], CORBA.ORB_ID)
     ior_fakens = None
@@ -305,6 +307,7 @@ def runSalome():
     args, ior_fakens_filename = main()
     # --
     test = args['gui'] and args['session_gui']
+    test = test and not args[on_demand_nam]
     test = test or args['wake_up_session']
     # --
     # The next test covers the --pinter option or if var PYTHONINSPECT is set
index 1326dd827184941e50c697026e4dfe8582479f6a..3047b209c1287add272e2c220688266cccb7b1fe 100755 (executable)
 """Run SALOME app in the context of adding modules as extensions.
 """
 
-import sys
+import os,sys
 import salomeContext
 from SalomeOnDemandTK.extension_utilities import logger, \
-    set_selext_env, get_app_root
+    set_selext_env, get_app_root, find_file
 from SalomeOnDemandTK.extension_query import ext_by_dependants, dependency_tree
 
 
@@ -53,6 +53,10 @@ def set_ext_env(app_name='', version=''):
     # Get the root directory
     app_root = get_app_root()
 
+    # Set the root dir as env variable
+    context = salomeContext.SalomeContext(None)
+    context.setVariable('SALOME_APPLICATION_DIR', app_root, overwrite=True)
+
     # Find and source all _env.py files for installed extensions
     tree = dependency_tree(app_root)
     installed_ext = ext_by_dependants(tree)
@@ -61,14 +65,11 @@ def set_ext_env(app_name='', version=''):
         logger.debug('There are not any extensions in %s!', app_root)
         return
 
-    # Set the root dir as env variable
-    context = salomeContext.SalomeContext(None)
-    context.setVariable('SALOME_APPLICATION_DIR', app_root, overwrite=True)
-
     # Execute env file as a module
     for ext_name in installed_ext:
         set_selext_env(app_root, ext_name, context)
-
+    for python_path in os.environ["PYTHONPATH"].split(':'):
+        sys.path[:0] = [python_path]
 
 if __name__ == "__main__":
     if len(sys.argv) == 3:
index 824e6a96246558104d7f2591848ef658535bb325..2e5474be4d25d1cf8551eb69cfc689361aad467c 100755 (executable)
@@ -23,7 +23,6 @@
 #
 
 import sys, os, string, glob, time, pickle
-import orbmodule
 from launchConfigureParser import verbose
 
 # this file is extraction of set_env from runSalome.py