From: crouzet Date: Mon, 29 Jul 2019 15:04:24 +0000 (+0200) Subject: do not create install dir for pip products installed in python, adapt archives to... X-Git-Tag: 5.5.0~39 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7a787183cb2b20bfaf8ec42fc863aa9fa2499d88;p=tools%2Fsat.git do not create install dir for pip products installed in python, adapt archives to single dir and pip --- diff --git a/commands/compile.py b/commands/compile.py index 9748b16..47a3d4b 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -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 diff --git a/commands/config.py b/commands/config.py index 3d44311..8e34e6d 100644 --- a/commands/config.py +++ b/commands/config.py @@ -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, diff --git a/commands/package.py b/commands/package.py index 865979e..c9a033c 100644 --- a/commands/package.py +++ b/commands/package.py @@ -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" diff --git a/commands/template.py b/commands/template.py index 23eddb0..b7ee487 100644 --- a/commands/template.py +++ b/commands/template.py @@ -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) diff --git a/src/environment.py b/src/environment.py index 81505bf..89dfece 100644 --- a/src/environment.py +++ b/src/environment.py @@ -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) diff --git a/src/fileEnviron.py b/src/fileEnviron.py index 5b293ff..ef900f3 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -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)) diff --git a/src/product.py b/src/product.py index fd8276a..029ecb0 100644 --- a/src/product.py +++ b/src/product.py @@ -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