From 16f547f334ed58cb9253fe46fa699d74c57ac28b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Wed, 13 Nov 2024 11:02:04 +0100 Subject: [PATCH 01/14] wip --- crates/rattler/src/install/link.rs | 248 +++++++++++- crates/rattler/src/install/mod.rs | 358 +++++++++++++++++- ..._test__link_package_from_package_file.snap | 76 ++++ 3 files changed, 680 insertions(+), 2 deletions(-) create mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap diff --git a/crates/rattler/src/install/link.rs b/crates/rattler/src/install/link.rs index 9b49a7eea..4f38e1c7c 100644 --- a/crates/rattler/src/install/link.rs +++ b/crates/rattler/src/install/link.rs @@ -6,12 +6,13 @@ use rattler_conda_types::package::{FileMode, PathType, PathsEntry, PrefixPlaceho use rattler_conda_types::Platform; use rattler_digest::Sha256; use rattler_digest::{HashingWriter, Sha256Hash}; +use rattler_package_streaming::seek::stream_conda_content; use reflink_copy::reflink; use regex::Regex; use std::borrow::Cow; use std::fmt; use std::fmt::Formatter; -use std::fs::Permissions; +use std::fs::{File, Permissions}; use std::io::{ErrorKind, Read, Seek, Write}; use std::path::{Path, PathBuf}; @@ -126,6 +127,197 @@ pub struct LinkedFile { pub prefix_placeholder: Option, } +/// Todo: docs +#[allow(clippy::too_many_arguments)] // TODO: Fix this properly +pub fn link_file_from_package_file( + path_json_entry: &PathsEntry, + destination_relative_path: PathBuf, + package_path: &Path, + target_dir: &Path, + target_prefix: &str, + allow_symbolic_links: bool, + allow_hard_links: bool, + allow_ref_links: bool, + target_platform: Platform, + apple_codesign_behavior: AppleCodeSignBehavior, +) -> Result { + // panic!("Not implemented"); + let source_path = package_path.join(&path_json_entry.relative_path); + // let source_path = package_dir.join(&path_json_entry.relative_path); + + let destination_path = target_dir.join(&destination_relative_path); + + // Temporary variables to store intermediate computations in. If we already computed the file + // size or the sha hash we dont have to recompute them at the end of the function. + let mut sha256 = None; + let mut file_size = path_json_entry.size_in_bytes; + + let link_method = if let Some(PrefixPlaceholder { + file_mode, + placeholder, + }) = path_json_entry.prefix_placeholder.as_ref() + { + panic!("{:?}", source_path); + // Memory map the source file. This provides us with easy access to a continuous stream of + // bytes which makes it easier to search for the placeholder prefix. + let source = map_or_read_source_file(&source_path)?; + + // Open the destination file + let destination = std::fs::File::create(&destination_path) + .map_err(LinkFileError::FailedToOpenDestinationFile)?; + let mut destination_writer = HashingWriter::<_, rattler_digest::Sha256>::new(destination); + + // Convert back-slashes (\) on windows with forward-slashes (/) to avoid problems with + // string escaping. For instance if we replace the prefix in the following text + // + // ```text + // string = "c:\\old_prefix" + // ``` + // + // with the path `c:\new_prefix` the text will become: + // + // ```text + // string = "c:\new_prefix" + // ``` + // + // In this case the literal string is not properly escape. This is fixed by using + // forward-slashes on windows instead. + let target_prefix = if target_platform.is_windows() { + Cow::Owned(target_prefix.replace('\\', "/")) + } else { + Cow::Borrowed(target_prefix) + }; + + // Replace the prefix placeholder in the file with the new placeholder + copy_and_replace_placeholders( + source.as_ref(), + &mut destination_writer, + placeholder, + &target_prefix, + &target_platform, + *file_mode, + ) + .map_err(|err| LinkFileError::IoError(String::from("replacing placeholders"), err))?; + + let (mut file, current_hash) = destination_writer.finalize(); + + // We computed the hash of the file while writing and from the file we can also infer the + // size of it. + sha256 = Some(current_hash); + file_size = file.stream_position().ok(); + + // We no longer need the file. + drop(file); + + // Copy over filesystem permissions. We do this to ensure that the destination file has the + // same permissions as the source file. + let metadata = std::fs::symlink_metadata(&source_path) + .map_err(LinkFileError::FailedToReadSourceFileMetadata)?; + std::fs::set_permissions(&destination_path, metadata.permissions()) + .map_err(LinkFileError::FailedToUpdateDestinationFilePermissions)?; + + // (re)sign the binary if the file is executable + if has_executable_permissions(&metadata.permissions()) + && target_platform == Platform::OsxArm64 + && *file_mode == FileMode::Binary + { + // Did the binary actually change? + let mut content_changed = false; + if let Some(original_hash) = &path_json_entry.sha256 { + content_changed = original_hash != ¤t_hash; + } + + // If the binary changed it requires resigning. + if content_changed && apple_codesign_behavior != AppleCodeSignBehavior::DoNothing { + match codesign(&destination_path) { + Ok(_) => {} + Err(e) => { + if apple_codesign_behavior == AppleCodeSignBehavior::Fail { + return Err(e); + } + } + } + + // The file on disk changed from the original file so the hash and file size + // also became invalid. Let's recompute them. + sha256 = Some( + rattler_digest::compute_file_digest::(&destination_path) + .map_err(LinkFileError::FailedToComputeSha)?, + ); + file_size = Some( + std::fs::symlink_metadata(&destination_path) + .map_err(LinkFileError::FailedToOpenDestinationFile)? + .len(), + ); + } + } + LinkMethod::Patched(*file_mode) + } else if path_json_entry.path_type == PathType::HardLink && allow_ref_links { + panic!("reflink {:?}", source_path); + reflink_to_destination(&source_path, &destination_path, allow_hard_links)? + } else if path_json_entry.path_type == PathType::HardLink && allow_hard_links { + panic!("hardlink {:?}", source_path); + hardlink_to_destination(&source_path, &destination_path)? + } else if path_json_entry.path_type == PathType::SoftLink && allow_symbolic_links { + panic!("symlink {:?}", source_path); + symlink_to_destination(&source_path, &destination_path)? + } else { + copy_to_destination_from_package_file(&package_path, &path_json_entry.relative_path, &destination_path)? + }; + + // Compute the final SHA256 if we didnt already or if its not stored in the paths.json entry. + let sha256 = if let Some(sha256) = sha256 { + sha256 + } else if link_method == LinkMethod::Softlink { + // we hash the content of the symlink file. Note that this behavior is different from + // conda or mamba (where the target of the symlink is hashed). However, hashing the target + // of the symlink is more tricky in our case as we link everything in parallel and would have to + // potentially "wait" for dependencies to be available. + // This needs to be taken into account when verifying an installation. + let linked_path = destination_path + .read_link() + .map_err(LinkFileError::FailedToReadSymlink)?; + rattler_digest::compute_bytes_digest::( + linked_path.as_os_str().to_string_lossy().as_bytes(), + ) + } else if let Some(sha256) = path_json_entry.sha256 { + sha256 + } else if path_json_entry.path_type == PathType::HardLink { + rattler_digest::compute_file_digest::(&destination_path) + .map_err(LinkFileError::FailedToComputeSha)? + } else { + // This is either a softlink or a directory. + // Computing the hash for a directory is not possible. + // This hash is `0000...0000` + Sha256Hash::default() + }; + + // Compute the final file size if we didnt already. + let file_size = if let Some(file_size) = file_size { + file_size + } else if let Some(size_in_bytes) = path_json_entry.size_in_bytes { + size_in_bytes + } else { + let metadata = std::fs::symlink_metadata(&destination_path) + .map_err(LinkFileError::FailedToOpenDestinationFile)?; + metadata.len() + }; + + let prefix_placeholder: Option = path_json_entry + .prefix_placeholder + .as_ref() + .map(|p| p.placeholder.clone()); + + Ok(LinkedFile { + clobbered: false, + sha256, + file_size, + relative_path: destination_relative_path, + method: link_method, + prefix_placeholder, + }) +} + /// Installs a single file from a `package_dir` to the the `target_dir`. Replaces any /// `prefix_placeholder` in the file with the `prefix`. /// @@ -458,6 +650,60 @@ fn symlink_to_destination( } } +/// Copy the specified file from the source (or cached) directory. If the file already exists it is +/// removed and the operation is retried. +fn copy_to_destination_from_package_file( + package_path: &Path, + relative_path: &Path, + destination_path: &Path, +) -> Result { + // todo: fix unwraps + // panic!("{:?} {:?} {:?}", package_path, relative_path, destination_path); + // assert file is .conda + let f = File::open(package_path).unwrap(); + let mut archive = stream_conda_content(f).unwrap(); + let mut entry = archive.entries().unwrap().find(|entry| { + entry.as_ref().unwrap().path().unwrap() == relative_path + }).unwrap().unwrap(); + + // panic!("{:?}", entry.path()); + + loop { + // todo: or unpack_in? + match entry.unpack(destination_path) { + Err(e) if e.kind() == ErrorKind::AlreadyExists => { + // If the file already exists, remove it and try again. + std::fs::remove_file(destination_path).map_err(|err| { + LinkFileError::IoError(String::from("removing clobbered file"), err) + })?; + } + Ok(_) => return Ok(LinkMethod::Copy), + Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), + } + // match std::fs::copy(entry, destination_path) { + // Err(e) if e.kind() == ErrorKind::AlreadyExists => { + // If the file already exists, remove it and try again. + // std::fs::remove_file(destination_path).map_err(|err| { + // LinkFileError::IoError(String::from("removing clobbered file"), err) + // })?; + // } + // Ok(_) => return Ok(LinkMethod::Copy), + // Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), + // } + + // match std::fs::copy(package_path, destination_path) { + // Err(e) if e.kind() == ErrorKind::AlreadyExists => { + // // If the file already exists, remove it and try again. + // std::fs::remove_file(destination_path).map_err(|err| { + // LinkFileError::IoError(String::from("removing clobbered file"), err) + // })?; + // } + // Ok(_) => return Ok(LinkMethod::Copy), + // Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), + // } + } +} + /// Copy the specified file from the source (or cached) directory. If the file already exists it is /// removed and the operation is retried. fn copy_to_destination( diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index ed5691ff9..dd3f5d056 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -49,6 +49,7 @@ pub use installer::{ }; pub use installer::{Installer, InstallerError, Reporter}; use itertools::Itertools; +use link::link_file_from_package_file; pub use link::{link_file, LinkFileError, LinkMethod}; pub use python::PythonInfo; use rattler_conda_types::{ @@ -56,6 +57,7 @@ use rattler_conda_types::{ prefix_record::PathsEntry, Platform, }; +use rattler_package_streaming::seek::read_package_file; use simple_spawn_blocking::Cancelled; use tokio::task::JoinError; use tracing::instrument; @@ -242,6 +244,290 @@ pub struct InstallOptions { pub apple_codesign_behavior: AppleCodeSignBehavior, } +/// Given a non-extracted conda package (`package_path`), installs its files +/// to the `target_dir`. +/// +/// Returns a [`PathsEntry`] for every file that was linked into the target +/// directory. The entries are ordered in the same order as they appear in the +/// `paths.json` file of the package. +pub async fn link_package_from_package_file( + package_path: &Path, + target_dir: &Path, + driver: &InstallDriver, + options: InstallOptions, +) -> Result, InstallError> { + // TODO: incorporate in link_package function + + // Determine the target prefix for linking + let target_prefix = options + .target_prefix + .as_deref() + .unwrap_or(target_dir) + .to_str() + .ok_or(InstallError::TargetPrefixIsNotUtf8)? + .to_owned(); + + // Ensure target directory exists + tokio::fs::create_dir_all(&target_dir) + .await + .map_err(InstallError::FailedToCreateTargetDirectory)?; + + // Reuse or read the `paths.json` and `index.json` files from the package + // directory + let paths_json = read_paths_json_from_package_file(package_path, driver, options.paths_json); + let index_json = read_index_json_from_package_file(package_path, driver, options.index_json); + let (paths_json, index_json) = tokio::try_join!(paths_json, index_json)?; + + // Error out if this is a noarch python package but the python information is + // missing. + if index_json.noarch.is_python() && options.python_info.is_none() { + return Err(InstallError::MissingPythonInfo); + } + + // Parse the `link.json` file and extract entry points from it. + let link_json = if index_json.noarch.is_python() { + read_link_json_from_package_file(package_path, driver, options.link_json.flatten()).await? + } else { + None + }; + + // Determine whether or not we can use symbolic links + let (allow_symbolic_links, allow_hard_links) = (false, false); + let allow_ref_links = false; + + // Determine the platform to use + let platform = options.platform.unwrap_or(Platform::current()); + + // compute all path renames + let mut final_paths = compute_paths(&index_json, &paths_json, options.python_info.as_ref()); + + // register all paths in the install driver path registry + let clobber_paths = Arc::new( + driver + .clobber_registry() + .register_paths(&index_json, &final_paths), + ); + + for (_, computed_path) in final_paths.iter_mut() { + if let Some(clobber_rename) = clobber_paths.get(computed_path) { + *computed_path = clobber_rename.clone(); + } + } + + // Figure out all the directories that we are going to need + let mut directories_to_construct = HashSet::new(); + for (_, computed_path) in final_paths.iter() { + let mut current_path = computed_path.parent(); + while let Some(path) = current_path { + if !path.as_os_str().is_empty() && directories_to_construct.insert(path.to_path_buf()) { + current_path = path.parent(); + } else { + break; + } + } + } + + let directories_target_dir = target_dir.to_path_buf(); + driver + .run_blocking_io_task(move || { + for directory in directories_to_construct.into_iter().sorted() { + let full_path = directories_target_dir.join(directory); + match fs::create_dir(&full_path) { + Ok(_) => (), + Err(e) if e.kind() == ErrorKind::AlreadyExists => (), + Err(e) => return Err(InstallError::FailedToCreateDirectory(full_path, e)), + } + } + Ok(()) + }) + .await?; + + // Wrap the python info in an `Arc` so we can more easily share it with async + // tasks. + let python_info = options.python_info.map(Arc::new); + + // Start linking all package files in parallel + let mut pending_futures = FuturesUnordered::new(); + let mut number_of_paths_entries = 0; + for (entry, computed_path) in final_paths { + let package_path = package_path.to_owned(); + let target_dir = target_dir.to_owned(); + let target_prefix = target_prefix.clone(); + + let clobber_rename = clobber_paths.get(&entry.relative_path).cloned(); + let install_future = async move { + let _permit = driver.acquire_io_permit().await; + + // Spawn a blocking task to link the specific file. We use a blocking task here + // because filesystem access is blocking anyway so its more + // efficient to group them together in a single blocking call. + let cloned_entry = entry.clone(); + let result = match tokio::task::spawn_blocking(move || { + link_file_from_package_file( + &cloned_entry, + computed_path, + &package_path, + &target_dir, + &target_prefix, + allow_symbolic_links && !cloned_entry.no_link, + allow_hard_links && !cloned_entry.no_link, + allow_ref_links && !cloned_entry.no_link, + platform, + options.apple_codesign_behavior, + ) + }) + .await + .map_err(JoinError::try_into_panic) + { + Ok(Ok(linked_file)) => linked_file, + Ok(Err(e)) => { + return Err(InstallError::FailedToLink(entry.relative_path.clone(), e)) + } + Err(Ok(payload)) => std::panic::resume_unwind(payload), + Err(Err(_err)) => return Err(InstallError::Cancelled), + }; + + // Construct a `PathsEntry` from the result of the linking operation + let paths_entry = PathsEntry { + relative_path: result.relative_path, + original_path: if clobber_rename.is_some() { + Some(entry.relative_path) + } else { + None + }, + path_type: entry.path_type.into(), + no_link: entry.no_link, + sha256: entry.sha256, + sha256_in_prefix: Some(result.sha256), + size_in_bytes: Some(result.file_size), + file_mode: match result.method { + LinkMethod::Patched(file_mode) => Some(file_mode), + _ => None, + }, + prefix_placeholder: entry + .prefix_placeholder + .as_ref() + .map(|p| p.placeholder.clone()), + }; + + Ok(vec![(number_of_paths_entries, paths_entry)]) + }; + + pending_futures.push(install_future.boxed()); + number_of_paths_entries += 1; + } + + // If this package is a noarch python package we also have to create entry + // points. + // + // Be careful with the fact that this code is currently running in parallel with + // the linking of individual files. + if let Some(link_json) = link_json { + // Parse the `link.json` file and extract entry points from it. + let entry_points = match link_json.noarch { + NoArchLinks::Python(entry_points) => entry_points.entry_points, + NoArchLinks::Generic => { + unreachable!("we only use link.json for noarch: python packages") + } + }; + + // Get python info + let python_info = python_info + .clone() + .expect("should be safe because its checked above that this contains a value"); + + // Create entry points for each listed item. This is different between Windows + // and unix because on Windows, two PathEntry's are created whereas on + // Linux only one is created. + for entry_point in entry_points { + let python_info = python_info.clone(); + let target_dir = target_dir.to_owned(); + let target_prefix = target_prefix.clone(); + + let entry_point_fut = async move { + // Acquire an IO permit + let _permit = driver.acquire_io_permit().await; + + let entries = if platform.is_windows() { + match create_windows_python_entry_point( + &target_dir, + &target_prefix, + &entry_point, + &python_info, + &platform, + ) { + Ok([a, b]) => vec![ + (number_of_paths_entries, a), + (number_of_paths_entries + 1, b), + ], + Err(e) => return Err(InstallError::FailedToCreatePythonEntryPoint(e)), + } + } else { + match create_unix_python_entry_point( + &target_dir, + &target_prefix, + &entry_point, + &python_info, + ) { + Ok(a) => vec![(number_of_paths_entries, a)], + Err(e) => return Err(InstallError::FailedToCreatePythonEntryPoint(e)), + } + }; + + Ok(entries) + }; + + pending_futures.push(entry_point_fut.boxed()); + number_of_paths_entries += if platform.is_windows() { 2 } else { 1 }; + } + } + + // Await the result of all the background tasks. The background tasks are + // scheduled in order, however, they can complete in any order. This means + // we have to reorder them back into their original order. This is achieved + // by waiting to add finished results to the result Vec, if the result + // before it has not yet finished. To that end we use a `BinaryHeap` as a + // priority queue which will buffer up finished results that finished before + // their predecessor. + // + // What makes this loop special is that it also aborts if any of the returned + // results indicate a failure. + let mut paths = Vec::with_capacity(number_of_paths_entries); + let mut out_of_order_queue = BinaryHeap::>::with_capacity(100); + while let Some(link_result) = pending_futures.next().await { + for (index, data) in link_result? { + if index == paths.len() { + // If this is the next element expected in the sorted list, add it immediately. + // This basically means the future finished in order. + paths.push(data); + + // By adding a finished future we have to check if there might also be another + // future that finished earlier and should also now be added to + // the result Vec. + while let Some(next_output) = out_of_order_queue.peek_mut() { + if next_output.index == paths.len() { + paths.push(PeekMut::pop(next_output).data); + } else { + break; + } + } + } else { + // Otherwise add it to the out-of-order queue. This means that we still have to + // wait for another element before we can add the result to the + // ordered list. + out_of_order_queue.push(OrderWrapper { index, data }); + } + } + } + debug_assert_eq!( + paths.len(), + paths.capacity(), + "some futures where not added to the result" + ); + + Ok(paths) +} + /// Given an extracted package archive (`package_dir`), installs its files to /// the `target_dir`. /// @@ -557,6 +843,27 @@ fn compute_paths( final_paths } +/// TODO docs +async fn read_paths_json_from_package_file( + package_path: &Path, + driver: &InstallDriver, + paths_json: Option, +) -> Result { + if let Some(paths_json) = paths_json { + Ok(paths_json) + } else { + // TODO: unwrap + Ok(read_package_file::(package_path).unwrap())//.map_err(InstallError::FailedToReadPathsJson) + // let package_path = package_path.to_owned(); + // driver + // .run_blocking_io_task(move || { + // PathsJson::from_package_directory_with_deprecated_fallback(&package_path) + // .map_err(InstallError::FailedToReadPathsJson) + // }) + // .await + } +} + /// A helper function that reads the `paths.json` file from a package unless it /// has already been provided, in which case it is returned immediately. async fn read_paths_json( @@ -577,6 +884,26 @@ async fn read_paths_json( } } +/// todo docs +async fn read_index_json_from_package_file( + package_path: &Path, + driver: &InstallDriver, + index_json: Option, +) -> Result { + // todo unwrap + Ok(read_package_file::(package_path).unwrap()) +} + +/// todo docs +async fn read_link_json_from_package_file( + package_path: &Path, + driver: &InstallDriver, + index_json: Option, +) -> Result, InstallError> { + // todo unwrap + Ok(Some(read_package_file::(package_path).unwrap())) +} + /// A helper function that reads the `index.json` file from a package unless it /// has already been provided, in which case it is returned immediately. async fn read_index_json( @@ -722,7 +1049,7 @@ mod test { use crate::{ get_test_data_dir, - install::{link_package, InstallDriver, InstallOptions, PythonInfo}, + install::{link_package, link_package_from_package_file, InstallDriver, InstallOptions, PythonInfo}, package_cache::PackageCache, }; @@ -876,4 +1203,33 @@ mod test { insta::assert_yaml_snapshot!(paths); } + + #[tracing_test::traced_test] + #[tokio::test] + async fn test_link_package_from_package_file() { + let environment_dir = tempfile::TempDir::new().unwrap(); + + let package_path = tools::download_and_cache_file_async( + "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda" + .parse() + .unwrap(), + "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd", + ) + .await + .unwrap(); + + let install_driver = InstallDriver::default(); + + // Link the package + let paths = link_package_from_package_file( + &package_path, + environment_dir.path(), + &install_driver, + InstallOptions::default(), + ) + .await + .unwrap(); + + insta::assert_yaml_snapshot!(paths); + } } diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap new file mode 100644 index 000000000..e4ae8dc9b --- /dev/null +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap @@ -0,0 +1,76 @@ +--- +source: crates/rattler/src/install/mod.rs +assertion_line: 1233 +expression: paths +snapshot_kind: text +--- +- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER + path_type: hardlink + sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + size_in_bytes: 5 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA + path_type: hardlink + sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + size_in_bytes: 77203 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD + path_type: hardlink + sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + size_in_bytes: 896 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL + path_type: hardlink + sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + size_in_bytes: 94 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json + path_type: hardlink + sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + size_in_bytes: 119 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE + path_type: hardlink + sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + size_in_bytes: 30157 +- _path: Lib/site-packages/ruff/__init__.py + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff/__main__.py + path_type: hardlink + sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + size_in_bytes: 193 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc + path_type: hardlink + sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + size_in_bytes: 160 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc + path_type: hardlink + sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + size_in_bytes: 143 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc + path_type: hardlink + sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + size_in_bytes: 383 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc + path_type: hardlink + sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + size_in_bytes: 629 +- _path: Scripts/ruff.exe + path_type: hardlink + sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + size_in_bytes: 6896640 From cf98c31db6180c937c7c9fd3d0a1a5fd72d1c587 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Wed, 13 Nov 2024 18:02:08 +0100 Subject: [PATCH 02/14] cleanup --- crates/rattler/src/install/link.rs | 248 +----------- crates/rattler/src/install/mod.rs | 353 ++---------------- ...est__link_package_from_package_file-2.snap | 76 ++++ ..._test__link_package_from_package_file.snap | 192 ++++++---- 4 files changed, 228 insertions(+), 641 deletions(-) create mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap diff --git a/crates/rattler/src/install/link.rs b/crates/rattler/src/install/link.rs index 4f38e1c7c..9b49a7eea 100644 --- a/crates/rattler/src/install/link.rs +++ b/crates/rattler/src/install/link.rs @@ -6,13 +6,12 @@ use rattler_conda_types::package::{FileMode, PathType, PathsEntry, PrefixPlaceho use rattler_conda_types::Platform; use rattler_digest::Sha256; use rattler_digest::{HashingWriter, Sha256Hash}; -use rattler_package_streaming::seek::stream_conda_content; use reflink_copy::reflink; use regex::Regex; use std::borrow::Cow; use std::fmt; use std::fmt::Formatter; -use std::fs::{File, Permissions}; +use std::fs::Permissions; use std::io::{ErrorKind, Read, Seek, Write}; use std::path::{Path, PathBuf}; @@ -127,197 +126,6 @@ pub struct LinkedFile { pub prefix_placeholder: Option, } -/// Todo: docs -#[allow(clippy::too_many_arguments)] // TODO: Fix this properly -pub fn link_file_from_package_file( - path_json_entry: &PathsEntry, - destination_relative_path: PathBuf, - package_path: &Path, - target_dir: &Path, - target_prefix: &str, - allow_symbolic_links: bool, - allow_hard_links: bool, - allow_ref_links: bool, - target_platform: Platform, - apple_codesign_behavior: AppleCodeSignBehavior, -) -> Result { - // panic!("Not implemented"); - let source_path = package_path.join(&path_json_entry.relative_path); - // let source_path = package_dir.join(&path_json_entry.relative_path); - - let destination_path = target_dir.join(&destination_relative_path); - - // Temporary variables to store intermediate computations in. If we already computed the file - // size or the sha hash we dont have to recompute them at the end of the function. - let mut sha256 = None; - let mut file_size = path_json_entry.size_in_bytes; - - let link_method = if let Some(PrefixPlaceholder { - file_mode, - placeholder, - }) = path_json_entry.prefix_placeholder.as_ref() - { - panic!("{:?}", source_path); - // Memory map the source file. This provides us with easy access to a continuous stream of - // bytes which makes it easier to search for the placeholder prefix. - let source = map_or_read_source_file(&source_path)?; - - // Open the destination file - let destination = std::fs::File::create(&destination_path) - .map_err(LinkFileError::FailedToOpenDestinationFile)?; - let mut destination_writer = HashingWriter::<_, rattler_digest::Sha256>::new(destination); - - // Convert back-slashes (\) on windows with forward-slashes (/) to avoid problems with - // string escaping. For instance if we replace the prefix in the following text - // - // ```text - // string = "c:\\old_prefix" - // ``` - // - // with the path `c:\new_prefix` the text will become: - // - // ```text - // string = "c:\new_prefix" - // ``` - // - // In this case the literal string is not properly escape. This is fixed by using - // forward-slashes on windows instead. - let target_prefix = if target_platform.is_windows() { - Cow::Owned(target_prefix.replace('\\', "/")) - } else { - Cow::Borrowed(target_prefix) - }; - - // Replace the prefix placeholder in the file with the new placeholder - copy_and_replace_placeholders( - source.as_ref(), - &mut destination_writer, - placeholder, - &target_prefix, - &target_platform, - *file_mode, - ) - .map_err(|err| LinkFileError::IoError(String::from("replacing placeholders"), err))?; - - let (mut file, current_hash) = destination_writer.finalize(); - - // We computed the hash of the file while writing and from the file we can also infer the - // size of it. - sha256 = Some(current_hash); - file_size = file.stream_position().ok(); - - // We no longer need the file. - drop(file); - - // Copy over filesystem permissions. We do this to ensure that the destination file has the - // same permissions as the source file. - let metadata = std::fs::symlink_metadata(&source_path) - .map_err(LinkFileError::FailedToReadSourceFileMetadata)?; - std::fs::set_permissions(&destination_path, metadata.permissions()) - .map_err(LinkFileError::FailedToUpdateDestinationFilePermissions)?; - - // (re)sign the binary if the file is executable - if has_executable_permissions(&metadata.permissions()) - && target_platform == Platform::OsxArm64 - && *file_mode == FileMode::Binary - { - // Did the binary actually change? - let mut content_changed = false; - if let Some(original_hash) = &path_json_entry.sha256 { - content_changed = original_hash != ¤t_hash; - } - - // If the binary changed it requires resigning. - if content_changed && apple_codesign_behavior != AppleCodeSignBehavior::DoNothing { - match codesign(&destination_path) { - Ok(_) => {} - Err(e) => { - if apple_codesign_behavior == AppleCodeSignBehavior::Fail { - return Err(e); - } - } - } - - // The file on disk changed from the original file so the hash and file size - // also became invalid. Let's recompute them. - sha256 = Some( - rattler_digest::compute_file_digest::(&destination_path) - .map_err(LinkFileError::FailedToComputeSha)?, - ); - file_size = Some( - std::fs::symlink_metadata(&destination_path) - .map_err(LinkFileError::FailedToOpenDestinationFile)? - .len(), - ); - } - } - LinkMethod::Patched(*file_mode) - } else if path_json_entry.path_type == PathType::HardLink && allow_ref_links { - panic!("reflink {:?}", source_path); - reflink_to_destination(&source_path, &destination_path, allow_hard_links)? - } else if path_json_entry.path_type == PathType::HardLink && allow_hard_links { - panic!("hardlink {:?}", source_path); - hardlink_to_destination(&source_path, &destination_path)? - } else if path_json_entry.path_type == PathType::SoftLink && allow_symbolic_links { - panic!("symlink {:?}", source_path); - symlink_to_destination(&source_path, &destination_path)? - } else { - copy_to_destination_from_package_file(&package_path, &path_json_entry.relative_path, &destination_path)? - }; - - // Compute the final SHA256 if we didnt already or if its not stored in the paths.json entry. - let sha256 = if let Some(sha256) = sha256 { - sha256 - } else if link_method == LinkMethod::Softlink { - // we hash the content of the symlink file. Note that this behavior is different from - // conda or mamba (where the target of the symlink is hashed). However, hashing the target - // of the symlink is more tricky in our case as we link everything in parallel and would have to - // potentially "wait" for dependencies to be available. - // This needs to be taken into account when verifying an installation. - let linked_path = destination_path - .read_link() - .map_err(LinkFileError::FailedToReadSymlink)?; - rattler_digest::compute_bytes_digest::( - linked_path.as_os_str().to_string_lossy().as_bytes(), - ) - } else if let Some(sha256) = path_json_entry.sha256 { - sha256 - } else if path_json_entry.path_type == PathType::HardLink { - rattler_digest::compute_file_digest::(&destination_path) - .map_err(LinkFileError::FailedToComputeSha)? - } else { - // This is either a softlink or a directory. - // Computing the hash for a directory is not possible. - // This hash is `0000...0000` - Sha256Hash::default() - }; - - // Compute the final file size if we didnt already. - let file_size = if let Some(file_size) = file_size { - file_size - } else if let Some(size_in_bytes) = path_json_entry.size_in_bytes { - size_in_bytes - } else { - let metadata = std::fs::symlink_metadata(&destination_path) - .map_err(LinkFileError::FailedToOpenDestinationFile)?; - metadata.len() - }; - - let prefix_placeholder: Option = path_json_entry - .prefix_placeholder - .as_ref() - .map(|p| p.placeholder.clone()); - - Ok(LinkedFile { - clobbered: false, - sha256, - file_size, - relative_path: destination_relative_path, - method: link_method, - prefix_placeholder, - }) -} - /// Installs a single file from a `package_dir` to the the `target_dir`. Replaces any /// `prefix_placeholder` in the file with the `prefix`. /// @@ -650,60 +458,6 @@ fn symlink_to_destination( } } -/// Copy the specified file from the source (or cached) directory. If the file already exists it is -/// removed and the operation is retried. -fn copy_to_destination_from_package_file( - package_path: &Path, - relative_path: &Path, - destination_path: &Path, -) -> Result { - // todo: fix unwraps - // panic!("{:?} {:?} {:?}", package_path, relative_path, destination_path); - // assert file is .conda - let f = File::open(package_path).unwrap(); - let mut archive = stream_conda_content(f).unwrap(); - let mut entry = archive.entries().unwrap().find(|entry| { - entry.as_ref().unwrap().path().unwrap() == relative_path - }).unwrap().unwrap(); - - // panic!("{:?}", entry.path()); - - loop { - // todo: or unpack_in? - match entry.unpack(destination_path) { - Err(e) if e.kind() == ErrorKind::AlreadyExists => { - // If the file already exists, remove it and try again. - std::fs::remove_file(destination_path).map_err(|err| { - LinkFileError::IoError(String::from("removing clobbered file"), err) - })?; - } - Ok(_) => return Ok(LinkMethod::Copy), - Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), - } - // match std::fs::copy(entry, destination_path) { - // Err(e) if e.kind() == ErrorKind::AlreadyExists => { - // If the file already exists, remove it and try again. - // std::fs::remove_file(destination_path).map_err(|err| { - // LinkFileError::IoError(String::from("removing clobbered file"), err) - // })?; - // } - // Ok(_) => return Ok(LinkMethod::Copy), - // Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), - // } - - // match std::fs::copy(package_path, destination_path) { - // Err(e) if e.kind() == ErrorKind::AlreadyExists => { - // // If the file already exists, remove it and try again. - // std::fs::remove_file(destination_path).map_err(|err| { - // LinkFileError::IoError(String::from("removing clobbered file"), err) - // })?; - // } - // Ok(_) => return Ok(LinkMethod::Copy), - // Err(e) => return Err(LinkFileError::FailedToLink(LinkMethod::Copy, e)), - // } - } -} - /// Copy the specified file from the source (or cached) directory. If the file already exists it is /// removed and the operation is retried. fn copy_to_destination( diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index dd3f5d056..3117a27d7 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -49,7 +49,6 @@ pub use installer::{ }; pub use installer::{Installer, InstallerError, Reporter}; use itertools::Itertools; -use link::link_file_from_package_file; pub use link::{link_file, LinkFileError, LinkMethod}; pub use python::PythonInfo; use rattler_conda_types::{ @@ -57,7 +56,7 @@ use rattler_conda_types::{ prefix_record::PathsEntry, Platform, }; -use rattler_package_streaming::seek::read_package_file; +use rattler_package_streaming::{fs::extract, ExtractError}; use simple_spawn_blocking::Cancelled; use tokio::task::JoinError; use tracing::instrument; @@ -104,6 +103,14 @@ pub enum InstallError { #[error("failed to create target directory")] FailedToCreateTargetDirectory(#[source] std::io::Error), + /// Failed to create a temporary directory. + #[error("failed to create temporary directory")] + FailedToCreateTempDirectory(#[source] std::io::Error), + + /// Failed to extract a conda package. + #[error("failed to extract conda package")] + FailedToExtractPackage(#[source] ExtractError), + /// A noarch package could not be installed because no python version was /// specified. #[error("cannot install noarch python package because there is no python version specified")] @@ -246,7 +253,7 @@ pub struct InstallOptions { /// Given a non-extracted conda package (`package_path`), installs its files /// to the `target_dir`. -/// +/// /// Returns a [`PathsEntry`] for every file that was linked into the target /// directory. The entries are ordered in the same order as they appear in the /// `paths.json` file of the package. @@ -256,276 +263,10 @@ pub async fn link_package_from_package_file( driver: &InstallDriver, options: InstallOptions, ) -> Result, InstallError> { - // TODO: incorporate in link_package function - - // Determine the target prefix for linking - let target_prefix = options - .target_prefix - .as_deref() - .unwrap_or(target_dir) - .to_str() - .ok_or(InstallError::TargetPrefixIsNotUtf8)? - .to_owned(); - - // Ensure target directory exists - tokio::fs::create_dir_all(&target_dir) - .await - .map_err(InstallError::FailedToCreateTargetDirectory)?; - - // Reuse or read the `paths.json` and `index.json` files from the package - // directory - let paths_json = read_paths_json_from_package_file(package_path, driver, options.paths_json); - let index_json = read_index_json_from_package_file(package_path, driver, options.index_json); - let (paths_json, index_json) = tokio::try_join!(paths_json, index_json)?; - - // Error out if this is a noarch python package but the python information is - // missing. - if index_json.noarch.is_python() && options.python_info.is_none() { - return Err(InstallError::MissingPythonInfo); - } - - // Parse the `link.json` file and extract entry points from it. - let link_json = if index_json.noarch.is_python() { - read_link_json_from_package_file(package_path, driver, options.link_json.flatten()).await? - } else { - None - }; - - // Determine whether or not we can use symbolic links - let (allow_symbolic_links, allow_hard_links) = (false, false); - let allow_ref_links = false; - - // Determine the platform to use - let platform = options.platform.unwrap_or(Platform::current()); - - // compute all path renames - let mut final_paths = compute_paths(&index_json, &paths_json, options.python_info.as_ref()); - - // register all paths in the install driver path registry - let clobber_paths = Arc::new( - driver - .clobber_registry() - .register_paths(&index_json, &final_paths), - ); - - for (_, computed_path) in final_paths.iter_mut() { - if let Some(clobber_rename) = clobber_paths.get(computed_path) { - *computed_path = clobber_rename.clone(); - } - } - - // Figure out all the directories that we are going to need - let mut directories_to_construct = HashSet::new(); - for (_, computed_path) in final_paths.iter() { - let mut current_path = computed_path.parent(); - while let Some(path) = current_path { - if !path.as_os_str().is_empty() && directories_to_construct.insert(path.to_path_buf()) { - current_path = path.parent(); - } else { - break; - } - } - } - - let directories_target_dir = target_dir.to_path_buf(); - driver - .run_blocking_io_task(move || { - for directory in directories_to_construct.into_iter().sorted() { - let full_path = directories_target_dir.join(directory); - match fs::create_dir(&full_path) { - Ok(_) => (), - Err(e) if e.kind() == ErrorKind::AlreadyExists => (), - Err(e) => return Err(InstallError::FailedToCreateDirectory(full_path, e)), - } - } - Ok(()) - }) - .await?; - - // Wrap the python info in an `Arc` so we can more easily share it with async - // tasks. - let python_info = options.python_info.map(Arc::new); - - // Start linking all package files in parallel - let mut pending_futures = FuturesUnordered::new(); - let mut number_of_paths_entries = 0; - for (entry, computed_path) in final_paths { - let package_path = package_path.to_owned(); - let target_dir = target_dir.to_owned(); - let target_prefix = target_prefix.clone(); - - let clobber_rename = clobber_paths.get(&entry.relative_path).cloned(); - let install_future = async move { - let _permit = driver.acquire_io_permit().await; - - // Spawn a blocking task to link the specific file. We use a blocking task here - // because filesystem access is blocking anyway so its more - // efficient to group them together in a single blocking call. - let cloned_entry = entry.clone(); - let result = match tokio::task::spawn_blocking(move || { - link_file_from_package_file( - &cloned_entry, - computed_path, - &package_path, - &target_dir, - &target_prefix, - allow_symbolic_links && !cloned_entry.no_link, - allow_hard_links && !cloned_entry.no_link, - allow_ref_links && !cloned_entry.no_link, - platform, - options.apple_codesign_behavior, - ) - }) - .await - .map_err(JoinError::try_into_panic) - { - Ok(Ok(linked_file)) => linked_file, - Ok(Err(e)) => { - return Err(InstallError::FailedToLink(entry.relative_path.clone(), e)) - } - Err(Ok(payload)) => std::panic::resume_unwind(payload), - Err(Err(_err)) => return Err(InstallError::Cancelled), - }; + let temp_dir = tempfile::tempdir().map_err(InstallError::FailedToCreateTempDirectory)?; - // Construct a `PathsEntry` from the result of the linking operation - let paths_entry = PathsEntry { - relative_path: result.relative_path, - original_path: if clobber_rename.is_some() { - Some(entry.relative_path) - } else { - None - }, - path_type: entry.path_type.into(), - no_link: entry.no_link, - sha256: entry.sha256, - sha256_in_prefix: Some(result.sha256), - size_in_bytes: Some(result.file_size), - file_mode: match result.method { - LinkMethod::Patched(file_mode) => Some(file_mode), - _ => None, - }, - prefix_placeholder: entry - .prefix_placeholder - .as_ref() - .map(|p| p.placeholder.clone()), - }; - - Ok(vec![(number_of_paths_entries, paths_entry)]) - }; - - pending_futures.push(install_future.boxed()); - number_of_paths_entries += 1; - } - - // If this package is a noarch python package we also have to create entry - // points. - // - // Be careful with the fact that this code is currently running in parallel with - // the linking of individual files. - if let Some(link_json) = link_json { - // Parse the `link.json` file and extract entry points from it. - let entry_points = match link_json.noarch { - NoArchLinks::Python(entry_points) => entry_points.entry_points, - NoArchLinks::Generic => { - unreachable!("we only use link.json for noarch: python packages") - } - }; - - // Get python info - let python_info = python_info - .clone() - .expect("should be safe because its checked above that this contains a value"); - - // Create entry points for each listed item. This is different between Windows - // and unix because on Windows, two PathEntry's are created whereas on - // Linux only one is created. - for entry_point in entry_points { - let python_info = python_info.clone(); - let target_dir = target_dir.to_owned(); - let target_prefix = target_prefix.clone(); - - let entry_point_fut = async move { - // Acquire an IO permit - let _permit = driver.acquire_io_permit().await; - - let entries = if platform.is_windows() { - match create_windows_python_entry_point( - &target_dir, - &target_prefix, - &entry_point, - &python_info, - &platform, - ) { - Ok([a, b]) => vec![ - (number_of_paths_entries, a), - (number_of_paths_entries + 1, b), - ], - Err(e) => return Err(InstallError::FailedToCreatePythonEntryPoint(e)), - } - } else { - match create_unix_python_entry_point( - &target_dir, - &target_prefix, - &entry_point, - &python_info, - ) { - Ok(a) => vec![(number_of_paths_entries, a)], - Err(e) => return Err(InstallError::FailedToCreatePythonEntryPoint(e)), - } - }; - - Ok(entries) - }; - - pending_futures.push(entry_point_fut.boxed()); - number_of_paths_entries += if platform.is_windows() { 2 } else { 1 }; - } - } - - // Await the result of all the background tasks. The background tasks are - // scheduled in order, however, they can complete in any order. This means - // we have to reorder them back into their original order. This is achieved - // by waiting to add finished results to the result Vec, if the result - // before it has not yet finished. To that end we use a `BinaryHeap` as a - // priority queue which will buffer up finished results that finished before - // their predecessor. - // - // What makes this loop special is that it also aborts if any of the returned - // results indicate a failure. - let mut paths = Vec::with_capacity(number_of_paths_entries); - let mut out_of_order_queue = BinaryHeap::>::with_capacity(100); - while let Some(link_result) = pending_futures.next().await { - for (index, data) in link_result? { - if index == paths.len() { - // If this is the next element expected in the sorted list, add it immediately. - // This basically means the future finished in order. - paths.push(data); - - // By adding a finished future we have to check if there might also be another - // future that finished earlier and should also now be added to - // the result Vec. - while let Some(next_output) = out_of_order_queue.peek_mut() { - if next_output.index == paths.len() { - paths.push(PeekMut::pop(next_output).data); - } else { - break; - } - } - } else { - // Otherwise add it to the out-of-order queue. This means that we still have to - // wait for another element before we can add the result to the - // ordered list. - out_of_order_queue.push(OrderWrapper { index, data }); - } - } - } - debug_assert_eq!( - paths.len(), - paths.capacity(), - "some futures where not added to the result" - ); - - Ok(paths) + extract(package_path, temp_dir.path()).map_err(InstallError::FailedToExtractPackage)?; + link_package(temp_dir.path(), target_dir, driver, options).await } /// Given an extracted package archive (`package_dir`), installs its files to @@ -843,27 +584,6 @@ fn compute_paths( final_paths } -/// TODO docs -async fn read_paths_json_from_package_file( - package_path: &Path, - driver: &InstallDriver, - paths_json: Option, -) -> Result { - if let Some(paths_json) = paths_json { - Ok(paths_json) - } else { - // TODO: unwrap - Ok(read_package_file::(package_path).unwrap())//.map_err(InstallError::FailedToReadPathsJson) - // let package_path = package_path.to_owned(); - // driver - // .run_blocking_io_task(move || { - // PathsJson::from_package_directory_with_deprecated_fallback(&package_path) - // .map_err(InstallError::FailedToReadPathsJson) - // }) - // .await - } -} - /// A helper function that reads the `paths.json` file from a package unless it /// has already been provided, in which case it is returned immediately. async fn read_paths_json( @@ -884,26 +604,6 @@ async fn read_paths_json( } } -/// todo docs -async fn read_index_json_from_package_file( - package_path: &Path, - driver: &InstallDriver, - index_json: Option, -) -> Result { - // todo unwrap - Ok(read_package_file::(package_path).unwrap()) -} - -/// todo docs -async fn read_link_json_from_package_file( - package_path: &Path, - driver: &InstallDriver, - index_json: Option, -) -> Result, InstallError> { - // todo unwrap - Ok(Some(read_package_file::(package_path).unwrap())) -} - /// A helper function that reads the `index.json` file from a package unless it /// has already been provided, in which case it is returned immediately. async fn read_index_json( @@ -1049,7 +749,9 @@ mod test { use crate::{ get_test_data_dir, - install::{link_package, link_package_from_package_file, InstallDriver, InstallOptions, PythonInfo}, + install::{ + link_package, link_package_from_package_file, InstallDriver, InstallOptions, PythonInfo, + }, package_cache::PackageCache, }; @@ -1204,19 +906,24 @@ mod test { insta::assert_yaml_snapshot!(paths); } + #[rstest::rstest] + #[case( + "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", + "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" + )] + #[case( + "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", + "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" + )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_package_file() { + async fn test_link_package_from_package_file(#[case] package_url: &str, #[case] sha256: &str) { let environment_dir = tempfile::TempDir::new().unwrap(); - let package_path = tools::download_and_cache_file_async( - "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda" - .parse() - .unwrap(), - "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd", - ) - .await - .unwrap(); + let package_path = + tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) + .await + .unwrap(); let install_driver = InstallDriver::default(); diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap new file mode 100644 index 000000000..8f99b1709 --- /dev/null +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap @@ -0,0 +1,76 @@ +--- +source: crates/rattler/src/install/mod.rs +assertion_line: 936 +expression: paths +snapshot_kind: text +--- +- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER + path_type: hardlink + sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + size_in_bytes: 5 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA + path_type: hardlink + sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + size_in_bytes: 77203 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD + path_type: hardlink + sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + size_in_bytes: 896 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL + path_type: hardlink + sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + size_in_bytes: 94 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json + path_type: hardlink + sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + size_in_bytes: 119 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE + path_type: hardlink + sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + size_in_bytes: 30157 +- _path: Lib/site-packages/ruff/__init__.py + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff/__main__.py + path_type: hardlink + sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + size_in_bytes: 193 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc + path_type: hardlink + sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + size_in_bytes: 160 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc + path_type: hardlink + sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + size_in_bytes: 143 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc + path_type: hardlink + sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + size_in_bytes: 383 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc + path_type: hardlink + sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + size_in_bytes: 629 +- _path: Scripts/ruff.exe + path_type: hardlink + sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + size_in_bytes: 6896640 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap index e4ae8dc9b..cc11cbf95 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap @@ -1,76 +1,126 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 1233 +assertion_line: 936 expression: paths snapshot_kind: text --- -- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER - path_type: hardlink - sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - size_in_bytes: 5 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA - path_type: hardlink - sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - size_in_bytes: 77203 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD - path_type: hardlink - sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - size_in_bytes: 896 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL - path_type: hardlink - sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - size_in_bytes: 94 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json - path_type: hardlink - sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - size_in_bytes: 119 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE - path_type: hardlink - sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - size_in_bytes: 30157 -- _path: Lib/site-packages/ruff/__init__.py - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff/__main__.py - path_type: hardlink - sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - size_in_bytes: 193 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc - path_type: hardlink - sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - size_in_bytes: 160 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc - path_type: hardlink - sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - size_in_bytes: 143 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc - path_type: hardlink - sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - size_in_bytes: 383 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc - path_type: hardlink - sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - size_in_bytes: 629 -- _path: Scripts/ruff.exe - path_type: hardlink - sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - size_in_bytes: 6896640 +- _path: bin/bunzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcat + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcmp + path_type: softlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 + size_in_bytes: 2140 +- _path: bin/bzdiff + path_type: hardlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + size_in_bytes: 2140 +- _path: bin/bzegrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzfgrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzgrep + path_type: hardlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + size_in_bytes: 2054 +- _path: bin/bzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzip2recover + path_type: hardlink + sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + size_in_bytes: 35896 +- _path: bin/bzless + path_type: softlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 + size_in_bytes: 1259 +- _path: bin/bzmore + path_type: hardlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + size_in_bytes: 1259 +- _path: include/bzlib.h + path_type: hardlink + sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + size_in_bytes: 6240 +- _path: lib/libbz2.a + path_type: hardlink + sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + size_in_bytes: 371082 +- _path: lib/libbz2.so + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0 + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0.8 + path_type: hardlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + size_in_bytes: 286272 +- _path: man/man1/bzcmp.1 + path_type: hardlink + sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + size_in_bytes: 18 +- _path: man/man1/bzdiff.1 + path_type: hardlink + sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + size_in_bytes: 897 +- _path: man/man1/bzegrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzfgrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzgrep.1 + path_type: hardlink + sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + size_in_bytes: 1297 +- _path: man/man1/bzip2.1 + path_type: hardlink + sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + size_in_bytes: 16266 +- _path: man/man1/bzless.1 + path_type: hardlink + sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + size_in_bytes: 18 +- _path: man/man1/bzmore.1 + path_type: hardlink + sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + size_in_bytes: 4310 From 831d9c463ec67cccd6acdc6484c7bf6be4da74e8 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Wed, 13 Nov 2024 18:03:03 +0100 Subject: [PATCH 03/14] fix --- crates/rattler/src/install/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 3117a27d7..33470ddc0 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -257,7 +257,7 @@ pub struct InstallOptions { /// Returns a [`PathsEntry`] for every file that was linked into the target /// directory. The entries are ordered in the same order as they appear in the /// `paths.json` file of the package. -pub async fn link_package_from_package_file( +pub async fn link_package_from_package( package_path: &Path, target_dir: &Path, driver: &InstallDriver, @@ -750,7 +750,7 @@ mod test { use crate::{ get_test_data_dir, install::{ - link_package, link_package_from_package_file, InstallDriver, InstallOptions, PythonInfo, + link_package, link_package_from_package, InstallDriver, InstallOptions, PythonInfo, }, package_cache::PackageCache, }; @@ -928,7 +928,7 @@ mod test { let install_driver = InstallDriver::default(); // Link the package - let paths = link_package_from_package_file( + let paths = link_package_from_package( &package_path, environment_dir.path(), &install_driver, From bd857c55510ef06c532008a8e822ff80b9dae566 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Wed, 13 Nov 2024 18:04:09 +0100 Subject: [PATCH 04/14] test name --- crates/rattler/src/install/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 33470ddc0..7ff0f8c09 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -917,7 +917,7 @@ mod test { )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_package_file(#[case] package_url: &str, #[case] sha256: &str) { + async fn test_link_package_from_package(#[case] package_url: &str, #[case] sha256: &str) { let environment_dir = tempfile::TempDir::new().unwrap(); let package_path = From 768afa8b3071cac973b25e9f5143fffc4be2c196 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Wed, 13 Nov 2024 18:18:51 +0100 Subject: [PATCH 05/14] rename --- crates/rattler/src/install/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 7ff0f8c09..9f6bf0bb8 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -257,7 +257,7 @@ pub struct InstallOptions { /// Returns a [`PathsEntry`] for every file that was linked into the target /// directory. The entries are ordered in the same order as they appear in the /// `paths.json` file of the package. -pub async fn link_package_from_package( +pub async fn link_package_from_archive( package_path: &Path, target_dir: &Path, driver: &InstallDriver, @@ -750,7 +750,7 @@ mod test { use crate::{ get_test_data_dir, install::{ - link_package, link_package_from_package, InstallDriver, InstallOptions, PythonInfo, + link_package, link_package_from_archive, InstallDriver, InstallOptions, PythonInfo, }, package_cache::PackageCache, }; @@ -917,7 +917,7 @@ mod test { )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_package(#[case] package_url: &str, #[case] sha256: &str) { + async fn test_link_package_from_archive(#[case] package_url: &str, #[case] sha256: &str) { let environment_dir = tempfile::TempDir::new().unwrap(); let package_path = @@ -928,7 +928,7 @@ mod test { let install_driver = InstallDriver::default(); // Link the package - let paths = link_package_from_package( + let paths = link_package_from_archive( &package_path, environment_dir.path(), &install_driver, From bb5aaadac99855c6f58bed893f0590a69168f4e8 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 14 Nov 2024 10:04:38 +0100 Subject: [PATCH 06/14] rename --- ...=> rattler__install__test__link_package_from_archive-2.snap} | 2 +- ...p => rattler__install__test__link_package_from_archive.snap} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename crates/rattler/src/install/snapshots/{rattler__install__test__link_package_from_package_file-2.snap => rattler__install__test__link_package_from_archive-2.snap} (99%) rename crates/rattler/src/install/snapshots/{rattler__install__test__link_package_from_package_file.snap => rattler__install__test__link_package_from_archive.snap} (99%) diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap similarity index 99% rename from crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap rename to crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap index 8f99b1709..889903e4a 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file-2.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap @@ -1,6 +1,6 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 936 +assertion_line: 940 expression: paths snapshot_kind: text --- diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap similarity index 99% rename from crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap rename to crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap index cc11cbf95..51f563de2 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_package_file.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap @@ -1,6 +1,6 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 936 +assertion_line: 940 expression: paths snapshot_kind: text --- From f119c98a2badf7da8a1074d0e2f92ad8b1a05391 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 14 Nov 2024 10:16:50 +0100 Subject: [PATCH 07/14] fix --- ...tall__test__link_package_from_archive.snap | 190 +++++++----------- 1 file changed, 70 insertions(+), 120 deletions(-) diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap index 51f563de2..889903e4a 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap @@ -4,123 +4,73 @@ assertion_line: 940 expression: paths snapshot_kind: text --- -- _path: bin/bunzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcat - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcmp - path_type: softlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 - size_in_bytes: 2140 -- _path: bin/bzdiff - path_type: hardlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - size_in_bytes: 2140 -- _path: bin/bzegrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzfgrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzgrep - path_type: hardlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - size_in_bytes: 2054 -- _path: bin/bzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzip2recover - path_type: hardlink - sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - size_in_bytes: 35896 -- _path: bin/bzless - path_type: softlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 - size_in_bytes: 1259 -- _path: bin/bzmore - path_type: hardlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - size_in_bytes: 1259 -- _path: include/bzlib.h - path_type: hardlink - sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - size_in_bytes: 6240 -- _path: lib/libbz2.a - path_type: hardlink - sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - size_in_bytes: 371082 -- _path: lib/libbz2.so - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0 - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0.8 - path_type: hardlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - size_in_bytes: 286272 -- _path: man/man1/bzcmp.1 - path_type: hardlink - sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - size_in_bytes: 18 -- _path: man/man1/bzdiff.1 - path_type: hardlink - sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - size_in_bytes: 897 -- _path: man/man1/bzegrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzfgrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzgrep.1 - path_type: hardlink - sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - size_in_bytes: 1297 -- _path: man/man1/bzip2.1 - path_type: hardlink - sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - size_in_bytes: 16266 -- _path: man/man1/bzless.1 - path_type: hardlink - sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - size_in_bytes: 18 -- _path: man/man1/bzmore.1 - path_type: hardlink - sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - size_in_bytes: 4310 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER + path_type: hardlink + sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + size_in_bytes: 5 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA + path_type: hardlink + sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + size_in_bytes: 77203 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD + path_type: hardlink + sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + size_in_bytes: 896 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL + path_type: hardlink + sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + size_in_bytes: 94 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json + path_type: hardlink + sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + size_in_bytes: 119 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE + path_type: hardlink + sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + size_in_bytes: 30157 +- _path: Lib/site-packages/ruff/__init__.py + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff/__main__.py + path_type: hardlink + sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + size_in_bytes: 193 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc + path_type: hardlink + sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + size_in_bytes: 160 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc + path_type: hardlink + sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + size_in_bytes: 143 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc + path_type: hardlink + sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + size_in_bytes: 383 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc + path_type: hardlink + sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + size_in_bytes: 629 +- _path: Scripts/ruff.exe + path_type: hardlink + sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + size_in_bytes: 6896640 From 4ef05c1fa7e67ca2de8b171d4719d0665cb3be11 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Thu, 14 Nov 2024 10:48:35 +0100 Subject: [PATCH 08/14] Make deterministic --- crates/rattler/src/install/mod.rs | 56 ++--- ...ll__test__link_package_from_archive-2.snap | 192 +++++++++++------- ...tall__test__link_package_from_archive.snap | 2 +- 3 files changed, 151 insertions(+), 99 deletions(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 9f6bf0bb8..c53845bbe 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -906,37 +906,39 @@ mod test { insta::assert_yaml_snapshot!(paths); } - #[rstest::rstest] - #[case( - "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", - "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" - )] - #[case( - "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", - "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" - )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_archive(#[case] package_url: &str, #[case] sha256: &str) { - let environment_dir = tempfile::TempDir::new().unwrap(); + async fn test_link_package_from_archive() { + let packages = vec![( + "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", + "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" + ), + ( + "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", + "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" + )]; + + for (package_url, sha256) in packages { + let environment_dir = tempfile::TempDir::new().unwrap(); + + let package_path = + tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) + .await + .unwrap(); - let package_path = - tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) - .await - .unwrap(); + let install_driver = InstallDriver::default(); - let install_driver = InstallDriver::default(); - - // Link the package - let paths = link_package_from_archive( - &package_path, - environment_dir.path(), - &install_driver, - InstallOptions::default(), - ) - .await - .unwrap(); + // Link the package + let paths = link_package_from_archive( + &package_path, + environment_dir.path(), + &install_driver, + InstallOptions::default(), + ) + .await + .unwrap(); - insta::assert_yaml_snapshot!(paths); + insta::assert_yaml_snapshot!(paths); + } } } diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap index 889903e4a..3cc6c2b6c 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap @@ -1,76 +1,126 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 940 +assertion_line: 941 expression: paths snapshot_kind: text --- -- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER - path_type: hardlink - sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - size_in_bytes: 5 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA - path_type: hardlink - sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - size_in_bytes: 77203 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD - path_type: hardlink - sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - size_in_bytes: 896 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL - path_type: hardlink - sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - size_in_bytes: 94 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json - path_type: hardlink - sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - size_in_bytes: 119 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE - path_type: hardlink - sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - size_in_bytes: 30157 -- _path: Lib/site-packages/ruff/__init__.py - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff/__main__.py - path_type: hardlink - sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - size_in_bytes: 193 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc - path_type: hardlink - sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - size_in_bytes: 160 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc - path_type: hardlink - sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - size_in_bytes: 143 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc - path_type: hardlink - sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - size_in_bytes: 383 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc - path_type: hardlink - sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - size_in_bytes: 629 -- _path: Scripts/ruff.exe - path_type: hardlink - sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - size_in_bytes: 6896640 +- _path: bin/bunzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcat + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcmp + path_type: softlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 + size_in_bytes: 2140 +- _path: bin/bzdiff + path_type: hardlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + size_in_bytes: 2140 +- _path: bin/bzegrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzfgrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzgrep + path_type: hardlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + size_in_bytes: 2054 +- _path: bin/bzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzip2recover + path_type: hardlink + sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + size_in_bytes: 35896 +- _path: bin/bzless + path_type: softlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 + size_in_bytes: 1259 +- _path: bin/bzmore + path_type: hardlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + size_in_bytes: 1259 +- _path: include/bzlib.h + path_type: hardlink + sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + size_in_bytes: 6240 +- _path: lib/libbz2.a + path_type: hardlink + sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + size_in_bytes: 371082 +- _path: lib/libbz2.so + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0 + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0.8 + path_type: hardlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + size_in_bytes: 286272 +- _path: man/man1/bzcmp.1 + path_type: hardlink + sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + size_in_bytes: 18 +- _path: man/man1/bzdiff.1 + path_type: hardlink + sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + size_in_bytes: 897 +- _path: man/man1/bzegrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzfgrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzgrep.1 + path_type: hardlink + sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + size_in_bytes: 1297 +- _path: man/man1/bzip2.1 + path_type: hardlink + sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + size_in_bytes: 16266 +- _path: man/man1/bzless.1 + path_type: hardlink + sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + size_in_bytes: 18 +- _path: man/man1/bzmore.1 + path_type: hardlink + sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + size_in_bytes: 4310 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap index 889903e4a..8c21aa9ee 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap @@ -1,6 +1,6 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 940 +assertion_line: 941 expression: paths snapshot_kind: text --- From 8fa1babb72ef2929e211e7dd9304c16bec479e0f Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 18 Nov 2024 18:03:34 +0100 Subject: [PATCH 09/14] Revert "Make deterministic" This reverts commit 4ef05c1fa7e67ca2de8b171d4719d0665cb3be11. --- crates/rattler/src/install/mod.rs | 56 +++-- ...ll__test__link_package_from_archive-2.snap | 192 +++++++----------- ...tall__test__link_package_from_archive.snap | 2 +- 3 files changed, 99 insertions(+), 151 deletions(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index c53845bbe..9f6bf0bb8 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -906,39 +906,37 @@ mod test { insta::assert_yaml_snapshot!(paths); } + #[rstest::rstest] + #[case( + "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", + "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" + )] + #[case( + "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", + "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" + )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_archive() { - let packages = vec![( - "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", - "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" - ), - ( - "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", - "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" - )]; - - for (package_url, sha256) in packages { - let environment_dir = tempfile::TempDir::new().unwrap(); - - let package_path = - tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) - .await - .unwrap(); + async fn test_link_package_from_archive(#[case] package_url: &str, #[case] sha256: &str) { + let environment_dir = tempfile::TempDir::new().unwrap(); - let install_driver = InstallDriver::default(); + let package_path = + tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) + .await + .unwrap(); - // Link the package - let paths = link_package_from_archive( - &package_path, - environment_dir.path(), - &install_driver, - InstallOptions::default(), - ) - .await - .unwrap(); + let install_driver = InstallDriver::default(); - insta::assert_yaml_snapshot!(paths); - } + // Link the package + let paths = link_package_from_archive( + &package_path, + environment_dir.path(), + &install_driver, + InstallOptions::default(), + ) + .await + .unwrap(); + + insta::assert_yaml_snapshot!(paths); } } diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap index 3cc6c2b6c..889903e4a 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap @@ -1,126 +1,76 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 941 +assertion_line: 940 expression: paths snapshot_kind: text --- -- _path: bin/bunzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcat - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcmp - path_type: softlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 - size_in_bytes: 2140 -- _path: bin/bzdiff - path_type: hardlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - size_in_bytes: 2140 -- _path: bin/bzegrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzfgrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzgrep - path_type: hardlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - size_in_bytes: 2054 -- _path: bin/bzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzip2recover - path_type: hardlink - sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - size_in_bytes: 35896 -- _path: bin/bzless - path_type: softlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 - size_in_bytes: 1259 -- _path: bin/bzmore - path_type: hardlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - size_in_bytes: 1259 -- _path: include/bzlib.h - path_type: hardlink - sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - size_in_bytes: 6240 -- _path: lib/libbz2.a - path_type: hardlink - sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - size_in_bytes: 371082 -- _path: lib/libbz2.so - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0 - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0.8 - path_type: hardlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - size_in_bytes: 286272 -- _path: man/man1/bzcmp.1 - path_type: hardlink - sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - size_in_bytes: 18 -- _path: man/man1/bzdiff.1 - path_type: hardlink - sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - size_in_bytes: 897 -- _path: man/man1/bzegrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzfgrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzgrep.1 - path_type: hardlink - sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - size_in_bytes: 1297 -- _path: man/man1/bzip2.1 - path_type: hardlink - sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - size_in_bytes: 16266 -- _path: man/man1/bzless.1 - path_type: hardlink - sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - size_in_bytes: 18 -- _path: man/man1/bzmore.1 - path_type: hardlink - sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - size_in_bytes: 4310 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER + path_type: hardlink + sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 + size_in_bytes: 5 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA + path_type: hardlink + sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 + size_in_bytes: 77203 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD + path_type: hardlink + sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 + size_in_bytes: 896 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL + path_type: hardlink + sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 + size_in_bytes: 94 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json + path_type: hardlink + sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a + size_in_bytes: 119 +- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE + path_type: hardlink + sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e + size_in_bytes: 30157 +- _path: Lib/site-packages/ruff/__init__.py + path_type: hardlink + sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + size_in_bytes: 0 +- _path: Lib/site-packages/ruff/__main__.py + path_type: hardlink + sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 + size_in_bytes: 193 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc + path_type: hardlink + sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e + size_in_bytes: 160 +- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc + path_type: hardlink + sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 + size_in_bytes: 143 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc + path_type: hardlink + sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd + size_in_bytes: 383 +- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc + path_type: hardlink + sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 + size_in_bytes: 629 +- _path: Scripts/ruff.exe + path_type: hardlink + sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 + size_in_bytes: 6896640 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap index 8c21aa9ee..889903e4a 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap @@ -1,6 +1,6 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 941 +assertion_line: 940 expression: paths snapshot_kind: text --- From 69ce199117d7b3a8228d0077389e3ac02265a4ea Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Mon, 18 Nov 2024 18:06:20 +0100 Subject: [PATCH 10/14] name snapshots --- crates/rattler/src/install/mod.rs | 6 +- ...test__link_package_from_archive-bzip2.snap | 126 ++++++++++++++++++ ...test__link_package_from_archive-ruff.snap} | 2 +- ...tall__test__link_package_from_archive.snap | 76 ----------- 4 files changed, 131 insertions(+), 79 deletions(-) create mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap rename crates/rattler/src/install/snapshots/{rattler__install__test__link_package_from_archive-2.snap => rattler__install__test__link_package_from_archive-ruff.snap} (99%) delete mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 9f6bf0bb8..674109ed7 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -908,16 +908,18 @@ mod test { #[rstest::rstest] #[case( + "ruff", "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" )] #[case( + "bzip2", "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_archive(#[case] package_url: &str, #[case] sha256: &str) { + async fn test_link_package_from_archive(#[case] package: &str, #[case] package_url: &str, #[case] sha256: &str) { let environment_dir = tempfile::TempDir::new().unwrap(); let package_path = @@ -937,6 +939,6 @@ mod test { .await .unwrap(); - insta::assert_yaml_snapshot!(paths); + insta::assert_yaml_snapshot!(format!("link_package_from_archive-{}", package), paths); } } diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap new file mode 100644 index 000000000..dbf0b33f4 --- /dev/null +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap @@ -0,0 +1,126 @@ +--- +source: crates/rattler/src/install/mod.rs +assertion_line: 942 +expression: paths +snapshot_kind: text +--- +- _path: bin/bunzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcat + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzcmp + path_type: softlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 + size_in_bytes: 2140 +- _path: bin/bzdiff + path_type: hardlink + sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 + size_in_bytes: 2140 +- _path: bin/bzegrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzfgrep + path_type: softlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 + size_in_bytes: 2054 +- _path: bin/bzgrep + path_type: hardlink + sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 + size_in_bytes: 2054 +- _path: bin/bzip2 + path_type: hardlink + sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 + size_in_bytes: 366552 +- _path: bin/bzip2recover + path_type: hardlink + sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b + size_in_bytes: 35896 +- _path: bin/bzless + path_type: softlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 + size_in_bytes: 1259 +- _path: bin/bzmore + path_type: hardlink + sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d + size_in_bytes: 1259 +- _path: include/bzlib.h + path_type: hardlink + sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d + size_in_bytes: 6240 +- _path: lib/libbz2.a + path_type: hardlink + sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf + size_in_bytes: 371082 +- _path: lib/libbz2.so + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0 + path_type: softlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 + size_in_bytes: 286272 +- _path: lib/libbz2.so.1.0.8 + path_type: hardlink + sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 + size_in_bytes: 286272 +- _path: man/man1/bzcmp.1 + path_type: hardlink + sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 + size_in_bytes: 18 +- _path: man/man1/bzdiff.1 + path_type: hardlink + sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf + size_in_bytes: 897 +- _path: man/man1/bzegrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzfgrep.1 + path_type: hardlink + sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 + size_in_bytes: 18 +- _path: man/man1/bzgrep.1 + path_type: hardlink + sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df + size_in_bytes: 1297 +- _path: man/man1/bzip2.1 + path_type: hardlink + sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d + size_in_bytes: 16266 +- _path: man/man1/bzless.1 + path_type: hardlink + sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c + size_in_bytes: 18 +- _path: man/man1/bzmore.1 + path_type: hardlink + sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 + size_in_bytes: 4310 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap similarity index 99% rename from crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap rename to crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap index 889903e4a..342b3858c 100644 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-2.snap +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap @@ -1,6 +1,6 @@ --- source: crates/rattler/src/install/mod.rs -assertion_line: 940 +assertion_line: 942 expression: paths snapshot_kind: text --- diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap deleted file mode 100644 index 889903e4a..000000000 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/rattler/src/install/mod.rs -assertion_line: 940 -expression: paths -snapshot_kind: text ---- -- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER - path_type: hardlink - sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - size_in_bytes: 5 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA - path_type: hardlink - sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - size_in_bytes: 77203 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD - path_type: hardlink - sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - size_in_bytes: 896 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL - path_type: hardlink - sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - size_in_bytes: 94 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json - path_type: hardlink - sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - size_in_bytes: 119 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE - path_type: hardlink - sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - size_in_bytes: 30157 -- _path: Lib/site-packages/ruff/__init__.py - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff/__main__.py - path_type: hardlink - sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - size_in_bytes: 193 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc - path_type: hardlink - sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - size_in_bytes: 160 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc - path_type: hardlink - sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - size_in_bytes: 143 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc - path_type: hardlink - sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - size_in_bytes: 383 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc - path_type: hardlink - sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - size_in_bytes: 629 -- _path: Scripts/ruff.exe - path_type: hardlink - sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - size_in_bytes: 6896640 From 48d9c204e093e896919120c5a229fd3385688318 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 22 Nov 2024 10:27:40 +0100 Subject: [PATCH 11/14] Use local conda packages --- crates/rattler/src/install/mod.rs | 17 +-- ...test__link_package_from_archive-bzip2.snap | 126 ------------------ ...nk_package_from_archive-clobber-conda.snap | 11 ++ ..._package_from_archive-clobber-tar-bz2.snap | 16 +++ ..._test__link_package_from_archive-ruff.snap | 76 ----------- 5 files changed, 33 insertions(+), 213 deletions(-) delete mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap create mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-conda.snap create mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-tar-bz2.snap delete mode 100644 crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 674109ed7..b2ea43e81 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -908,24 +908,19 @@ mod test { #[rstest::rstest] #[case( - "ruff", - "https://conda.anaconda.org/conda-forge/win-64/ruff-0.0.171-py310h298983d_0.conda", - "25c755b97189ee066576b4ae3999d5e7ff4406d236b984742194e63941838dcd" + "clobber-tar-bz2", + "clobber/clobber-1-0.1.0-h4616a5c_0.tar.bz2", )] #[case( - "bzip2", - "https://conda.anaconda.org/conda-forge/linux-aarch64/bzip2-1.0.8-hf897c2e_4.tar.bz2", - "3aeb6ab92aa0351722497b2d2a735dc20921cf6c60d9196c04b7a2b9ece198d2" + "clobber-conda", + "clobber/clobber-python-0.1.0-cpython.conda", )] #[tracing_test::traced_test] #[tokio::test] - async fn test_link_package_from_archive(#[case] package: &str, #[case] package_url: &str, #[case] sha256: &str) { + async fn test_link_package_from_archive(#[case] package: &str, #[case] package_path: &str) { let environment_dir = tempfile::TempDir::new().unwrap(); - let package_path = - tools::download_and_cache_file_async(package_url.parse().unwrap(), sha256) - .await - .unwrap(); + let package_path = get_test_data_dir().join(package_path); let install_driver = InstallDriver::default(); diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap deleted file mode 100644 index dbf0b33f4..000000000 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-bzip2.snap +++ /dev/null @@ -1,126 +0,0 @@ ---- -source: crates/rattler/src/install/mod.rs -assertion_line: 942 -expression: paths -snapshot_kind: text ---- -- _path: bin/bunzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcat - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzcmp - path_type: softlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: d5e2951edcc0388feda0726ee69b5ac079bf91e4bc79ce095b34a56b38db29b7 - size_in_bytes: 2140 -- _path: bin/bzdiff - path_type: hardlink - sha256: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - sha256_in_prefix: 1c1f96193cdf14b85ea65f140a7557a07ece8783a53ec5ba6b5c30644a9d3012 - size_in_bytes: 2140 -- _path: bin/bzegrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzfgrep - path_type: softlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: aa3149e6182875b6fc8b393c9b556fa49427b8732e87c5def2e109904143caa3 - size_in_bytes: 2054 -- _path: bin/bzgrep - path_type: hardlink - sha256: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - sha256_in_prefix: a8e368a31766c7862b8d0feeffe274c3bb43b969e3ccb4f9e77d13bfa447a5c9 - size_in_bytes: 2054 -- _path: bin/bzip2 - path_type: hardlink - sha256: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - sha256_in_prefix: 04f60342b7332b849c3d0e3896322c3b92d8bcfc822c3be0ffd80332b3c223d4 - size_in_bytes: 366552 -- _path: bin/bzip2recover - path_type: hardlink - sha256: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - sha256_in_prefix: 0eacb81fcff1adb72a67efa1f01074c3119ff46709187eada93560533412b38b - size_in_bytes: 35896 -- _path: bin/bzless - path_type: softlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 97fc73f3676c65ae05a49cad2afb3126a00baf9dbf2613996e3b95eac6364c32 - size_in_bytes: 1259 -- _path: bin/bzmore - path_type: hardlink - sha256: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - sha256_in_prefix: 836536d4c7469788c730355d59f8ae8d16ba07cb0754174878d99ed90f04448d - size_in_bytes: 1259 -- _path: include/bzlib.h - path_type: hardlink - sha256: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - sha256_in_prefix: 6ac62e811669598ee30c9e1c379b9e627f6ff17a5a3dc1e0b4fa8b8ea75e580d - size_in_bytes: 6240 -- _path: lib/libbz2.a - path_type: hardlink - sha256: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - sha256_in_prefix: ece8562c4d98e21896056c3f195f0f1b0afed89188fc0e17a8ca53664c28d5bf - size_in_bytes: 371082 -- _path: lib/libbz2.so - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0 - path_type: softlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: 7136a6a39c8e423501e3cefc44a552170b1e996ffd43185357640572e3d38394 - size_in_bytes: 286272 -- _path: lib/libbz2.so.1.0.8 - path_type: hardlink - sha256: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - sha256_in_prefix: d24341372acf8be384d59dedca008fa3052d7d2deab7f8e79410f73383d15b28 - size_in_bytes: 286272 -- _path: man/man1/bzcmp.1 - path_type: hardlink - sha256: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - sha256_in_prefix: 172cde42c47a6d50c244e39d993097dcd3882427d57303078643849cf10a81c4 - size_in_bytes: 18 -- _path: man/man1/bzdiff.1 - path_type: hardlink - sha256: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - sha256_in_prefix: 32d1a7cd115430398e58537532584ef2ab76343c9f094dcd1253d9c4c0f705bf - size_in_bytes: 897 -- _path: man/man1/bzegrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzfgrep.1 - path_type: hardlink - sha256: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - sha256_in_prefix: cf1c98d3fa055506c8af2f8bba4da9c17d367c6409c6ad83a2bc67ccb6630182 - size_in_bytes: 18 -- _path: man/man1/bzgrep.1 - path_type: hardlink - sha256: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - sha256_in_prefix: 924aa4a7c7c1467400181e4c0ee1b527db142b6399a717171f2351b72b5899df - size_in_bytes: 1297 -- _path: man/man1/bzip2.1 - path_type: hardlink - sha256: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - sha256_in_prefix: 27b984bb2e8bbee2651d11cda87449cfc4138d2e479b9eaa77b8f60fa5d0bf5d - size_in_bytes: 16266 -- _path: man/man1/bzless.1 - path_type: hardlink - sha256: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - sha256_in_prefix: 216898f9b8acf61eeb471ecf23e47c1452dfd648f7f38d7d3bf48627072dc52c - size_in_bytes: 18 -- _path: man/man1/bzmore.1 - path_type: hardlink - sha256: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - sha256_in_prefix: ccfcf3f995e11adae3035e287252091bb72d165da21e0c385a4965d17c9051c7 - size_in_bytes: 4310 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-conda.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-conda.snap new file mode 100644 index 000000000..52b542814 --- /dev/null +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-conda.snap @@ -0,0 +1,11 @@ +--- +source: crates/rattler/src/install/mod.rs +assertion_line: 937 +expression: paths +snapshot_kind: text +--- +- _path: bin/python + path_type: hardlink + sha256: 9e13091076809d9c845dc484b21ae2ba965895705d7fec77dd51ec3af7e26e31 + sha256_in_prefix: 9e13091076809d9c845dc484b21ae2ba965895705d7fec77dd51ec3af7e26e31 + size_in_bytes: 8 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-tar-bz2.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-tar-bz2.snap new file mode 100644 index 000000000..4daa57049 --- /dev/null +++ b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-clobber-tar-bz2.snap @@ -0,0 +1,16 @@ +--- +source: crates/rattler/src/install/mod.rs +assertion_line: 937 +expression: paths +snapshot_kind: text +--- +- _path: another-clobber.txt + path_type: hardlink + sha256: dd79cf28afefb8038e9ca3141f2d47ca3c764cd50b880eb65263705792b909c8 + sha256_in_prefix: dd79cf28afefb8038e9ca3141f2d47ca3c764cd50b880eb65263705792b909c8 + size_in_bytes: 10 +- _path: clobber.txt + path_type: hardlink + sha256: dd79cf28afefb8038e9ca3141f2d47ca3c764cd50b880eb65263705792b909c8 + sha256_in_prefix: dd79cf28afefb8038e9ca3141f2d47ca3c764cd50b880eb65263705792b909c8 + size_in_bytes: 10 diff --git a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap b/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap deleted file mode 100644 index 342b3858c..000000000 --- a/crates/rattler/src/install/snapshots/rattler__install__test__link_package_from_archive-ruff.snap +++ /dev/null @@ -1,76 +0,0 @@ ---- -source: crates/rattler/src/install/mod.rs -assertion_line: 942 -expression: paths -snapshot_kind: text ---- -- _path: Lib/site-packages/ruff-0.0.171.dist-info/INSTALLER - path_type: hardlink - sha256: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - sha256_in_prefix: d0edee15f91b406f3f99726e44eb990be6e34fd0345b52b910c568e0eef6a2a8 - size_in_bytes: 5 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/METADATA - path_type: hardlink - sha256: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - sha256_in_prefix: fba95fb4a3bb15c300e3950b2b912425b0163a9e8e2faae8a68d867bdfec7819 - size_in_bytes: 77203 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/RECORD - path_type: hardlink - sha256: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - sha256_in_prefix: b821cd5c255c078e53c904846b95e0bd9f73bc7764538cf9fd1181b8d7c2b628 - size_in_bytes: 896 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/REQUESTED - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/WHEEL - path_type: hardlink - sha256: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - sha256_in_prefix: 48809079c83d2fc9b7581bb1a3ea375f6eaea7074b0a722c0ada479f78d54f35 - size_in_bytes: 94 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/direct_url.json - path_type: hardlink - sha256: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - sha256_in_prefix: 88d97db3dccb9ab7f8ff5a8d3c3405297e111364375ccd848a9966906c900d6a - size_in_bytes: 119 -- _path: Lib/site-packages/ruff-0.0.171.dist-info/license_files/LICENSE - path_type: hardlink - sha256: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - sha256_in_prefix: 0891ad47212cb60b4d5f277b3b18fd44f8c3501d2612bbac0325bd332173d49e - size_in_bytes: 30157 -- _path: Lib/site-packages/ruff/__init__.py - path_type: hardlink - sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - sha256_in_prefix: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 - size_in_bytes: 0 -- _path: Lib/site-packages/ruff/__main__.py - path_type: hardlink - sha256: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - sha256_in_prefix: 86de2c033f7285b67662e60d06ee9837c0fd9ba128a72bb271eb6d1f75c4f902 - size_in_bytes: 193 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-310.pyc - path_type: hardlink - sha256: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - sha256_in_prefix: 9c830b0cbcd46189b34cabed42a002bd0faeba9abdd48979079dec18bdfb540e - size_in_bytes: 160 -- _path: Lib/site-packages/ruff/__pycache__/__init__.cpython-311.pyc - path_type: hardlink - sha256: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - sha256_in_prefix: 890732d0bad13b143e69f22d2e81e11ce746f225a418f0382fc153cfcabf7b35 - size_in_bytes: 143 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-310.pyc - path_type: hardlink - sha256: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - sha256_in_prefix: a212e166b246f05caa68ba296261d9b5ca3554a4c0f9b4b266c45759df7c5abd - size_in_bytes: 383 -- _path: Lib/site-packages/ruff/__pycache__/__main__.cpython-311.pyc - path_type: hardlink - sha256: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - sha256_in_prefix: da00646e8afbeca6ed78d3159d231e198dbf4950e92cec6cdf629e2fbd620a60 - size_in_bytes: 629 -- _path: Scripts/ruff.exe - path_type: hardlink - sha256: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - sha256_in_prefix: 268820aa3008ea202b779382ac80b09d81ee1de26e72fdc5d0feca05b3d94e09 - size_in_bytes: 6896640 From e0341f0d4c6eb280d24ac35c768d8d00cf66fd46 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 22 Nov 2024 10:32:37 +0100 Subject: [PATCH 12/14] format --- crates/rattler/src/install/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 4137cf380..f93cd0a71 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -907,14 +907,8 @@ mod test { } #[rstest::rstest] - #[case( - "clobber-tar-bz2", - "clobber/clobber-1-0.1.0-h4616a5c_0.tar.bz2", - )] - #[case( - "clobber-conda", - "clobber/clobber-python-0.1.0-cpython.conda", - )] + #[case("clobber-tar-bz2", "clobber/clobber-1-0.1.0-h4616a5c_0.tar.bz2")] + #[case("clobber-conda", "clobber/clobber-python-0.1.0-cpython.conda")] #[tracing_test::traced_test] #[tokio::test] async fn test_link_package_from_archive(#[case] package: &str, #[case] package_path: &str) { From 707c8e24ac5ceb94853b878595066973399714d2 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 22 Nov 2024 11:02:39 +0100 Subject: [PATCH 13/14] add debug message --- crates/rattler/src/install/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index f93cd0a71..847ad34af 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -264,6 +264,7 @@ pub async fn link_package_from_archive( options: InstallOptions, ) -> Result, InstallError> { let temp_dir = tempfile::tempdir().map_err(InstallError::FailedToCreateTempDirectory)?; + tracing::debug!("extracting {} to temporary directory {}", package_path.display(), temp_dir.path().display()); extract(package_path, temp_dir.path()).map_err(InstallError::FailedToExtractPackage)?; link_package(temp_dir.path(), target_dir, driver, options).await From c7eb50e15cacd4843d41f6f3a9458cf1a9dbe463 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Fri, 22 Nov 2024 11:10:01 +0100 Subject: [PATCH 14/14] fmt --- crates/rattler/src/install/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 847ad34af..68dc8fe79 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -264,7 +264,11 @@ pub async fn link_package_from_archive( options: InstallOptions, ) -> Result, InstallError> { let temp_dir = tempfile::tempdir().map_err(InstallError::FailedToCreateTempDirectory)?; - tracing::debug!("extracting {} to temporary directory {}", package_path.display(), temp_dir.path().display()); + tracing::debug!( + "extracting {} to temporary directory {}", + package_path.display(), + temp_dir.path().display() + ); extract(package_path, temp_dir.path()).map_err(InstallError::FailedToExtractPackage)?; link_package(temp_dir.path(), target_dir, driver, options).await