def _upload_package(self, pref, retry=None, retry_wait=None, integrity_check=False, policy=None, p_remote=None): assert (pref.revision is not None), "Cannot upload a package without PREV" assert (pref.ref.revision is not None), "Cannot upload a package without RREV" conanfile_path = self._cache.package_layout(pref.ref).conanfile() self._hook_manager.execute("pre_upload_package", conanfile_path=conanfile_path, reference=pref.ref, package_id=pref.id, remote=p_remote) t1 = time.time() the_files = self._compress_package_files(pref, integrity_check) with self._cache.package_layout( pref.ref).update_metadata() as metadata: metadata.packages[pref.id].checksums = calc_files_checksum( the_files) if policy == UPLOAD_POLICY_SKIP: return None files_to_upload, deleted = self._package_files_to_upload( pref, policy, the_files, p_remote) if files_to_upload or deleted: self._remote_manager.upload_package(pref, files_to_upload, deleted, p_remote, retry, retry_wait) logger.debug("UPLOAD: Time upload package: %f" % (time.time() - t1)) else: self._output.info("Package is up to date, upload skipped") duration = time.time() - t1 log_package_upload(pref, duration, the_files, p_remote) self._hook_manager.execute("post_upload_package", conanfile_path=conanfile_path, reference=pref.ref, package_id=pref.id, remote=p_remote) logger.debug("UPLOAD: Time uploader upload_package: %f" % (time.time() - t1)) metadata = self._cache.package_layout(pref.ref).load_metadata() cur_package_remote = metadata.packages[pref.id].remote if not cur_package_remote and policy != UPLOAD_POLICY_SKIP: with self._cache.package_layout( pref.ref).update_metadata() as metadata: metadata.packages[pref.id].remote = p_remote.name return pref
def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote, remotes): current_remote_name = self._cache.package_layout(ref).load_metadata().recipe.remote if remote.name != current_remote_name: complete_recipe_sources(self._remote_manager, self._cache, conanfile, ref, remotes) conanfile_path = self._cache.package_layout(ref).conanfile() self._hook_manager.execute("pre_upload_recipe", conanfile_path=conanfile_path, reference=ref, remote=remote) t1 = time.time() the_files = self._compress_recipe_files(ref) with self._cache.package_layout(ref).update_metadata() as metadata: metadata.recipe.checksums = calc_files_checksum(the_files) local_manifest = FileTreeManifest.loads(load(the_files["conanmanifest.txt"])) remote_manifest = None if policy != UPLOAD_POLICY_FORCE: # Check SCM data for auto fields if hasattr(conanfile, "scm") and ( conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto"): raise ConanException("The recipe has 'scm.url' or 'scm.revision' with 'auto' " "values. Use '--force' to ignore this error or export again " "the recipe ('conan export' or 'conan create') in a " "repository with no-uncommitted changes or by " "using the '--ignore-dirty' option") remote_manifest = self._check_recipe_date(ref, remote, local_manifest) if policy == UPLOAD_POLICY_SKIP: return ref files_to_upload, deleted = self._recipe_files_to_upload(ref, policy, the_files, remote, remote_manifest, local_manifest) if files_to_upload or deleted: self._remote_manager.upload_recipe(ref, files_to_upload, deleted, remote, retry, retry_wait) self._upload_recipe_end_msg(ref, remote) else: self._output.info("Recipe is up to date, upload skipped") duration = time.time() - t1 log_recipe_upload(ref, duration, the_files, remote.name) self._hook_manager.execute("post_upload_recipe", conanfile_path=conanfile_path, reference=ref, remote=remote) # The recipe wasn't in the registry or it has changed the revision field only if not current_remote_name: with self._cache.package_layout(ref).update_metadata() as metadata: metadata.recipe.remote = remote.name return ref
def prepare_recipe(self, ref, conanfile, remote, remotes, policy): """ do a bunch of things that are necessary before actually executing the upload: - retrieve exports_sources to complete the recipe if necessary - compress the artifacts in conan_export.tgz and conan_export_sources.tgz - check if package is ok to be uploaded, if scm info missing, will raise - check if the remote recipe is newer, raise - compare and decide which files need to be uploaded (and deleted from server) """ layout = self._cache.package_layout(ref) current_remote_name = layout.load_metadata().recipe.remote if remote.name != current_remote_name: retrieve_exports_sources(self._remote_manager, self._cache, conanfile, ref, remotes) conanfile_path = layout.conanfile() self._hook_manager.execute("pre_upload_recipe", conanfile_path=conanfile_path, reference=ref, remote=remote) t1 = time.time() cache_files = self._compress_recipe_files(layout, ref) with layout.update_metadata() as metadata: metadata.recipe.checksums = calc_files_checksum(cache_files) local_manifest = FileTreeManifest.loads( load(cache_files["conanmanifest.txt"])) remote_manifest = None if policy != UPLOAD_POLICY_FORCE: # Check SCM data for auto fields if hasattr(conanfile, "scm") and (conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto" or conanfile.scm.get("type") is None or conanfile.scm.get("url") is None or conanfile.scm.get("revision") is None): raise ConanException( "The recipe contains invalid data in the 'scm' attribute" " (some 'auto' values or missing fields 'type', 'url' or" " 'revision'). Use '--force' to ignore this error or export" " again the recipe ('conan export' or 'conan create') to" " fix these issues.") remote_manifest = self._check_recipe_date(ref, remote, local_manifest) if policy == UPLOAD_POLICY_SKIP: return files_to_upload, deleted = self._recipe_files_to_upload( ref, policy, cache_files, remote, remote_manifest, local_manifest) return files_to_upload, deleted, cache_files, conanfile_path, t1, current_remote_name, layout
def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote, remotes): layout = self._cache.package_layout(ref) current_remote_name = layout.load_metadata().recipe.remote if remote.name != current_remote_name: retrieve_exports_sources(self._remote_manager, self._cache, conanfile, ref, remotes) conanfile_path = layout.conanfile() self._hook_manager.execute("pre_upload_recipe", conanfile_path=conanfile_path, reference=ref, remote=remote) t1 = time.time() cache_files = self._compress_recipe_files(layout, ref) with layout.update_metadata() as metadata: metadata.recipe.checksums = calc_files_checksum(cache_files) local_manifest = FileTreeManifest.loads( load(cache_files["conanmanifest.txt"])) remote_manifest = None if policy != UPLOAD_POLICY_FORCE: # Check SCM data for auto fields if hasattr(conanfile, "scm") and (conanfile.scm.get("url") == "auto" or conanfile.scm.get("revision") == "auto" or conanfile.scm.get("type") is None or conanfile.scm.get("url") is None or conanfile.scm.get("revision") is None): raise ConanException( "The recipe contains invalid data in the 'scm' attribute" " (some 'auto' values or missing fields 'type', 'url' or" " 'revision'). Use '--force' to ignore this error or export" " again the recipe ('conan export' or 'conan create') to" " fix these issues.") remote_manifest = self._check_recipe_date(ref, remote, local_manifest) if policy == UPLOAD_POLICY_SKIP: return ref files_to_upload, deleted = self._recipe_files_to_upload( ref, policy, cache_files, remote, remote_manifest, local_manifest) if files_to_upload or deleted: self._remote_manager.upload_recipe(ref, files_to_upload, deleted, remote, retry, retry_wait) self._upload_recipe_end_msg(ref, remote) else: self._output.info("Recipe is up to date, upload skipped") duration = time.time() - t1 log_recipe_upload(ref, duration, cache_files, remote.name) self._hook_manager.execute("post_upload_recipe", conanfile_path=conanfile_path, reference=ref, remote=remote) # The recipe wasn't in the registry or it has changed the revision field only if not current_remote_name: with layout.update_metadata() as metadata: metadata.recipe.remote = remote.name return ref