Salome HOME
relax constraint about openssl for windows - Python embeds already ssl
[tools/sat.git] / commands / compile.py
index 526f70b73a7cc294d1e9adb52d4c438fe4530bd6..d084b2df8fbaf624a90168bbe00b407660d12dba 100644 (file)
@@ -17,6 +17,7 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 import os
+import sys
 import re
 import subprocess
 import src
@@ -104,16 +105,22 @@ def find_path_graph(graph, start, end, path=[]):
 def depth_first_topo_graph(graph, start, visited=[], sorted_nodes=[]):
     visited = visited + [start]
     if start not in graph:
-        raise src.SatException('Error in product dependencies : %s product is referenced in products dependencies but is not present in the application !' % start)
+        # get more explicit error
+        where = [k for k in graph if start in graph[k]]
+        raise src.SatException('Error in product dependencies : %s product is referenced in products dependencies, but is not present in the application, from %s' % (start, where))
+        # may be in debug mode, continue loop to get all problems, (if comment raise)
+        # print("WARNING : %s product is referenced in products dependencies but is not present in the application, from %s" % (start, where))
+        # sorted_nodes = sorted_nodes + [start]
+        # return visited, sorted_nodes
     for node in graph[start]:
         if node not in visited:
             visited,sorted_nodes=depth_first_topo_graph(graph, node, visited,sorted_nodes)
         else:
             if node not in sorted_nodes:
-                raise src.SatException('Error in product dependencies : cycle detection for node %s and %s !' % (start,node))
+                raise src.SatException('Error in product dependencies : cycle detection for node %s and %s' % (start,node))
     
     sorted_nodes = sorted_nodes + [start]
-    return visited,sorted_nodes
+    return visited, sorted_nodes
 
 
 # check for p_name that all dependencies are installed
@@ -198,7 +205,8 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
                           verbose=0,
                           logger_add_link = logger)
 
-            if options.update:
+            if options.update and src.product.product_is_vcs(p_info):
+            # only VCS products are concerned by update option
                 try: 
                     do_update=False
                     if len(updated_products)>0:
@@ -207,9 +215,10 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
                         if find_path_graph(all_products_graph, p_name, updated_products):
                             logger.write("\nUpdate product %s (child)" % p_name, 5)
                             do_update=True
-                    if not do_update:
-                        source_time=os.path.getatime(p_info.source_dir)
-                        install_time=os.path.getatime(p_info.install_dir)
+                    if (not do_update) and os.path.isdir(p_info.source_dir) \
+                                       and os.path.isdir(p_info.install_dir):
+                        source_time=os.path.getmtime(p_info.source_dir)
+                        install_time=os.path.getmtime(p_info.install_dir)
                         if install_time<source_time:
                             logger.write("\nupdate product %s" % p_name, 5)
                             do_update=True
@@ -221,7 +230,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
                                   batch=True,
                                   verbose=0,
                                   logger_add_link = logger)
-                except:
+                except Exception:
                     pass
 
     if check_salome_configuration:
@@ -237,9 +246,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict
         # for configuration modules, check if sources are present
         for prod in all_products_dict:
             product_name, product_info = all_products_dict[prod]
