Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rattler-bin/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub async fn create(opt: Opt) -> miette::Result<()> {
gateway
.query(
channels,
[install_platform, Platform::NoArch],
[install_platform.clone(), Platform::NoArch],
specs.clone(),
)
.recursive(true),
Expand Down
4 changes: 2 additions & 2 deletions crates/rattler/src/install/installer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl Installer {
desired_records.iter(),
self.reinstall_packages.as_ref(),
self.ignored_packages.as_ref(),
target_platform,
target_platform.clone(),
)?;
// If transaction is non-empty, we need full prefix records for file operations
// Reload them and reconstruct the transaction with full records
Expand All @@ -407,7 +407,7 @@ impl Installer {
desired_records.iter(),
self.reinstall_packages.as_ref(),
self.ignored_packages.as_ref(),
target_platform,
target_platform.clone(),
)?;
}

Expand Down
21 changes: 13 additions & 8 deletions crates/rattler/src/install/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ pub async fn link_package(
let package_dir = package_dir.to_owned();
let target_dir = target_dir.to_owned();
let target_prefix = target_prefix.clone();
let platform_clone = platform.clone();

let install_future = async move {
let _permit = driver.acquire_io_permit().await;
Expand All @@ -415,7 +416,7 @@ pub async fn link_package(
allow_symbolic_links && !cloned_entry.no_link,
allow_hard_links && !cloned_entry.no_link,
allow_ref_links && !cloned_entry.no_link,
platform,
platform_clone,
options.apple_codesign_behavior,
)
})
Expand Down Expand Up @@ -482,22 +483,24 @@ pub async fn link_package(
// 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.
let is_windows = platform.is_windows();
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 platform_clone = platform.clone();

let entry_point_fut = async move {
// Acquire an IO permit
let _permit = driver.acquire_io_permit().await;

let entries = if platform.is_windows() {
let entries = if platform_clone.is_windows() {
match create_windows_python_entry_point(
&target_dir,
&target_prefix,
&entry_point,
&python_info,
&platform,
&platform_clone,
) {
Ok([a, b]) => vec![
(number_of_paths_entries, a),
Expand All @@ -521,7 +524,7 @@ pub async fn link_package(
};

pending_futures.push(entry_point_fut.boxed());
number_of_paths_entries += if platform.is_windows() { 2 } else { 1 };
number_of_paths_entries += if is_windows { 2 } else { 1 };
}
}

Expand Down Expand Up @@ -810,6 +813,7 @@ pub fn link_package_sync(
// Link the individual files in parallel
let link_target_prefix = target_prefix.clone();
let package_dir = package_dir.to_path_buf();
let platform_clone = platform.clone();
let mut paths = paths_by_directory
.into_values()
.collect_vec()
Expand All @@ -832,7 +836,7 @@ pub fn link_package_sync(
allow_symbolic_links && !entry.no_link,
allow_hard_links && !entry.no_link,
allow_ref_links && !entry.no_link,
platform,
platform_clone.clone(),
options.apple_codesign_behavior,
);

Expand Down Expand Up @@ -900,7 +904,8 @@ pub fn link_package_sync(
// 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.
let mut entry_point_paths = if platform.is_windows() {
let is_windows = platform.is_windows();
let mut entry_point_paths = if is_windows {
entry_points
.into_iter()
// .into_par_iter()
Expand Down Expand Up @@ -1200,7 +1205,7 @@ mod test {

assert_eq!(
env.platform,
Some(current_platform),
Some(current_platform.clone()),
"the platform for which the explicit lock file was created does not match the current platform"
);

Expand All @@ -1224,7 +1229,7 @@ mod test {
.default_environment()
.expect("no default environment in lock file");

let Some(packages) = lock_env.packages(current_platform) else {
let Some(packages) = lock_env.packages(current_platform.clone()) else {
panic!(
"the platform for which the explicit lock file was created does not match the current platform"
)
Expand Down
8 changes: 4 additions & 4 deletions crates/rattler/src/install/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ where
let desired_packages = desired.into_iter().collect::<Vec<_>>();

// Determine the python version used in the current situation.
let current_python_info = find_python_info(&current_packages, platform)?;
let desired_python_info = find_python_info(&desired_packages, platform)?;
let current_python_info = find_python_info(&current_packages, &platform)?;
let desired_python_info = find_python_info(&desired_packages, &platform)?;
let needs_python_relink = match (&current_python_info, &desired_python_info) {
(Some(current), Some(desired)) => desired.is_relink_required(current),
_ => false,
Expand Down Expand Up @@ -393,7 +393,7 @@ impl<New> Transaction<PrefixRecord, New> {
/// none of the packages refers to a Python installation.
fn find_python_info(
records: impl IntoIterator<Item = impl ContentComparable>,
platform: Platform,
platform: &Platform,
) -> Result<Option<PythonInfo>, PythonInfoError> {
records
.into_iter()
Expand All @@ -402,7 +402,7 @@ fn find_python_info(
PythonInfo::from_version(
record.version(),
record.python_site_packages_path(),
platform,
platform.clone(),
)
})
.map_or(Ok(None), |info| info.map(Some))
Expand Down
2 changes: 1 addition & 1 deletion crates/rattler_conda_types/src/channel/channel_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ChannelUrl {
}

/// Append the platform to the base url.
pub fn platform_url(&self, platform: Platform) -> Url {
pub fn platform_url(&self, platform: &Platform) -> Url {
self.0
.join(&format!("{}/", platform.as_str())) // trailing slash is important here as this signifies a directory
.expect("platform is a valid url fragment")
Expand Down
16 changes: 9 additions & 7 deletions crates/rattler_conda_types/src/channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ impl Channel {
}

/// Returns the Urls for the given platform
pub fn platform_url(&self, platform: Platform) -> Url {
pub fn platform_url(&self, platform: &Platform) -> Url {
self.base_url.platform_url(platform)
}

/// Returns the Urls for all the supported platforms of this package.
pub fn platforms_url(&self) -> Vec<(Platform, Url)> {
self.platforms_or_default()
.iter()
.map(|&platform| (platform, self.platform_url(platform)))
.map(|platform| (platform.clone(), self.platform_url(platform)))
.collect()
}

Expand Down Expand Up @@ -443,9 +443,11 @@ fn parse_platforms(channel: &str) -> Result<(Option<Vec<Platform>>, &str), Parse

/// Returns the default platforms. These are based on the platform this binary
/// was build for as well as platform agnostic platforms.
pub(crate) const fn default_platforms() -> &'static [Platform] {
const CURRENT_PLATFORMS: [Platform; 2] = [Platform::current(), Platform::NoArch];
&CURRENT_PLATFORMS
pub(crate) fn default_platforms() -> &'static [Platform] {
use std::sync::LazyLock;
static CURRENT_PLATFORMS: LazyLock<[Platform; 2]> =
LazyLock::new(|| [Platform::current(), Platform::NoArch]);
&*CURRENT_PLATFORMS
}

/// Returns the specified path as an absolute path
Expand Down Expand Up @@ -653,7 +655,7 @@ mod tests {
assert_eq!(channel.platforms, None);
assert_eq!(channel.name(), "http://localhost:1234/");

let noarch_url = channel.platform_url(Platform::NoArch);
let noarch_url = channel.platform_url(&Platform::NoArch);
assert_eq!(noarch_url.to_string(), "http://localhost:1234/noarch/");

assert!(matches!(
Expand All @@ -677,7 +679,7 @@ mod tests {
"https://conda.anaconda.org/conda-forge/".parse().unwrap()
);
assert_eq!(channel.name.as_deref(), Some("conda-forge"));
assert_eq!(channel.platforms, Some(vec![platform]));
assert_eq!(channel.platforms, Some(vec![platform.clone()]));

let channel = Channel::from_str(
format!("https://conda.anaconda.org/pkgs/main[{platform}]"),
Expand Down
Loading
Loading