]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
do not create install dir for pip products installed in python, adapt archives to...
authorcrouzet <nicolas.crouzet@cea.fr>
Mon, 29 Jul 2019 15:04:24 +0000 (17:04 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Mon, 29 Jul 2019 15:04:24 +0000 (17:04 +0200)
commands/compile.py
commands/config.py
commands/package.py
commands/template.py
src/environment.py
src/fileEnviron.py
src/product.py

index 9748b169392ab1c32e65deb8ff3e82721253c24c..47a3d4b8a53159c6dd7b7f1197c31efe0069eb75 100644 (file)
@@ -470,10 +470,6 @@ def compile_product_pip(sat,
                                stderr=subprocess.STDOUT) == 0)        
     if res_pip:
         res=0
-        if pip_install_in_python:
-            # when product is installed in python, create install_dir 
-            # (to put inside product info and mark the installation success)
-            os.mkdir(p_info.install_dir)
     else:
         #log_res_step(logger, res)
         res=1
index 3d44311fe9fd7de6ae697765cd34d0f411cdd393..8e34e6d5ae269a0a706f9c7f428adef04711e74a 100644 (file)
@@ -576,15 +576,6 @@ class ConfigManager:
                                  'evince', 
                                  "This is the pdf_viewer used "
                                  "to read pdf documentation\n")
