From 7b1c7e2a67741fd5d281ead75222251e95113a94 Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 11:05:47 +0800 Subject: [PATCH 1/7] Refactor PackageCache into an enum to prepare for layered package cache feature --- crates/rattler-bin/src/commands/create.rs | 4 ++-- .../rattler/src/install/clobber_registry.rs | 18 +++++++------- crates/rattler/src/install/installer/mod.rs | 12 +++++----- crates/rattler/src/install/link_script.rs | 4 ++-- crates/rattler/src/install/mod.rs | 4 ++-- crates/rattler/src/install/test_utils.rs | 6 ++--- crates/rattler_cache/src/package_cache.rs | 24 ++++++++++++------- .../src/gateway/builder.rs | 10 ++++---- .../src/gateway/direct_url_query.rs | 12 +++++----- .../src/gateway/mod.rs | 10 ++++---- 10 files changed, 56 insertions(+), 48 deletions(-) diff --git a/crates/rattler-bin/src/commands/create.rs b/crates/rattler-bin/src/commands/create.rs index 7c840a77a..3e42f2b4e 100644 --- a/crates/rattler-bin/src/commands/create.rs +++ b/crates/rattler-bin/src/commands/create.rs @@ -4,7 +4,7 @@ use clap::ValueEnum; use indicatif::{ProgressBar, ProgressStyle}; use itertools::Itertools; use rattler::install::{IndicatifReporter, Installer}; -use rattler::package_cache::PackageCache; +use rattler::package_cache::SingletonPackageCache; use rattler::{ default_cache_dir, install::{Transaction, TransactionOperation}, @@ -145,7 +145,7 @@ pub async fn create(opt: Opt) -> anyhow::Result<()> { // Get the package names from the matchspecs so we can only load the package records that we need. let gateway = Gateway::builder() .with_cache_dir(cache_dir.join(rattler_cache::REPODATA_CACHE_DIR)) - .with_package_cache(PackageCache::new( + .with_package_cache(SingletonPackageCache::new( cache_dir.join(rattler_cache::PACKAGE_CACHE_DIR), )) .with_client(download_client.clone()) diff --git a/crates/rattler/src/install/clobber_registry.rs b/crates/rattler/src/install/clobber_registry.rs index 3c9a62570..54f2079f6 100644 --- a/crates/rattler/src/install/clobber_registry.rs +++ b/crates/rattler/src/install/clobber_registry.rs @@ -371,7 +371,7 @@ mod tests { use crate::{ get_repodata_record, get_test_data_dir, install::{test_utils::*, transaction, InstallDriver, InstallOptions, PythonInfo}, - package_cache::PackageCache, + package_cache::SingletonPackageCache, }; fn test_operations() -> Vec> { @@ -476,7 +476,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -597,7 +597,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -679,7 +679,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -782,7 +782,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -883,7 +883,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -1013,7 +1013,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); let install_options = InstallOptions { python_info: Some(python_info.clone()), @@ -1062,7 +1062,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, @@ -1129,7 +1129,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); execute_transaction( transaction, diff --git a/crates/rattler/src/install/installer/mod.rs b/crates/rattler/src/install/installer/mod.rs index 9bd8dde96..fdb6b2449 100644 --- a/crates/rattler/src/install/installer/mod.rs +++ b/crates/rattler/src/install/installer/mod.rs @@ -31,14 +31,14 @@ use crate::install::link_script::LinkScriptError; use crate::{ default_cache_dir, install::{clobber_registry::ClobberedPath, link_script::PrePostLinkResult}, - package_cache::{CacheReporter, PackageCache}, + package_cache::{CacheReporter, SingletonPackageCache}, }; /// An installer that can install packages into a prefix. #[derive(Default)] pub struct Installer { installed: Option>, - package_cache: Option, + package_cache: Option, downloader: Option, execute_link_scripts: bool, io_semaphore: Option>, @@ -142,7 +142,7 @@ impl Installer { /// Sets the package cache to use. #[must_use] - pub fn with_package_cache(self, package_cache: PackageCache) -> Self { + pub fn with_package_cache(self, package_cache: SingletonPackageCache) -> Self { Self { package_cache: Some(package_cache), ..self @@ -153,7 +153,7 @@ impl Installer { /// /// This function is similar to [`Self::with_package_cache`],but modifies an /// existing instance. - pub fn set_package_cache(&mut self, package_cache: PackageCache) -> &mut Self { + pub fn set_package_cache(&mut self, package_cache: SingletonPackageCache) -> &mut Self { self.package_cache = Some(package_cache); self } @@ -274,7 +274,7 @@ impl Installer { .downloader .unwrap_or_else(|| reqwest_middleware::ClientWithMiddleware::from(Client::default())); let package_cache = self.package_cache.unwrap_or_else(|| { - PackageCache::new( + SingletonPackageCache::new( default_cache_dir() .expect("failed to determine default cache directory") .join(rattler_cache::PACKAGE_CACHE_DIR), @@ -517,7 +517,7 @@ async fn link_package( async fn populate_cache( record: &RepoDataRecord, downloader: reqwest_middleware::ClientWithMiddleware, - cache: &PackageCache, + cache: &SingletonPackageCache, reporter: Option<(Arc, usize)>, ) -> Result { struct CacheReporterBridge { diff --git a/crates/rattler/src/install/link_script.rs b/crates/rattler/src/install/link_script.rs index b04bec345..9fb7742a9 100644 --- a/crates/rattler/src/install/link_script.rs +++ b/crates/rattler/src/install/link_script.rs @@ -239,7 +239,7 @@ mod tests { test_utils::execute_transaction, transaction, InstallDriver, InstallOptions, TransactionOperation, }, - package_cache::PackageCache, + package_cache::SingletonPackageCache, }; fn test_operations() -> Vec> { @@ -264,7 +264,7 @@ mod tests { }; let packages_dir = tempfile::tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = SingletonPackageCache::new(packages_dir.path()); let driver = InstallDriver::builder().execute_link_scripts(true).finish(); execute_transaction( diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 21be0f2d7..9fa99f926 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -723,7 +723,7 @@ mod test { use crate::{ get_test_data_dir, install::{link_package, InstallDriver, InstallOptions, PythonInfo}, - package_cache::PackageCache, + package_cache::SingletonPackageCache, }; #[tracing_test::traced_test] @@ -777,7 +777,7 @@ mod test { // Open a package cache in the systems temporary directory with a specific name. // This allows us to reuse a package cache across multiple invocations // of this test. Useful if you're debugging. - let package_cache = PackageCache::new(temp_dir().join("rattler").join(cache_name)); + let package_cache = SingletonPackageCache::new(temp_dir().join("rattler").join(cache_name)); // Create an HTTP client we can use to download packages let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); diff --git a/crates/rattler/src/install/test_utils.rs b/crates/rattler/src/install/test_utils.rs index 4a2a17786..2b8fb2ca4 100644 --- a/crates/rattler/src/install/test_utils.rs +++ b/crates/rattler/src/install/test_utils.rs @@ -7,7 +7,7 @@ use transaction::{Transaction, TransactionOperation}; use crate::{ install::{transaction, unlink_package, InstallDriver, InstallOptions}, - package_cache::PackageCache, + package_cache::SingletonPackageCache, }; /// Install a package into the environment and write a `conda-meta` file that @@ -69,7 +69,7 @@ pub async fn install_package_to_environment( pub async fn execute_operation( target_prefix: &Path, download_client: &reqwest_middleware::ClientWithMiddleware, - package_cache: &PackageCache, + package_cache: &SingletonPackageCache, install_driver: &InstallDriver, op: TransactionOperation, install_options: &InstallOptions, @@ -121,7 +121,7 @@ pub async fn execute_transaction( transaction: Transaction, target_prefix: &Path, download_client: &reqwest_middleware::ClientWithMiddleware, - package_cache: &PackageCache, + package_cache: &SingletonPackageCache, install_driver: &InstallDriver, install_options: &InstallOptions, ) { diff --git a/crates/rattler_cache/src/package_cache.rs b/crates/rattler_cache/src/package_cache.rs index 6e5cd78d5..d168889c4 100644 --- a/crates/rattler_cache/src/package_cache.rs +++ b/crates/rattler_cache/src/package_cache.rs @@ -47,8 +47,10 @@ pub trait CacheReporter: Send + Sync { /// cache is stale a user defined function is called to populate the cache. This /// separates the corners between caching and fetching of the content. #[derive(Clone)] -pub struct PackageCache { - inner: Arc>, +pub enum PackageCache { + SingletonPackageCache { + inner: Arc>, + }, } /// Provides a unique identifier for packages in the cache. @@ -133,9 +135,8 @@ pub enum PackageCacheError { } impl PackageCache { - /// Constructs a new [`PackageCache`] located at the specified path. - pub fn new(path: impl Into) -> Self { - Self { + pub fn new_singleton(path: impl Into) -> Self { + Self::SingletonPackageCache { inner: Arc::new(Mutex::new(PackageCacheInner { path: path.into(), packages: FxHashMap::default(), @@ -143,6 +144,12 @@ impl PackageCache { } } + pub fn get_inner(&self) -> Arc> { + match self { + Self::SingletonPackageCache { inner } => inner.clone(), + } + } + /// Returns the directory that contains the specified package. /// /// If the package was previously successfully fetched and stored in the @@ -168,7 +175,8 @@ impl PackageCache { // Get the package entry let (package, pkg_cache_dir) = { - let mut inner = self.inner.lock(); + let _inner = self.get_inner(); + let mut inner = _inner.lock(); let destination = inner.path.join(cache_key.to_string()); let package = inner.packages.entry(cache_key).or_default().clone(); (package, destination) @@ -455,7 +463,7 @@ mod test { }; let packages_dir = tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); // Get the package to the cache let package_dir = cache @@ -590,7 +598,7 @@ mod test { tokio::spawn(axum::serve(listener, service).into_future()); let packages_dir = tempdir().unwrap(); - let cache = PackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); let server_url = Url::parse(&format!("http://localhost:{}", addr.port())).unwrap(); diff --git a/crates/rattler_repodata_gateway/src/gateway/builder.rs b/crates/rattler_repodata_gateway/src/gateway/builder.rs index c2c572450..b90dfd61d 100644 --- a/crates/rattler_repodata_gateway/src/gateway/builder.rs +++ b/crates/rattler_repodata_gateway/src/gateway/builder.rs @@ -1,7 +1,7 @@ use crate::gateway::GatewayInner; use crate::{ChannelConfig, Gateway}; use dashmap::DashMap; -use rattler_cache::package_cache::PackageCache; +use rattler_cache::package_cache::SingletonPackageCache; use reqwest::Client; use reqwest_middleware::ClientWithMiddleware; use std::path::PathBuf; @@ -13,7 +13,7 @@ pub struct GatewayBuilder { channel_config: ChannelConfig, client: Option, cache: Option, - package_cache: Option, + package_cache: Option, max_concurrent_requests: Option, } @@ -57,7 +57,7 @@ impl GatewayBuilder { } /// Add package cache to the builder to store packages. - pub fn with_package_cache(mut self, package_cache: PackageCache) -> Self { + pub fn with_package_cache(mut self, package_cache: SingletonPackageCache) -> Self { self.set_package_cache(package_cache); self } @@ -69,7 +69,7 @@ impl GatewayBuilder { } /// Set the directory to use for caching packages. - pub fn set_package_cache(&mut self, package_cache: PackageCache) -> &mut Self { + pub fn set_package_cache(&mut self, package_cache: SingletonPackageCache) -> &mut Self { self.package_cache = Some(package_cache); self } @@ -99,7 +99,7 @@ impl GatewayBuilder { .join("rattler/cache") }); - let package_cache = self.package_cache.unwrap_or(PackageCache::new( + let package_cache = self.package_cache.unwrap_or(SingletonPackageCache::new( cache.join(rattler_cache::PACKAGE_CACHE_DIR), )); diff --git a/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs b/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs index 6ecbf3083..267d92732 100644 --- a/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs +++ b/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs @@ -1,7 +1,7 @@ use std::{future::IntoFuture, sync::Arc}; use futures::FutureExt; -use rattler_cache::package_cache::{CacheKey, PackageCache, PackageCacheError}; +use rattler_cache::package_cache::{CacheKey, PackageCacheError}; use rattler_conda_types::{ package::{ArchiveIdentifier, IndexJson, PackageFile}, ConvertSubdirError, PackageRecord, RepoDataRecord, @@ -17,7 +17,7 @@ pub(crate) struct DirectUrlQuery { /// The client to use for fetching the package client: reqwest_middleware::ClientWithMiddleware, /// The cache to use for storing the package - package_cache: PackageCache, + package_cache: SingletonPackageCache, } #[derive(Debug, thiserror::Error)] @@ -35,7 +35,7 @@ pub enum DirectUrlQueryError { impl DirectUrlQuery { pub(crate) fn new( url: Url, - package_cache: PackageCache, + package_cache: SingletonPackageCache, client: reqwest_middleware::ClientWithMiddleware, sha256: Option, ) -> Self { @@ -110,7 +110,7 @@ impl IntoFuture for DirectUrlQuery { mod test { use std::{env::temp_dir, path::PathBuf}; - use rattler_cache::package_cache::PackageCache; + use rattler_cache::package_cache::SingletonPackageCache; use url::Url; use super::*; @@ -121,7 +121,7 @@ mod test { "https://conda.anaconda.org/conda-forge/noarch/boltons-24.0.0-pyhd8ed1ab_0.conda", ) .unwrap(); - let package_cache = PackageCache::new(PathBuf::from("/tmp")); + let package_cache = SingletonPackageCache::new(PathBuf::from("/tmp")); let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); let query = DirectUrlQuery::new(url.clone(), package_cache, client, None); @@ -163,7 +163,7 @@ mod test { .unwrap(); let url = Url::from_file_path(package_path).unwrap(); - let package_cache = PackageCache::new(temp_dir()); + let package_cache = SingletonPackageCache::new(temp_dir()); let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); let query = DirectUrlQuery::new(url.clone(), package_cache, client, None); diff --git a/crates/rattler_repodata_gateway/src/gateway/mod.rs b/crates/rattler_repodata_gateway/src/gateway/mod.rs index 3f7340963..2fb2eb31f 100644 --- a/crates/rattler_repodata_gateway/src/gateway/mod.rs +++ b/crates/rattler_repodata_gateway/src/gateway/mod.rs @@ -24,7 +24,7 @@ pub use error::GatewayError; use file_url::url_to_path; use local_subdir::LocalSubdirClient; pub use query::{NamesQuery, RepoDataQuery}; -use rattler_cache::package_cache::PackageCache; +use rattler_cache::package_cache::SingletonPackageCache; use rattler_conda_types::{Channel, MatchSpec, Platform}; pub use repo_data::RepoData; use reqwest_middleware::ClientWithMiddleware; @@ -161,7 +161,7 @@ struct GatewayInner { cache: PathBuf, /// The package cache, stored to reuse memory cache - package_cache: PackageCache, + package_cache: SingletonPackageCache, /// A semaphore to limit the number of concurrent requests. concurrent_requests_semaphore: Arc, @@ -362,7 +362,7 @@ mod test { use dashmap::DashSet; use rattler_cache::default_cache_dir; - use rattler_cache::package_cache::PackageCache; + use rattler_cache::package_cache::SingletonPackageCache; use rattler_conda_types::{ Channel, ChannelConfig, MatchSpec, PackageName, ParseStrictness::Lenient, ParseStrictness::Strict, Platform, RepoDataRecord, @@ -433,7 +433,7 @@ mod test { #[tokio::test] async fn test_direct_url_spec_from_gateway() { let gateway = Gateway::builder() - .with_package_cache(PackageCache::new( + .with_package_cache(SingletonPackageCache::new( default_cache_dir() .unwrap() .join(rattler_cache::PACKAGE_CACHE_DIR), @@ -494,7 +494,7 @@ mod test { #[tokio::test] async fn test_select_forced_url_instead_of_deps() { let gateway = Gateway::builder() - .with_package_cache(PackageCache::new( + .with_package_cache(SingletonPackageCache::new( default_cache_dir() .unwrap() .join(rattler_cache::PACKAGE_CACHE_DIR), From b428ca20bc37550ec2bf62d69490740d87d30a9e Mon Sep 17 00:00:00 2001 From: Bas Zalmstra Date: Mon, 2 Sep 2024 20:19:43 +0200 Subject: [PATCH 2/7] chore: release (#836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🤖 New release * `rattler_conda_types`: 0.27.2 -> 0.27.3 * `rattler_package_streaming`: 0.22.3 -> 0.22.4 * `rattler_lock`: 0.22.20 -> 0.22.21 * `rattler_solve`: 1.0.3 -> 1.0.4 * `rattler_virtual_packages`: 1.0.4 -> 1.1.0 * `rattler_index`: 0.19.24 -> 0.19.25 * `rattler`: 0.27.6 -> 0.27.7 * `rattler_cache`: 0.1.8 -> 0.1.9 * `rattler_shell`: 0.21.6 -> 0.21.7 * `rattler_repodata_gateway`: 0.21.8 -> 0.21.9
Changelog

## `rattler_conda_types`

## [0.27.3](https://github.com/conda/rattler/compare/rattler_conda_types-v0.27.2...rattler_conda_types-v0.27.3) - 2024-09-02 ### Added - add edge case tests for `StringMatcher` ([#839](https://github.com/conda/rattler/pull/839))
## `rattler_package_streaming`
## [0.22.4](https://github.com/conda/rattler/compare/rattler_package_streaming-v0.22.3...rattler_package_streaming-v0.22.4) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818)) ### Fixed - zip large files compression ([#838](https://github.com/conda/rattler/pull/838))
## `rattler_lock`
## [0.22.21](https://github.com/conda/rattler/compare/rattler_lock-v0.22.20...rattler_lock-v0.22.21) - 2024-09-02 ### Added - Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818))
## `rattler_solve`
## [1.0.4](https://github.com/conda/rattler/compare/rattler_solve-v1.0.3...rattler_solve-v1.0.4) - 2024-09-02 ### Fixed - Redact spec channel before comparing it with repodata channel ([#831](https://github.com/conda/rattler/pull/831)) ### Other - Remove note that only libsolv is supported ([#832](https://github.com/conda/rattler/pull/832))
## `rattler_virtual_packages`
## [1.1.0](https://github.com/conda/rattler/compare/rattler_virtual_packages-v1.0.4...rattler_virtual_packages-v1.1.0) - 2024-09-02 ### Added - start adding interface to override ([#834](https://github.com/conda/rattler/pull/834)) - Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818)) ### Other - make virtual package overrides none by default consistently ([#842](https://github.com/conda/rattler/pull/842))
## `rattler_index`
## [0.19.25](https://github.com/conda/rattler/compare/rattler_index-v0.19.24...rattler_index-v0.19.25) - 2024-09-02 ### Other - release ([#824](https://github.com/conda/rattler/pull/824))
## `rattler`
## [0.27.7](https://github.com/conda/rattler/compare/rattler-v0.27.6...rattler-v0.27.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming
## `rattler_cache`
## [0.1.9](https://github.com/conda/rattler/compare/rattler_cache-v0.1.8...rattler_cache-v0.1.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types, rattler_package_streaming
## `rattler_shell`
## [0.21.7](https://github.com/conda/rattler/compare/rattler_shell-v0.21.6...rattler_shell-v0.21.7) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types
## `rattler_repodata_gateway`
## [0.21.9](https://github.com/conda/rattler/compare/rattler_repodata_gateway-v0.21.8...rattler_repodata_gateway-v0.21.9) - 2024-09-02 ### Other - updated the following local packages: rattler_conda_types

--- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). --- crates/rattler-bin/Cargo.toml | 12 ++++++------ crates/rattler/CHANGELOG.md | 5 +++++ crates/rattler/Cargo.toml | 10 +++++----- crates/rattler_cache/CHANGELOG.md | 5 +++++ crates/rattler_cache/Cargo.toml | 6 +++--- crates/rattler_conda_types/CHANGELOG.md | 5 +++++ crates/rattler_conda_types/Cargo.toml | 2 +- crates/rattler_index/CHANGELOG.md | 5 +++++ crates/rattler_index/Cargo.toml | 6 +++--- crates/rattler_lock/CHANGELOG.md | 5 +++++ crates/rattler_lock/Cargo.toml | 4 ++-- crates/rattler_package_streaming/CHANGELOG.md | 8 ++++++++ crates/rattler_package_streaming/Cargo.toml | 4 ++-- crates/rattler_repodata_gateway/CHANGELOG.md | 5 +++++ crates/rattler_repodata_gateway/Cargo.toml | 6 +++--- crates/rattler_shell/CHANGELOG.md | 5 +++++ crates/rattler_shell/Cargo.toml | 4 ++-- crates/rattler_solve/CHANGELOG.md | 8 ++++++++ crates/rattler_solve/Cargo.toml | 4 ++-- crates/rattler_virtual_packages/CHANGELOG.md | 9 +++++++++ crates/rattler_virtual_packages/Cargo.toml | 4 ++-- 21 files changed, 91 insertions(+), 31 deletions(-) diff --git a/crates/rattler-bin/Cargo.toml b/crates/rattler-bin/Cargo.toml index 9ec3685f6..b681adc11 100644 --- a/crates/rattler-bin/Cargo.toml +++ b/crates/rattler-bin/Cargo.toml @@ -27,13 +27,13 @@ clap = { workspace = true, features = ["derive"] } console = { workspace = true, features = ["windows-console-colors"] } indicatif = { workspace = true } once_cell = { workspace = true } -rattler = { path="../rattler", version = "0.27.6", default-features = false, features = ["indicatif"] } -rattler_conda_types = { path="../rattler_conda_types", version = "0.27.2", default-features = false } +rattler = { path="../rattler", version = "0.27.7", default-features = false, features = ["indicatif"] } +rattler_conda_types = { path="../rattler_conda_types", version = "0.27.3", default-features = false } rattler_networking = { path="../rattler_networking", version = "0.21.2", default-features = false } -rattler_repodata_gateway = { path="../rattler_repodata_gateway", version = "0.21.8", default-features = false, features = ["gateway"] } -rattler_solve = { path="../rattler_solve", version = "1.0.3", default-features = false, features = ["resolvo", "libsolv_c"] } -rattler_virtual_packages = { path="../rattler_virtual_packages", version = "1.0.4", default-features = false } -rattler_cache = { path="../rattler_cache", version = "0.1.8", default-features = false } +rattler_repodata_gateway = { path="../rattler_repodata_gateway", version = "0.21.9", default-features = false, features = ["gateway"] } +rattler_solve = { path="../rattler_solve", version = "1.0.4", default-features = false, features = ["resolvo", "libsolv_c"] } +rattler_virtual_packages = { path="../rattler_virtual_packages", version = "1.1.0", default-features = false } +rattler_cache = { path="../rattler_cache", version = "0.1.9", default-features = false } reqwest = { workspace = true } reqwest-middleware = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } diff --git a/crates/rattler/CHANGELOG.md b/crates/rattler/CHANGELOG.md index 57dfb46b3..e8323a29d 100644 --- a/crates/rattler/CHANGELOG.md +++ b/crates/rattler/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.27.7](https://github.com/conda/rattler/compare/rattler-v0.27.6...rattler-v0.27.7) - 2024-09-02 + +### Other +- updated the following local packages: rattler_conda_types, rattler_package_streaming + ## [0.27.6](https://github.com/conda/rattler/compare/rattler-v0.27.5...rattler-v0.27.6) - 2024-08-16 ### Other diff --git a/crates/rattler/Cargo.toml b/crates/rattler/Cargo.toml index 2129260ef..1d68d58dd 100644 --- a/crates/rattler/Cargo.toml +++ b/crates/rattler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler" -version = "0.27.6" +version = "0.27.7" edition.workspace = true authors = ["Bas Zalmstra "] description = "Rust library to install conda environments" @@ -32,12 +32,12 @@ memchr = { workspace = true } memmap2 = { workspace = true } once_cell = { workspace = true } parking_lot = { workspace = true } -rattler_cache = { path = "../rattler_cache", version = "0.1.8", default-features = false } -rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_cache = { path = "../rattler_cache", version = "0.1.9", default-features = false } +rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.3", default-features = false } rattler_digest = { path = "../rattler_digest", version = "1.0.1", default-features = false } rattler_networking = { path = "../rattler_networking", version = "0.21.2", default-features = false } -rattler_shell = { path = "../rattler_shell", version = "0.21.6", default-features = false } -rattler_package_streaming = { path = "../rattler_package_streaming", version = "0.22.3", default-features = false, features = ["reqwest"] } +rattler_shell = { path = "../rattler_shell", version = "0.21.7", default-features = false } +rattler_package_streaming = { path = "../rattler_package_streaming", version = "0.22.4", default-features = false, features = ["reqwest"] } reflink-copy = { workspace = true } regex = { workspace = true } reqwest = { workspace = true, features = ["stream", "json", "gzip"] } diff --git a/crates/rattler_cache/CHANGELOG.md b/crates/rattler_cache/CHANGELOG.md index 92a9c7705..476786184 100644 --- a/crates/rattler_cache/CHANGELOG.md +++ b/crates/rattler_cache/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.9](https://github.com/conda/rattler/compare/rattler_cache-v0.1.8...rattler_cache-v0.1.9) - 2024-09-02 + +### Other +- updated the following local packages: rattler_conda_types, rattler_package_streaming + ## [0.1.8](https://github.com/conda/rattler/compare/rattler_cache-v0.1.7...rattler_cache-v0.1.8) - 2024-08-16 ### Other diff --git a/crates/rattler_cache/Cargo.toml b/crates/rattler_cache/Cargo.toml index b25d8f6ec..4dcf08916 100644 --- a/crates/rattler_cache/Cargo.toml +++ b/crates/rattler_cache/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_cache" -version = "0.1.8" +version = "0.1.9" description = "A crate to manage the caching of data in rattler" categories.workspace = true homepage.workspace = true @@ -15,10 +15,10 @@ dirs.workspace = true fxhash.workspace = true itertools.workspace = true parking_lot.workspace = true -rattler_conda_types = { version = "0.27.2", path = "../rattler_conda_types", default-features = false } +rattler_conda_types = { version = "0.27.3", path = "../rattler_conda_types", default-features = false } rattler_digest = { version = "1.0.1", path = "../rattler_digest", default-features = false } rattler_networking = { version = "0.21.2", path = "../rattler_networking", default-features = false } -rattler_package_streaming = { version = "0.22.3", path = "../rattler_package_streaming", default-features = false, features = ["reqwest"] } +rattler_package_streaming = { version = "0.22.4", path = "../rattler_package_streaming", default-features = false, features = ["reqwest"] } reqwest.workspace = true tokio.workspace = true tracing.workspace = true diff --git a/crates/rattler_conda_types/CHANGELOG.md b/crates/rattler_conda_types/CHANGELOG.md index aa5843a04..ce9e5c263 100644 --- a/crates/rattler_conda_types/CHANGELOG.md +++ b/crates/rattler_conda_types/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.27.3](https://github.com/conda/rattler/compare/rattler_conda_types-v0.27.2...rattler_conda_types-v0.27.3) - 2024-09-02 + +### Added +- add edge case tests for `StringMatcher` ([#839](https://github.com/conda/rattler/pull/839)) + ## [0.27.2](https://github.com/conda/rattler/compare/rattler_conda_types-v0.27.1...rattler_conda_types-v0.27.2) - 2024-08-15 ### Added diff --git a/crates/rattler_conda_types/Cargo.toml b/crates/rattler_conda_types/Cargo.toml index 71c1d8431..5d77d978e 100644 --- a/crates/rattler_conda_types/Cargo.toml +++ b/crates/rattler_conda_types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_conda_types" -version = "0.27.2" +version = "0.27.3" edition.workspace = true authors = ["Bas Zalmstra "] description = "Rust data types for common types used within the Conda ecosystem" diff --git a/crates/rattler_index/CHANGELOG.md b/crates/rattler_index/CHANGELOG.md index 129afa3d1..45dd86d3a 100644 --- a/crates/rattler_index/CHANGELOG.md +++ b/crates/rattler_index/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.19.25](https://github.com/conda/rattler/compare/rattler_index-v0.19.24...rattler_index-v0.19.25) - 2024-09-02 + +### Other +- release ([#824](https://github.com/conda/rattler/pull/824)) + ## [0.19.24](https://github.com/conda/rattler/compare/rattler_index-v0.19.23...rattler_index-v0.19.24) - 2024-08-15 ### Fixed diff --git a/crates/rattler_index/Cargo.toml b/crates/rattler_index/Cargo.toml index bc68cd473..41723c226 100644 --- a/crates/rattler_index/Cargo.toml +++ b/crates/rattler_index/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_index" -version = "0.19.24" +version = "0.19.25" edition.workspace = true authors = [] description = "A crate that indexes directories containing conda packages to create local conda channels" @@ -12,9 +12,9 @@ readme.workspace = true [dependencies] fs-err = { workspace = true } -rattler_conda_types = { path="../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path="../rattler_conda_types", version = "0.27.3", default-features = false } rattler_digest = { path="../rattler_digest", version = "1.0.1", default-features = false } -rattler_package_streaming = { path="../rattler_package_streaming", version = "0.22.3", default-features = false } +rattler_package_streaming = { path="../rattler_package_streaming", version = "0.22.4", default-features = false } serde_json = { workspace = true } tracing = { workspace = true } walkdir = { workspace = true } diff --git a/crates/rattler_lock/CHANGELOG.md b/crates/rattler_lock/CHANGELOG.md index ee5b92fc6..34ca5120c 100644 --- a/crates/rattler_lock/CHANGELOG.md +++ b/crates/rattler_lock/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.22.21](https://github.com/conda/rattler/compare/rattler_lock-v0.22.20...rattler_lock-v0.22.21) - 2024-09-02 + +### Added +- Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818)) + ## [0.22.20](https://github.com/conda/rattler/compare/rattler_lock-v0.22.19...rattler_lock-v0.22.20) - 2024-08-16 ### Added diff --git a/crates/rattler_lock/Cargo.toml b/crates/rattler_lock/Cargo.toml index 52045b220..2c69ebe47 100644 --- a/crates/rattler_lock/Cargo.toml +++ b/crates/rattler_lock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_lock" -version = "0.22.20" +version = "0.22.21" edition.workspace = true authors = ["Bas Zalmstra "] description = "Rust data types for conda lock" @@ -15,7 +15,7 @@ chrono = { workspace = true } fxhash = { workspace = true } indexmap = { workspace = true, features = ["serde"] } itertools = { workspace = true } -rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.3", default-features = false } rattler_digest = { path = "../rattler_digest", version = "1.0.1", default-features = false } file_url = { path = "../file_url", version = "0.1.4" } pep508_rs = { workspace = true, features = ["serde"] } diff --git a/crates/rattler_package_streaming/CHANGELOG.md b/crates/rattler_package_streaming/CHANGELOG.md index e93211653..73fb703be 100644 --- a/crates/rattler_package_streaming/CHANGELOG.md +++ b/crates/rattler_package_streaming/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.22.4](https://github.com/conda/rattler/compare/rattler_package_streaming-v0.22.3...rattler_package_streaming-v0.22.4) - 2024-09-02 + +### Added +- Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818)) + +### Fixed +- zip large files compression ([#838](https://github.com/conda/rattler/pull/838)) + ## [0.22.3](https://github.com/conda/rattler/compare/rattler_package_streaming-v0.22.2...rattler_package_streaming-v0.22.3) - 2024-08-16 ### Other diff --git a/crates/rattler_package_streaming/Cargo.toml b/crates/rattler_package_streaming/Cargo.toml index 57d1fed79..e105e975c 100644 --- a/crates/rattler_package_streaming/Cargo.toml +++ b/crates/rattler_package_streaming/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_package_streaming" -version = "0.22.3" +version = "0.22.4" edition.workspace = true authors = ["Bas Zalmstra "] description = "Extract and stream of Conda package archives" @@ -15,7 +15,7 @@ bzip2 = { workspace = true } chrono = { workspace = true } futures-util = { workspace = true } num_cpus = { workspace = true } -rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.3", default-features = false } rattler_digest = { path = "../rattler_digest", version = "1.0.1", default-features = false } rattler_networking = { path = "../rattler_networking", version = "0.21.2", default-features = false } rattler_redaction = { version = "0.1.1", path = "../rattler_redaction", features = ["reqwest", "reqwest-middleware"] } diff --git a/crates/rattler_repodata_gateway/CHANGELOG.md b/crates/rattler_repodata_gateway/CHANGELOG.md index 4e3b16eba..fb5503a24 100644 --- a/crates/rattler_repodata_gateway/CHANGELOG.md +++ b/crates/rattler_repodata_gateway/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.21.9](https://github.com/conda/rattler/compare/rattler_repodata_gateway-v0.21.8...rattler_repodata_gateway-v0.21.9) - 2024-09-02 + +### Other +- updated the following local packages: rattler_conda_types + ## [0.21.8](https://github.com/conda/rattler/compare/rattler_repodata_gateway-v0.21.7...rattler_repodata_gateway-v0.21.8) - 2024-08-16 ### Other diff --git a/crates/rattler_repodata_gateway/Cargo.toml b/crates/rattler_repodata_gateway/Cargo.toml index e3bf6d095..bfb00004e 100644 --- a/crates/rattler_repodata_gateway/Cargo.toml +++ b/crates/rattler_repodata_gateway/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_repodata_gateway" -version = "0.21.8" +version = "0.21.9" edition.workspace = true authors = ["Bas Zalmstra "] description = "A crate to interact with Conda repodata" @@ -34,7 +34,7 @@ memmap2 = { workspace = true, optional = true } ouroboros = { workspace = true, optional = true } parking_lot = { workspace = true, optional = true } pin-project-lite = { workspace = true } -rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.2", default-features = false, optional = true } +rattler_conda_types = { path = "../rattler_conda_types", version = "0.27.3", default-features = false, optional = true } rattler_digest = { path = "../rattler_digest", version = "1.0.1", default-features = false, features = ["tokio", "serde"] } rattler_networking = { path = "../rattler_networking", version = "0.21.2", default-features = false } reqwest = { workspace = true, features = ["stream", "http2"] } @@ -52,7 +52,7 @@ tokio-util = { workspace = true, features = ["codec", "io"] } tracing = { workspace = true } url = { workspace = true, features = ["serde"] } zstd = { workspace = true } -rattler_cache = { version = "0.1.8", path = "../rattler_cache" } +rattler_cache = { version = "0.1.9", path = "../rattler_cache" } rattler_redaction = { version = "0.1.1", path = "../rattler_redaction", features = ["reqwest", "reqwest-middleware"] } [target.'cfg(unix)'.dependencies] diff --git a/crates/rattler_shell/CHANGELOG.md b/crates/rattler_shell/CHANGELOG.md index 9089e8ace..edb09796f 100644 --- a/crates/rattler_shell/CHANGELOG.md +++ b/crates/rattler_shell/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.21.7](https://github.com/conda/rattler/compare/rattler_shell-v0.21.6...rattler_shell-v0.21.7) - 2024-09-02 + +### Other +- updated the following local packages: rattler_conda_types + ## [0.21.6](https://github.com/conda/rattler/compare/rattler_shell-v0.21.5...rattler_shell-v0.21.6) - 2024-08-15 ### Fixed diff --git a/crates/rattler_shell/Cargo.toml b/crates/rattler_shell/Cargo.toml index b2673cda0..4df30be18 100644 --- a/crates/rattler_shell/Cargo.toml +++ b/crates/rattler_shell/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_shell" -version = "0.21.6" +version = "0.21.7" edition.workspace = true authors = ["Wolf Vollprecht "] description = "A crate to help with activation and deactivation of a conda environment" @@ -14,7 +14,7 @@ readme.workspace = true enum_dispatch = { workspace = true } indexmap = { workspace = true } itertools = { workspace = true } -rattler_conda_types = { path="../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path="../rattler_conda_types", version = "0.27.3", default-features = false } serde_json = { workspace = true, features = ["preserve_order"] } shlex = { workspace = true } sysinfo = { workspace = true, optional = true } diff --git a/crates/rattler_solve/CHANGELOG.md b/crates/rattler_solve/CHANGELOG.md index 929ef7750..d659e9861 100644 --- a/crates/rattler_solve/CHANGELOG.md +++ b/crates/rattler_solve/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.0.4](https://github.com/conda/rattler/compare/rattler_solve-v1.0.3...rattler_solve-v1.0.4) - 2024-09-02 + +### Fixed +- Redact spec channel before comparing it with repodata channel ([#831](https://github.com/conda/rattler/pull/831)) + +### Other +- Remove note that only libsolv is supported ([#832](https://github.com/conda/rattler/pull/832)) + ## [1.0.3](https://github.com/conda/rattler/compare/rattler_solve-v1.0.2...rattler_solve-v1.0.3) - 2024-08-15 ### Fixed diff --git a/crates/rattler_solve/Cargo.toml b/crates/rattler_solve/Cargo.toml index e37d2731f..1dbaec7a4 100644 --- a/crates/rattler_solve/Cargo.toml +++ b/crates/rattler_solve/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_solve" -version = "1.0.3" +version = "1.0.4" edition.workspace = true authors = ["Bas Zalmstra "] description = "A crate to solve conda environments" @@ -11,7 +11,7 @@ license.workspace = true readme.workspace = true [dependencies] -rattler_conda_types = { path="../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path="../rattler_conda_types", version = "0.27.3", default-features = false } rattler_digest = { path="../rattler_digest", version = "1.0.1", default-features = false } libc = { workspace = true, optional = true } chrono = { workspace = true } diff --git a/crates/rattler_virtual_packages/CHANGELOG.md b/crates/rattler_virtual_packages/CHANGELOG.md index 4d47bcb7a..5e9064a05 100644 --- a/crates/rattler_virtual_packages/CHANGELOG.md +++ b/crates/rattler_virtual_packages/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.0](https://github.com/conda/rattler/compare/rattler_virtual_packages-v1.0.4...rattler_virtual_packages-v1.1.0) - 2024-09-02 + +### Added +- start adding interface to override ([#834](https://github.com/conda/rattler/pull/834)) +- Add support for `CONDA_OVERRIDE_CUDA` ([#818](https://github.com/conda/rattler/pull/818)) + +### Other +- make virtual package overrides none by default consistently ([#842](https://github.com/conda/rattler/pull/842)) + ## [1.0.4](https://github.com/conda/rattler/compare/rattler_virtual_packages-v1.0.3...rattler_virtual_packages-v1.0.4) - 2024-08-16 ### Fixed diff --git a/crates/rattler_virtual_packages/Cargo.toml b/crates/rattler_virtual_packages/Cargo.toml index d9cf93805..47047d4f6 100644 --- a/crates/rattler_virtual_packages/Cargo.toml +++ b/crates/rattler_virtual_packages/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rattler_virtual_packages" -version = "1.0.4" +version = "1.1.0" edition.workspace = true authors = ["Bas Zalmstra "] description = "Library to work with and detect Conda virtual packages" @@ -14,7 +14,7 @@ readme.workspace = true libloading = { workspace = true } nom = { workspace = true } once_cell = { workspace = true } -rattler_conda_types = { path="../rattler_conda_types", version = "0.27.2", default-features = false } +rattler_conda_types = { path="../rattler_conda_types", version = "0.27.3", default-features = false } regex = { workspace = true } serde = { workspace = true, features = ["derive"] } thiserror = { workspace = true } From 2b04cf5a4c713b51f3bb05c7a0fdad195ca9246c Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 15:14:03 +0800 Subject: [PATCH 3/7] Change constructor calls to new_singleton --- crates/rattler-bin/src/commands/create.rs | 4 ++-- crates/rattler/src/install/clobber_registry.rs | 18 +++++++++--------- crates/rattler/src/install/installer/mod.rs | 12 ++++++------ crates/rattler/src/install/link_script.rs | 4 ++-- crates/rattler/src/install/mod.rs | 5 +++-- crates/rattler/src/install/test_utils.rs | 6 +++--- .../src/gateway/builder.rs | 10 +++++----- .../src/gateway/direct_url_query.rs | 12 ++++++------ .../src/gateway/mod.rs | 10 +++++----- 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/crates/rattler-bin/src/commands/create.rs b/crates/rattler-bin/src/commands/create.rs index 3e42f2b4e..18c103923 100644 --- a/crates/rattler-bin/src/commands/create.rs +++ b/crates/rattler-bin/src/commands/create.rs @@ -4,7 +4,7 @@ use clap::ValueEnum; use indicatif::{ProgressBar, ProgressStyle}; use itertools::Itertools; use rattler::install::{IndicatifReporter, Installer}; -use rattler::package_cache::SingletonPackageCache; +use rattler::package_cache::PackageCache; use rattler::{ default_cache_dir, install::{Transaction, TransactionOperation}, @@ -145,7 +145,7 @@ pub async fn create(opt: Opt) -> anyhow::Result<()> { // Get the package names from the matchspecs so we can only load the package records that we need. let gateway = Gateway::builder() .with_cache_dir(cache_dir.join(rattler_cache::REPODATA_CACHE_DIR)) - .with_package_cache(SingletonPackageCache::new( + .with_package_cache(PackageCache::new_singleton( cache_dir.join(rattler_cache::PACKAGE_CACHE_DIR), )) .with_client(download_client.clone()) diff --git a/crates/rattler/src/install/clobber_registry.rs b/crates/rattler/src/install/clobber_registry.rs index 54f2079f6..0a471f6c7 100644 --- a/crates/rattler/src/install/clobber_registry.rs +++ b/crates/rattler/src/install/clobber_registry.rs @@ -371,7 +371,7 @@ mod tests { use crate::{ get_repodata_record, get_test_data_dir, install::{test_utils::*, transaction, InstallDriver, InstallOptions, PythonInfo}, - package_cache::SingletonPackageCache, + package_cache::PackageCache, }; fn test_operations() -> Vec> { @@ -476,7 +476,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -597,7 +597,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -679,7 +679,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -782,7 +782,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -883,7 +883,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -1013,7 +1013,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); let install_options = InstallOptions { python_info: Some(python_info.clone()), @@ -1062,7 +1062,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, @@ -1129,7 +1129,7 @@ mod tests { let target_prefix = tempfile::tempdir().unwrap(); let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); execute_transaction( transaction, diff --git a/crates/rattler/src/install/installer/mod.rs b/crates/rattler/src/install/installer/mod.rs index fdb6b2449..008903cd6 100644 --- a/crates/rattler/src/install/installer/mod.rs +++ b/crates/rattler/src/install/installer/mod.rs @@ -31,14 +31,14 @@ use crate::install::link_script::LinkScriptError; use crate::{ default_cache_dir, install::{clobber_registry::ClobberedPath, link_script::PrePostLinkResult}, - package_cache::{CacheReporter, SingletonPackageCache}, + package_cache::{CacheReporter, PackageCache}, }; /// An installer that can install packages into a prefix. #[derive(Default)] pub struct Installer { installed: Option>, - package_cache: Option, + package_cache: Option, downloader: Option, execute_link_scripts: bool, io_semaphore: Option>, @@ -142,7 +142,7 @@ impl Installer { /// Sets the package cache to use. #[must_use] - pub fn with_package_cache(self, package_cache: SingletonPackageCache) -> Self { + pub fn with_package_cache(self, package_cache: PackageCache) -> Self { Self { package_cache: Some(package_cache), ..self @@ -153,7 +153,7 @@ impl Installer { /// /// This function is similar to [`Self::with_package_cache`],but modifies an /// existing instance. - pub fn set_package_cache(&mut self, package_cache: SingletonPackageCache) -> &mut Self { + pub fn set_package_cache(&mut self, package_cache: PackageCache) -> &mut Self { self.package_cache = Some(package_cache); self } @@ -274,7 +274,7 @@ impl Installer { .downloader .unwrap_or_else(|| reqwest_middleware::ClientWithMiddleware::from(Client::default())); let package_cache = self.package_cache.unwrap_or_else(|| { - SingletonPackageCache::new( + PackageCache::new_singleton( default_cache_dir() .expect("failed to determine default cache directory") .join(rattler_cache::PACKAGE_CACHE_DIR), @@ -517,7 +517,7 @@ async fn link_package( async fn populate_cache( record: &RepoDataRecord, downloader: reqwest_middleware::ClientWithMiddleware, - cache: &SingletonPackageCache, + cache: &PackageCache, reporter: Option<(Arc, usize)>, ) -> Result { struct CacheReporterBridge { diff --git a/crates/rattler/src/install/link_script.rs b/crates/rattler/src/install/link_script.rs index 9fb7742a9..dd3af5d01 100644 --- a/crates/rattler/src/install/link_script.rs +++ b/crates/rattler/src/install/link_script.rs @@ -239,7 +239,7 @@ mod tests { test_utils::execute_transaction, transaction, InstallDriver, InstallOptions, TransactionOperation, }, - package_cache::SingletonPackageCache, + package_cache::PackageCache, }; fn test_operations() -> Vec> { @@ -264,7 +264,7 @@ mod tests { }; let packages_dir = tempfile::tempdir().unwrap(); - let cache = SingletonPackageCache::new(packages_dir.path()); + let cache = PackageCache::new_singleton(packages_dir.path()); let driver = InstallDriver::builder().execute_link_scripts(true).finish(); execute_transaction( diff --git a/crates/rattler/src/install/mod.rs b/crates/rattler/src/install/mod.rs index 9fa99f926..b423d2e77 100644 --- a/crates/rattler/src/install/mod.rs +++ b/crates/rattler/src/install/mod.rs @@ -723,7 +723,7 @@ mod test { use crate::{ get_test_data_dir, install::{link_package, InstallDriver, InstallOptions, PythonInfo}, - package_cache::SingletonPackageCache, + package_cache::PackageCache, }; #[tracing_test::traced_test] @@ -777,7 +777,8 @@ mod test { // Open a package cache in the systems temporary directory with a specific name. // This allows us to reuse a package cache across multiple invocations // of this test. Useful if you're debugging. - let package_cache = SingletonPackageCache::new(temp_dir().join("rattler").join(cache_name)); + let package_cache = + PackageCache::new_singleton(temp_dir().join("rattler").join(cache_name)); // Create an HTTP client we can use to download packages let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); diff --git a/crates/rattler/src/install/test_utils.rs b/crates/rattler/src/install/test_utils.rs index 2b8fb2ca4..4a2a17786 100644 --- a/crates/rattler/src/install/test_utils.rs +++ b/crates/rattler/src/install/test_utils.rs @@ -7,7 +7,7 @@ use transaction::{Transaction, TransactionOperation}; use crate::{ install::{transaction, unlink_package, InstallDriver, InstallOptions}, - package_cache::SingletonPackageCache, + package_cache::PackageCache, }; /// Install a package into the environment and write a `conda-meta` file that @@ -69,7 +69,7 @@ pub async fn install_package_to_environment( pub async fn execute_operation( target_prefix: &Path, download_client: &reqwest_middleware::ClientWithMiddleware, - package_cache: &SingletonPackageCache, + package_cache: &PackageCache, install_driver: &InstallDriver, op: TransactionOperation, install_options: &InstallOptions, @@ -121,7 +121,7 @@ pub async fn execute_transaction( transaction: Transaction, target_prefix: &Path, download_client: &reqwest_middleware::ClientWithMiddleware, - package_cache: &SingletonPackageCache, + package_cache: &PackageCache, install_driver: &InstallDriver, install_options: &InstallOptions, ) { diff --git a/crates/rattler_repodata_gateway/src/gateway/builder.rs b/crates/rattler_repodata_gateway/src/gateway/builder.rs index b90dfd61d..fc79dc85e 100644 --- a/crates/rattler_repodata_gateway/src/gateway/builder.rs +++ b/crates/rattler_repodata_gateway/src/gateway/builder.rs @@ -1,7 +1,7 @@ use crate::gateway::GatewayInner; use crate::{ChannelConfig, Gateway}; use dashmap::DashMap; -use rattler_cache::package_cache::SingletonPackageCache; +use rattler_cache::package_cache::PackageCache; use reqwest::Client; use reqwest_middleware::ClientWithMiddleware; use std::path::PathBuf; @@ -13,7 +13,7 @@ pub struct GatewayBuilder { channel_config: ChannelConfig, client: Option, cache: Option, - package_cache: Option, + package_cache: Option, max_concurrent_requests: Option, } @@ -57,7 +57,7 @@ impl GatewayBuilder { } /// Add package cache to the builder to store packages. - pub fn with_package_cache(mut self, package_cache: SingletonPackageCache) -> Self { + pub fn with_package_cache(mut self, package_cache: PackageCache) -> Self { self.set_package_cache(package_cache); self } @@ -69,7 +69,7 @@ impl GatewayBuilder { } /// Set the directory to use for caching packages. - pub fn set_package_cache(&mut self, package_cache: SingletonPackageCache) -> &mut Self { + pub fn set_package_cache(&mut self, package_cache: PackageCache) -> &mut Self { self.package_cache = Some(package_cache); self } @@ -99,7 +99,7 @@ impl GatewayBuilder { .join("rattler/cache") }); - let package_cache = self.package_cache.unwrap_or(SingletonPackageCache::new( + let package_cache = self.package_cache.unwrap_or(PackageCache::new_singleton( cache.join(rattler_cache::PACKAGE_CACHE_DIR), )); diff --git a/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs b/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs index 267d92732..7bbaf6382 100644 --- a/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs +++ b/crates/rattler_repodata_gateway/src/gateway/direct_url_query.rs @@ -1,7 +1,7 @@ use std::{future::IntoFuture, sync::Arc}; use futures::FutureExt; -use rattler_cache::package_cache::{CacheKey, PackageCacheError}; +use rattler_cache::package_cache::{CacheKey, PackageCache, PackageCacheError}; use rattler_conda_types::{ package::{ArchiveIdentifier, IndexJson, PackageFile}, ConvertSubdirError, PackageRecord, RepoDataRecord, @@ -17,7 +17,7 @@ pub(crate) struct DirectUrlQuery { /// The client to use for fetching the package client: reqwest_middleware::ClientWithMiddleware, /// The cache to use for storing the package - package_cache: SingletonPackageCache, + package_cache: PackageCache, } #[derive(Debug, thiserror::Error)] @@ -35,7 +35,7 @@ pub enum DirectUrlQueryError { impl DirectUrlQuery { pub(crate) fn new( url: Url, - package_cache: SingletonPackageCache, + package_cache: PackageCache, client: reqwest_middleware::ClientWithMiddleware, sha256: Option, ) -> Self { @@ -110,7 +110,7 @@ impl IntoFuture for DirectUrlQuery { mod test { use std::{env::temp_dir, path::PathBuf}; - use rattler_cache::package_cache::SingletonPackageCache; + use rattler_cache::package_cache::PackageCache; use url::Url; use super::*; @@ -121,7 +121,7 @@ mod test { "https://conda.anaconda.org/conda-forge/noarch/boltons-24.0.0-pyhd8ed1ab_0.conda", ) .unwrap(); - let package_cache = SingletonPackageCache::new(PathBuf::from("/tmp")); + let package_cache = PackageCache::new_singleton(PathBuf::from("/tmp")); let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); let query = DirectUrlQuery::new(url.clone(), package_cache, client, None); @@ -163,7 +163,7 @@ mod test { .unwrap(); let url = Url::from_file_path(package_path).unwrap(); - let package_cache = SingletonPackageCache::new(temp_dir()); + let package_cache = PackageCache::new_singleton(temp_dir()); let client = reqwest_middleware::ClientWithMiddleware::from(reqwest::Client::new()); let query = DirectUrlQuery::new(url.clone(), package_cache, client, None); diff --git a/crates/rattler_repodata_gateway/src/gateway/mod.rs b/crates/rattler_repodata_gateway/src/gateway/mod.rs index 2fb2eb31f..e914ecbbd 100644 --- a/crates/rattler_repodata_gateway/src/gateway/mod.rs +++ b/crates/rattler_repodata_gateway/src/gateway/mod.rs @@ -24,7 +24,7 @@ pub use error::GatewayError; use file_url::url_to_path; use local_subdir::LocalSubdirClient; pub use query::{NamesQuery, RepoDataQuery}; -use rattler_cache::package_cache::SingletonPackageCache; +use rattler_cache::package_cache::PackageCache; use rattler_conda_types::{Channel, MatchSpec, Platform}; pub use repo_data::RepoData; use reqwest_middleware::ClientWithMiddleware; @@ -161,7 +161,7 @@ struct GatewayInner { cache: PathBuf, /// The package cache, stored to reuse memory cache - package_cache: SingletonPackageCache, + package_cache: PackageCache, /// A semaphore to limit the number of concurrent requests. concurrent_requests_semaphore: Arc, @@ -362,7 +362,7 @@ mod test { use dashmap::DashSet; use rattler_cache::default_cache_dir; - use rattler_cache::package_cache::SingletonPackageCache; + use rattler_cache::package_cache::PackageCache; use rattler_conda_types::{ Channel, ChannelConfig, MatchSpec, PackageName, ParseStrictness::Lenient, ParseStrictness::Strict, Platform, RepoDataRecord, @@ -433,7 +433,7 @@ mod test { #[tokio::test] async fn test_direct_url_spec_from_gateway() { let gateway = Gateway::builder() - .with_package_cache(SingletonPackageCache::new( + .with_package_cache(PackageCache::new_singleton( default_cache_dir() .unwrap() .join(rattler_cache::PACKAGE_CACHE_DIR), @@ -494,7 +494,7 @@ mod test { #[tokio::test] async fn test_select_forced_url_instead_of_deps() { let gateway = Gateway::builder() - .with_package_cache(SingletonPackageCache::new( + .with_package_cache(PackageCache::new_singleton( default_cache_dir() .unwrap() .join(rattler_cache::PACKAGE_CACHE_DIR), From 857f5cc2b328e37f4ce301177e7e8419f7428574 Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 15:16:23 +0800 Subject: [PATCH 4/7] Make get_inner private --- crates/rattler_cache/src/package_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler_cache/src/package_cache.rs b/crates/rattler_cache/src/package_cache.rs index d168889c4..0c3ac35cb 100644 --- a/crates/rattler_cache/src/package_cache.rs +++ b/crates/rattler_cache/src/package_cache.rs @@ -144,7 +144,7 @@ impl PackageCache { } } - pub fn get_inner(&self) -> Arc> { + fn get_inner(&self) -> Arc> { match self { Self::SingletonPackageCache { inner } => inner.clone(), } From 8050a12abbe33a6a012cbc1ea39be4baf232722c Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 15:41:52 +0800 Subject: [PATCH 5/7] Make PackageCacheInner public --- crates/rattler_cache/src/package_cache.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rattler_cache/src/package_cache.rs b/crates/rattler_cache/src/package_cache.rs index 0c3ac35cb..ab61daef7 100644 --- a/crates/rattler_cache/src/package_cache.rs +++ b/crates/rattler_cache/src/package_cache.rs @@ -114,7 +114,7 @@ impl Display for CacheKey { } #[derive(Default)] -struct PackageCacheInner { +pub struct PackageCacheInner { path: PathBuf, packages: FxHashMap>>, } From cfa69d6ac65f13048a3e5e7db0c223d8ab9f76a6 Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 15:46:14 +0800 Subject: [PATCH 6/7] Add docs --- crates/rattler_cache/src/package_cache.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rattler_cache/src/package_cache.rs b/crates/rattler_cache/src/package_cache.rs index ab61daef7..afe2bd342 100644 --- a/crates/rattler_cache/src/package_cache.rs +++ b/crates/rattler_cache/src/package_cache.rs @@ -48,6 +48,7 @@ pub trait CacheReporter: Send + Sync { /// separates the corners between caching and fetching of the content. #[derive(Clone)] pub enum PackageCache { + /// A package cache which reads/writes from only one directory. SingletonPackageCache { inner: Arc>, }, From 32aaf6626ee22de28e643e49a805e71a5102700d Mon Sep 17 00:00:00 2001 From: Kelvin Ou Date: Tue, 3 Sep 2024 15:46:26 +0800 Subject: [PATCH 7/7] Fix py-rattler bindings --- py-rattler/src/installer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py-rattler/src/installer.rs b/py-rattler/src/installer.rs index 86c6026f5..0edf87c49 100644 --- a/py-rattler/src/installer.rs +++ b/py-rattler/src/installer.rs @@ -59,7 +59,7 @@ pub fn py_install<'a>( } if let Some(cache_dir) = cache_dir { - installer.set_package_cache(PackageCache::new(cache_dir)); + installer.set_package_cache(PackageCache::new_singleton(cache_dir)); } if let Some(installed_packages) = installed_packages {