From: crouzet Date: Mon, 22 Jul 2019 12:19:42 +0000 (+0200) Subject: pip download dans sat compile, property single_install_dir, postfix nom produit pour... X-Git-Tag: 5.5.0~44 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2691e32ff0309ae0c313c0e5869aa94f686666f6;p=tools%2Fsat.git pip download dans sat compile, property single_install_dir, postfix nom produit pour sat-config and sat-products pyconf files. --- diff --git a/commands/compile.py b/commands/compile.py index 7bf4b76..9748b16 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -109,7 +109,7 @@ def check_dependencies(config, p_name_p_info, all_products_dict): for prod in p_name_p_info[1]["depend_all"]: # for each dependency, check the install prod_name, prod_info=all_products_dict[prod] - if not(src.product.check_installation(prod_info)): + if not(src.product.check_installation(config, prod_info)): l_depends_not_installed.append(prod_name) return l_depends_not_installed # non installed deps @@ -232,7 +232,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict continue # Check if it was already successfully installed - if src.product.check_installation(p_info): + if src.product.check_installation(config, p_info): logger.write(_("Already installed")) logger.write(_(" in %s" % p_info.install_dir), 4) logger.write(_("\n")) @@ -411,50 +411,56 @@ def compile_product_pip(sat, :return: 1 if it fails, else 0. :rtype: int ''' + # a) initialisation p_name, p_info = p_name_info - - # Execute "sat configure", "sat make" and "sat install" res = 0 error_step = "" pip_install_in_python=False pip_wheels_dir=os.path.join(config.LOCAL.archive_dir,"wheels") + pip_install_cmd=config.INTERNAL.command.pip_install # parametrized in src/internal + + # b) get the build environment (useful to get the installed python & pip3) + build_environ = src.environment.SalomeEnviron(config, + src.environment.Environ(dict(os.environ)), + True) + environ_info = src.product.get_product_dependencies(config, + p_info) + build_environ.silent = (config.USER.output_verbose_level < 5) + build_environ.set_full_environ(logger, environ_info) + + # c- download : check/get pip wheel in pip_wheels_dir + pip_download_cmd=config.INTERNAL.command.pip_download +\ + " --destination-directory %s --no-deps %s==%s " %\ + (pip_wheels_dir, p_info.name, p_info.version) + logger.write("\n"+pip_download_cmd+"\n", 4, False) + res_pip_dwl = (subprocess.call(pip_download_cmd, + shell=True, + cwd=config.LOCAL.workdir, + env=build_environ.environ.environ, + stdout=logger.logTxtFile, + stderr=subprocess.STDOUT) == 0) + # error is not managed at the stage. error will be handled by pip install + # here we just print a message + if not res_pip_dwl: + logger.write("Error in pip download\n", 4, False) + + + # 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="pip3 install --disable-pip-version-check --no-index --find-links=%s --build %s %s==%s" %\ + pip_install_cmd+=" --find-links=%s --build %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="pip3 install --disable-pip-version-check --no-index --find-links=%s --build %s --target %s %s==%s" %\ + 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) log_step(logger, header, "PIP") logger.write("\n"+pip_install_cmd+"\n", 4) len_end_line = len_end + 3 error_step = "" - build_environ = src.environment.SalomeEnviron(config, - src.environment.Environ(dict(os.environ)), - True) - environ_info = src.product.get_product_dependencies(config, - p_info) - build_environ.silent = (config.USER.output_verbose_level < 5) - build_environ.set_full_environ(logger, environ_info) - - # useless - pip uninstall himself when wheel is alredy installed - #if pip_install_in_python and (options.clean_install or options.clean_all): - # # for products installed by pip inside python install dir - # # finish the clean by uninstalling the product from python install dir - # pip_clean_cmd="pip3 uninstall -y %s==%s" % (p_name, p_info.version) - # res_pipclean = (subprocess.call(pip_clean_cmd, - # shell=True, - # cwd=config.LOCAL.workdir, - # env=build_environ.environ.environ, - # stdout=logger.logTxtFile, - # stderr=subprocess.STDOUT) == 0) - # if not res_pipclean: - # logger.write("\n",1) - # logger.warning("pip3 uninstall failed!") res_pip = (subprocess.call(pip_install_cmd, shell=True, diff --git a/commands/launcher.py b/commands/launcher.py index ca293b6..1208559 100644 --- a/commands/launcher.py +++ b/commands/launcher.py @@ -77,7 +77,7 @@ def generate_launch_file(config, # get KERNEL bin installation path # (in order for the launcher to get python salomeContext API) kernel_cfg = src.product.get_product_config(config, "KERNEL") - if not src.product.check_installation(kernel_cfg): + if not src.product.check_installation(config, kernel_cfg): raise src.SatException(_("KERNEL is not installed")) kernel_root_dir = kernel_cfg.install_dir diff --git a/commands/package.py b/commands/package.py index 8c75f35..c24de6e 100644 --- a/commands/package.py +++ b/commands/package.py @@ -542,7 +542,7 @@ def binary_package(config, logger, options, tmp_working_dir): or src.product.product_is_fixed(prod_info) or not src.product.product_compiles(prod_info)): continue - if src.product.check_installation(prod_info): + if src.product.check_installation(config, prod_info): l_install_dir.append((prod_name, prod_info.install_dir)) else: l_not_installed.append(prod_name) diff --git a/commands/source.py b/commands/source.py index 0df9e67..c4968c9 100644 --- a/commands/source.py +++ b/commands/source.py @@ -158,17 +158,9 @@ def get_source_from_archive(config, product_info, source_dir, logger): # check if pip should be used : pip mode id activated if the application and product have pip property if (src.appli_test_property(config,"pip", "yes") and src.product.product_test_property(product_info,"pip", "yes")): - # download whl in local archive dir - pip_wheels_dir=os.path.join(config.LOCAL.archive_dir,"wheels") - pip_download_cmd="pip download --disable-pip-version-check --destination-directory %s --no-deps %s==%s " %\ - (pip_wheels_dir, product_info.name, product_info.version) - logger.write(pip_download_cmd, 3, False) - res_pip = (subprocess.call(pip_download_cmd, - shell=True, - cwd=config.LOCAL.workdir, - stdout=logger.logTxtFile, - stderr=subprocess.STDOUT) == 0) - return res_pip + pip_msg = "PIP : do nothing, product will be downloaded later at compile time " + logger.write(pip_msg, 3) + return True # check archive exists if not os.path.exists(product_info.archive_info.archive_name): diff --git a/src/internal_config/salomeTools.pyconf b/src/internal_config/salomeTools.pyconf index 6c678df..2b93e11 100644 --- a/src/internal_config/salomeTools.pyconf +++ b/src/internal_config/salomeTools.pyconf @@ -8,11 +8,17 @@ INTERNAL : { copy_prefix : "LOCAL_" install_dir : "INSTALL" + single_install_dir : "PRODUCTS" } log : { not_shown_commands : ["log"] } + command : + { + pip_download : "pip3 download --disable-pip-version-check" + pip_install : "pip3 install --disable-pip-version-check --no-index" + } } PRODUCTS : { diff --git a/src/product.py b/src/product.py index cdb3ab0..fd8276a 100644 --- a/src/product.py +++ b/src/product.py @@ -31,8 +31,8 @@ import src.versionMinorMajorPatch as VMMP AVAILABLE_VCS = ['git', 'svn', 'cvs'] -CONFIG_FILENAME = "sat-config.pyconf" # trace product depends version(s) -PRODUCT_FILENAME = "sat-product.pyconf" # trace product compile config +CONFIG_FILENAME = "sat-config-" # trace product depends version(s) +PRODUCT_FILENAME = "sat-product-" # trace product compile config config_expression = "^config-\d+$" def get_product_config(config, product_name, with_install_dir=True): @@ -484,9 +484,18 @@ def get_install_dir(config, base, version, prod_info): else: if "install_dir" not in prod_info or prod_info.install_dir == "base": # Set it to the default value (in application directory) - install_dir = os.path.join(config.APPLICATION.workdir, - config.INTERNAL.config.install_dir, - prod_info.name) + if ( src.appli_test_property(config,"single_install_dir", "yes") and + src.product.product_test_property(prod_info,"single_install_dir", "yes")): + # when single_install_dir mode is activated in tha application + # we use config.INTERNAL.config.single_install_dir for products + # having single_install_dir property + install_dir = os.path.join(config.APPLICATION.workdir, + config.INTERNAL.config.install_dir, + config.INTERNAL.config.single_install_dir) + else: + install_dir = os.path.join(config.APPLICATION.workdir, + config.INTERNAL.config.install_dir, + prod_info.name) else: install_dir = prod_info.install_dir @@ -545,12 +554,14 @@ def add_compile_config_file(p_info, config): # Write it in the install directory of the product # This file is for automatic reading/checking # see check_config_exists method - aFile = os.path.join(p_info.install_dir, CONFIG_FILENAME) + afilename = CONFIG_FILENAME + p_info.name + ".pyconf" + aFile = os.path.join(p_info.install_dir, afilename) with open(aFile, 'w') as f: res.__save__(f) # this file is not mandatory, is for human eye reading - aFile = os.path.join(p_info.install_dir, PRODUCT_FILENAME) + afilename = PRODUCT_FILENAME + p_info.name + ".pyconf" + aFile = os.path.join(p_info.install_dir, afilename) try: with open(aFile, 'w') as f: p_info.__save__(f, evaluated=True) # evaluated expressions mode @@ -593,7 +604,8 @@ def check_config_exists(config, prod_dir, prod_info, verbose=False): continue # check if there is the file sat-config.pyconf file in the installation # directory - config_file = os.path.join(prod_dir, dir_or_file, CONFIG_FILENAME) + afilename = PRODUCT_FILENAME + p_info.name + ".pyconf" + config_file = os.path.join(prod_dir, dir_or_file, afilename) DBG.write("check_config_exists 222", config_file, verbose) if not os.path.exists(config_file): continue @@ -749,7 +761,7 @@ def get_product_dependencies(config, product_info): res.append(prod_in_dep) return res -def check_installation(product_info): +def check_installation(config, product_info): """\ Verify if a product is well installed. Checks install directory presence and some additional files if it is defined in the config @@ -761,9 +773,20 @@ def check_installation(product_info): """ if not product_compiles(product_info): return True + install_dir = product_info.install_dir - if not os.path.exists(install_dir): - return False + 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. + filename = CONFIG_FILENAME + product_info.name + ".pyconf" + if not os.path.exists(os.path.join(install_dir, filename)): + return False + else: + if not os.path.exists(install_dir): + return False + + # check extra files if specified in present_files.install section if ("present_files" in product_info and "install" in product_info.present_files): for file_relative_path in product_info.present_files.install: