def install_cmake_package(self, requirement_specifier, cmake_options, ignore_index): """ Build and install cmake package into cache & copy it to env. """ pkg_cache_dir = os.path.abspath( os.path.join(self.cache, "%s-%s" % (requirement_specifier.name, requirement_specifier.version)) ) def in_cache(): return os.path.isdir(pkg_cache_dir) if not in_cache() and not ignore_index: cwd = os.getcwd() archive = None archive_name = None try: archive = self.download(requirement_specifier.name, requirement_specifier.version) archive_name = unpack(archive) logging.info("Building %s" % requirement_specifier.name) os.chdir(archive_name) env = os.environ.copy() env["PKG_CONFIG_PATH"] = ",".join(self.search_pkg_config_locations()) retcode = run_shell( ["cmake", ".", "-DCMAKE_INSTALL_PREFIX=%s" % pkg_cache_dir] + cmake_options, env=env, verbose=self.settings["verbosity"] >= 1, ) if retcode != 0: raise RequirementException("%s configure failed" % requirement_specifier.name) retcode = run_shell(["make", "-j4"], verbose=self.settings["verbosity"] >= 1) if retcode != 0: raise RequirementException("%s build failed" % requirement_specifier.name) retcode = run_shell(["make", "install"], verbose=self.settings["verbosity"] >= 1) if retcode != 0: raise RequirementException('%s "make install" failed' % requirement_specifier.name) finally: safe_remove(archive) safe_remove(archive_name) os.chdir(cwd) pkg_install_dir = os.path.join( self.env, "lib/%s-%s" % (requirement_specifier.name, requirement_specifier.version) ) if in_cache(): # install gazebo somewhere into venv if os.path.exists(pkg_install_dir): shutil.rmtree(pkg_install_dir) shutil.copytree(pkg_cache_dir, pkg_install_dir) else: raise RequirementException("can't find gazebo-%s in robustus cache" % requirement_specifier.version) return pkg_install_dir
def install_satisfactory_requirement_from_remote(self, requirement_specifier): """ If wheel for satisfactory requirement found on remote, install it. :param requirement_specifier: specifies package namd and package version string :return: True if package installed by function (according to pip return code); False otherwise. """ logging.info("Attempting to install package from remote wheel") for find_link in self.settings["find_links"]: find_links_url = (find_link + "/python-wheels/index.html",) # TEMPORARY. dtemp_path = tempfile.mkdtemp() return_code = run_shell( [ self.pip_executable, "install", "--download-cache=%s" % dtemp_path, "--no-index", "--use-wheel", "--find-links=%s" % find_links_url, requirement_specifier.freeze(), ], verbose=self.settings["verbosity"] >= 2, ) if return_code == 0: # The following downloads the wheels of the requirment (and those of # dependencies) into a pip download cache and moves (renames) the downloaded # wheels into the local Robustus cache. Regarding the need for this see "Wheels # for Dependencies" "http://lucumr.pocoo.org/2014/1/27/python-on-wheels/". for file_path in glob.glob(os.path.join(dtemp_path, "http*.whl")): if os.path.isfile(file_path): file_name = os.path.basename(file_path) file_name_new = file_name.rpartition("%2F")[-1] file_path_new = os.path.join(self.cache, file_name_new) shutil.move(file_path, file_path_new) # NOTE: Allow overwrites. safe_remove(dtemp_path) return True else: logging.info( "pip failed to install requirement %s from remote wheels cache %s." % (requirement_specifier.freeze(), find_links_url) ) safe_remove(dtemp_path) return False