Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into new-variant-resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 9, 2024
2 parents 3285cd9 + b3f6bd2 commit 5d75af2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/variants.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ package:
build:
string: ${{ blas_variant }}${{ hash }}_${{ build_number }}
variant_config:
variant:
# make sure that `openblas` is preferred over `mkl`
down_prioritize_variant: ${{ 1 if blas_variant == "mkl" else 0 }}
```
Expand Down
2 changes: 1 addition & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub async fn run_build(
output
.build_configuration
.directories
.create_build_dir()
.create_build_dir(true)
.into_diagnostic()?;

let span = tracing::info_span!("Running build for", recipe = output.identifier());
Expand Down
11 changes: 8 additions & 3 deletions src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ impl Directories {
}

/// Creates the build directory.
pub fn create_build_dir(&self) -> Result<(), std::io::Error> {
fs::create_dir_all(self.build_dir.join("work"))?;
pub fn create_build_dir(&self, remove_existing_work_dir: bool) -> Result<(), std::io::Error> {
if remove_existing_work_dir && self.work_dir.exists() {
fs::remove_dir_all(&self.work_dir)?;
}

fs::create_dir_all(&self.work_dir)?;

Ok(())
}

Expand Down Expand Up @@ -787,7 +792,7 @@ mod test {
&chrono::Utc::now(),
)
.unwrap();
directories.create_build_dir().unwrap();
directories.create_build_dir(false).unwrap();

// test yaml roundtrip
let yaml = serde_yaml::to_string(&directories).unwrap();
Expand Down
24 changes: 22 additions & 2 deletions src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use futures::FutureExt;
use indicatif::{HumanBytes, ProgressBar, ProgressStyle};
use itertools::Itertools;
use rattler::install::{DefaultProgressFormatter, IndicatifReporter, Installer};
use rattler_conda_types::{Channel, ChannelUrl, MatchSpec, Platform, RepoDataRecord};
use rattler_conda_types::{Channel, ChannelUrl, MatchSpec, Platform, PrefixRecord, RepoDataRecord};
use rattler_solve::{resolvo::Solver, ChannelPriority, SolveStrategy, SolverImpl, SolverTask};
use url::Url;

use crate::{metadata::PlatformWithVirtualPackages, tool_configuration};
use crate::{metadata::PlatformWithVirtualPackages, packaging::Files, tool_configuration};

fn print_as_table(packages: &[RepoDataRecord]) {
let mut table = Table::new();
Expand Down Expand Up @@ -311,12 +311,32 @@ pub async fn install_packages(
)
})?;

let installed_packages = PrefixRecord::collect_from_prefix(target_prefix)?;

if !installed_packages.is_empty() && name.starts_with("host") {
// we have to clean up extra files in the prefix
let extra_files =
Files::from_prefix(target_prefix, &Default::default(), &Default::default())?;

tracing::info!(
"Cleaning up {} files in the prefix from a previous build.",
extra_files.new_files.len()
);

for f in extra_files.new_files {
if !f.is_dir() {
fs_err::remove_file(target_prefix.join(f))?;
}
}
}

tracing::info!("\nInstalling {name} environment\n");
Installer::new()
.with_download_client(tool_configuration.client.clone())
.with_target_platform(target_platform)
.with_execute_link_scripts(true)
.with_package_cache(tool_configuration.package_cache.clone())
.with_installed_packages(installed_packages)
.with_reporter(
IndicatifReporter::builder()
.with_multi_progress(
Expand Down
2 changes: 1 addition & 1 deletion src/tool_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub fn reqwest_client_from_auth_storage(
.no_gzip()
.pool_max_idle_per_host(20)
.user_agent(APP_USER_AGENT)
.timeout(std::time::Duration::from_secs(timeout))
.read_timeout(std::time::Duration::from_secs(timeout))
.build()
.expect("failed to create client"),
)
Expand Down

0 comments on commit 5d75af2

Please sign in to comment.