-            if ("properties" in product_info and
-                "configure_dependency" in product_info.properties and
-                product_info.properties.configure_dependency == "yes"):
+            if src.product.product_is_configuration(product_info):
                 check_source = check_source and src.product.check_source(product_info)
                 if not check_source:
                     logger.write(_("\nERROR : SOURCES of %s not found! It is required for" 
@@ -456,6 +463,10 @@ def compile_product(sat, p_name_info, config, options, logger, header, len_end):
     # product that have been successfully compiled
     if res==0:       
         logger.write(_("Add the config file in installation directory\n"), 5)
+        # for git bases : add the description of git tag
+        src_sha1=src.system.git_describe(p_info.source_dir)
+        if src_sha1:
+            p_info.git_tag_description=src_sha1
         src.product.add_compile_config_file(p_info, config)
         
         if options.check:
@@ -491,7 +502,7 @@ def compile_product_pip(sat,
     :rtype: int
     '''
     # pip needs openssl-dev. If openssl is declared in the application, we check it!
-    if "openssl" in config.APPLICATION.products:
+    if "openssl" in config.APPLICATION.products and not src.architecture.is_windows():
         openssl_cfg = src.product.get_product_config(config, "openssl")
         if not src.product.check_installation(config, openssl_cfg):
             raise src.SatException(_("please install system openssl development package, it is required for products managed by pip."))
@@ -508,6 +519,7 @@ def compile_product_pip(sat,
                              src.environment.Environ(dict(os.environ)),
                              True)
     environ_info = src.product.get_product_dependencies(config,
+                                                        p_name,
                                                         p_info)
     build_environ.silent = (config.USER.output_verbose_level < 5)
     build_environ.set_full_environ(logger, environ_info)
@@ -527,20 +539,35 @@ def compile_product_pip(sat,
     # here we just print a message
     if not res_pip_dwl:
         logger.write("Error in pip download\n", 4, False)
-
-
+    try:
+        pip_version_cmd = 'python -c "import pip;print(pip.__version__)"'
+        res_pip_version = subprocess.check_output(pip_version_cmd,
+                               shell=True,
+                               cwd=config.LOCAL.workdir,
+                               env=build_environ.environ.environ,
+                               stderr=subprocess.STDOUT).decode(sys.stdout.encoding).strip()
+        pip_build_options=int(res_pip_version.split('.')[0]) < 21
+    except Exception:
+        pip_build_options= True
     # d- install (in python or in separate product directory)
     if src.appli_test_property(config,"pip_install_dir", "python"):
         # pip will install product in python directory"
-        pip_install_cmd+=" --find-links=%s --build %s %s==%s" %\
-        (pip_wheels_dir, p_info.build_dir, p_info.name, p_info.version)
+        if pip_build_options:
+            pip_install_cmd+=" --find-links=%s --build %s %s==%s" %\
+                (pip_wheels_dir, p_info.build_dir, p_info.name, p_info.version)
+        else:
+            pip_install_cmd+=" --find-links=%s --cache-dir %s %s==%s" %\
+                (pip_wheels_dir, p_info.build_dir, p_info.name, p_info.version)
         pip_install_in_python=True
-        
     else: 
         # pip will install product in product install_dir
-        pip_install_dir=os.path.join(p_info.install_dir, "lib", "python${PYTHON_VERSION:0:3}", "site-packages")
-        pip_install_cmd+=" --find-links=%s --build %s --target %s %s==%s" %\
-        (pip_wheels_dir, p_info.build_dir, pip_install_dir, p_info.name, p_info.version)
+        pip_install_dir=os.path.join(p_info.install_dir, "lib", "python${PYTHON}", "site-packages")
+        if pip_build_options:
+            pip_install_cmd+=" --find-links=%s --build %s --target %s %s==%s" %\
+                (pip_wheels_dir, p_info.build_dir, pip_install_dir, p_info.name, p_info.version)
+        else:
+            pip_install_cmd+=" --find-links=%s --cache-dir %s --target %s %s==%s" %\
+                (pip_wheels_dir,  p_info.build_dir, pip_install_dir, p_info.name, p_info.version)
     log_step(logger, header, "PIP")
     logger.write("\n"+pip_install_cmd+"\n", 4)
     len_end_line = len_end + 3
@@ -709,6 +736,9 @@ def run(args, runner, logger):
     # check that the command has been called with an application
     src.check_config_has_application( runner.cfg )
 
+    # write warning if platform is not declared as supported
+    src.check_platform_is_supported( runner.cfg, logger )
+
     # Print some informations
     logger.write(_('Executing the compile commands in the build '
                                 'directories of the products of '