-# CNC 25/10/17 : plus nécessaire a priori
-#        user_cfg.USER.addMapping("base",
-#                                 src.pyconf.Reference(
-#                                            user_cfg,
-#                                            src.pyconf.DOLLAR,
-#                                            'workdir  + $VARS.sep + "BASE"'),
-#                                 "The products installation base (could be "
-#                                 "ignored if this key exists in the local.pyconf"
-#                                 " file of salomTools).\n")
 
         src.ensure_path_exists(config.VARS.personalDir)
         src.ensure_path_exists( osJoin(config.VARS.personalDir,
index 865979e3acb54998f84f7aa95ebd174182d71402..c9a033c36377408745625c0ca281f3258311df84 100644 (file)
@@ -136,6 +136,8 @@ def add_files(tar, name_archive, d_content, logger, f_exclude=None):
     names = sorted(d_content.keys())
     DBG.write("add tar names", names)
 
+    # used to avoid duplications (for pip install in python, or single_install_dir cases)
+    already_added=set() 
     for name in names:
         # display information
         len_points = max_len - len(name) + 3
@@ -146,7 +148,10 @@ def add_files(tar, name_archive, d_content, logger, f_exclude=None):
         # of the directory or file to add
         # Add it in the archive
         try:
-            tar.add(local_path, arcname=in_archive, exclude=f_exclude)
+            key=local_path+"->"+in_archive
+            if key not in already_added:
+                tar.add(local_path, arcname=in_archive, exclude=f_exclude)
+                already_added.add(key)
             logger.write(src.printcolors.printcSuccess(_("OK")), 3)
         except Exception as e:
             logger.write(src.printcolors.printcError(_("KO ")), 3)
@@ -266,7 +271,6 @@ def produce_relative_launcher(config,
              stat.S_IXGRP |
              stat.S_IXOTH)
 
-    print "CNC filepath = ", filepath
     return filepath
 
 def hack_for_distene_licence(filepath, licence_file):
@@ -608,7 +612,7 @@ WARNING: existing binaries directory from previous detar installation:
     # actual install directories and there install directory in archive
     d_products = {}
     for prod_name, install_dir in l_install_dir:
-        path_in_archive = os.path.join(binaries_dir_name, prod_name)
+        path_in_archive = os.path.join(binaries_dir_name, os.path.basename(install_dir))
         d_products[prod_name + " (bin)"] = (install_dir, path_in_archive)
         
     for prod_name, source_dir in l_source_dir:
@@ -789,7 +793,6 @@ def get_archives(config, logger):
                 pip_wheels_dir=os.path.join(config.LOCAL.archive_dir,"wheels")
                 pip_wheel_pattern=os.path.join(pip_wheels_dir, 
                     "%s-%s*" % (p_info.name, p_info.version))
-                print "CNC  pip_wheel_pattern = ",pip_wheel_pattern
                 pip_wheel_path=glob.glob(pip_wheel_pattern)
                 msg_pip_not_found="Error in get_archive, pip wheel for "\
                                   "product %s-%s was not found in %s directory"
index 23eddb0d83a089d0043509a752ce1790e55f32f4..b7ee487b545bda7b53d71e9b3cae8a8139ed2f8c 100644 (file)
@@ -483,16 +483,6 @@ def run(args, runner, logger):
         logger.write("\n", 1)
         return 1
 
-    # CNC inutile
-    # Ask user confirmation if a module of the same name already exists
-    #if options.name in runner.cfg.PRODUCTS and not runner.options.batch:
-    #    logger.write(src.printcolors.printcWarning(
-    #                _("A module named '%s' already exists." % options.name)), 1)
-    #    logger.write("\n", 1)
-    #    rep = input(_("Are you sure you want to continue? [Yes/No] "))
-    #    if rep.upper() != _("YES"):
-    #        return 1
-
     if options.target is None:
         msg = _("Error: the --%s argument is required\n") % "target"
         logger.write(src.printcolors.printcError(msg), 1)
@@ -506,16 +496,6 @@ def run(args, runner, logger):
         logger.write("\n", 1)
         return 1
 
-    # CNC inutile
-    #if options.template == "Application":
-    #    if "_APPLI" not in options.name and not runner.options.batch:
-    #        msg = _("An Application module named '..._APPLI' "
-    #                "is usually recommended.")
-    #        logger.write(src.printcolors.printcWarning(msg), 1)
-    #        logger.write("\n", 1)
-    #        rep = input(_("Are you sure you want to continue? [Yes/No] "))
-    #        if rep.upper() != _("YES"):
-    #            return 1
 
     logger.write(_('Create sources from template\n'), 1)
     src.printcolors.print_value(logger, 'destination', target_dir, 2)
index 81505bfc51788f927826f3012e477ea57420e5a0..89dfece96b651dc06c7d44a37acf584f21b036b0 100644 (file)
@@ -432,8 +432,8 @@ class SalomeEnviron:
                         self.set(src_dir, product_info.source_dir)
                     else:
                         self.set(src_dir, os.path.join("out_dir_Path",
-                                                       "SOURCES",
-                                                       product_info.name))
+                                 "SOURCES",
+                                 os.path.basename(product_info.source_dir)))
 
     def set_salome_generic_product_env(self, pi):
         """\
@@ -463,13 +463,13 @@ class SalomeEnviron:
             bin_path = os.path.join(env_root_dir, 'bin')
             if self.has_python:
             # if the application doesn't include python, we don't need these two lines
-                pylib1_path = os.path.join(env_root_dir, self.python_lib)
+                pylib_path = os.path.join(env_root_dir, self.python_lib)
         else:
             lib_path = os.path.join(env_root_dir, 'lib', 'salome')
             bin_path = os.path.join(env_root_dir, 'bin', 'salome')
             if self.has_python:
             # if the application doesn't include python, we don't need these two lines
-                pylib1_path = os.path.join(env_root_dir, self.python_lib, 'salome')
+                pylib_path = os.path.join(env_root_dir, self.python_lib, 'salome')
 
         # Construct the paths to prepend to PATH and LD_LIBRARY_PATH and 
         # PYTHONPATH
@@ -486,8 +486,7 @@ class SalomeEnviron:
             l = [ bin_path, lib_path ]
             if not src.product.product_is_wheel(pi):
                 if self.has_python:
-                    l.append(pylib1_path)
-                    l.append(pylib2_path)
+                    l.append(pylib_path)
                 self.prepend('PYTHONPATH', l)
 
     def set_cpp_env(self, product_info):
@@ -598,9 +597,10 @@ class SalomeEnviron:
                
         
         if self.for_package:
-            pi.install_dir = os.path.join("out_dir_Path",
-                                          self.for_package,
-                                          pi.name)
+            pi.install_dir = os.path.join(
+                                 "out_dir_Path",
+                                 self.for_package,
+                                 os.path.basename(pi.install_dir))
 
         if not self.silent:
             logger.write(_("Setting environment for %s\n") % product, 4)
index 5b293ffcb8ed948cfae504ba6d6b3d1ccc9f3a83..ef900f3c84d74f9b7da4a271d35afb1dc32771f1 100644 (file)
@@ -128,7 +128,6 @@ class FileEnviron(object):
             value_list = self.environ.get(key).split(sep)
             if self.environ._expandvars(value) in value_list:
                 do_append=False  # value is already in key path : we don't append it again
-                #print "\nCNC append_value value is already set!! key=%s, val=%s value_list=%s\n" % (key,self.environ._expandvars(value), value_list)
             
         if do_append:
             self.environ.append_value(key, value,sep)
@@ -168,7 +167,6 @@ class FileEnviron(object):
             exp_val=self.environ._expandvars(value)
             if exp_val in value_list:
                 do_not_prepend=True
-                #print "\nCNC prepend_value value is already set!! key=%s, val=%s value_list=%s\n" % (key,exp_val, value_list)
         if not do_not_prepend:
             self.environ.prepend_value(key, value,sep)
             self.set(key, value + sep + self.get(key))
index fd8276a5ef337294908ed659ea506865ef0fa784..029ecb0e4f6554608036de993a1e13e3c2fdd19b 100644 (file)
@@ -492,6 +492,15 @@ def get_install_dir(config, base, version, prod_info):
                 install_dir = os.path.join(config.APPLICATION.workdir,
                                            config.INTERNAL.config.install_dir,
                                            config.INTERNAL.config.single_install_dir)
+            elif ( src.appli_test_property(config,"pip", "yes") and 
+                   src.product.product_test_property(prod_info,"pip", "yes") and
+                   src.appli_test_property(config,"pip_install_dir", "python") ):
+                # when pip mode is activated in the application
+                # and product is pip, and pip_install_dir is set to python 
+                # we assume python in installed in install_dir/Python
+                install_dir = os.path.join(config.APPLICATION.workdir,
+                                           config.INTERNAL.config.install_dir,
+                                           "Python")   
             else:
                 install_dir = os.path.join(config.APPLICATION.workdir,
                                            config.INTERNAL.config.install_dir,
@@ -775,10 +784,13 @@ def check_installation(config, product_info):
         return True
 
     install_dir = product_info.install_dir
-    if ( src.appli_test_property(config,"single_install_dir", "yes") and 
-         src.product.product_test_property(product_info,"single_install_dir", "yes")):
-        # if the product is installed in the single install dir, we check the product file
-        #in state of the install directory.
+    if ( (src.appli_test_property(config,"single_install_dir", "yes") and 
+          src.product.product_test_property(product_info,"single_install_dir", "yes")) or
+         (src.appli_test_property(config,"pip", "yes") and 
+          src.product.product_test_property(product_info,"pip", "yes") and
+          src.appli_test_property(config,"pip_install_dir", "python") ) ):
+        # if the product is installed in the single install dir, or in python (for pip managed products)
+        # we check the product file in state of the install directory.
         filename = CONFIG_FILENAME + product_info.name + ".pyconf"
         if not os.path.exists(os.path.join(install_dir, filename)): 
             return False