Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: keep installed packages in environments #1119

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
25 changes: 23 additions & 2 deletions src/render/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ use futures::FutureExt;
use indicatif::{HumanBytes, ProgressBar, ProgressStyle};
use itertools::Itertools;
use rattler::install::{DefaultProgressFormatter, IndicatifReporter, Installer};
use rattler_conda_types::{Channel, MatchSpec, Platform, RepoDataRecord};
use rattler_conda_types::{Channel, 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, recipe::parser::GlobVec,
tool_configuration,
};

fn print_as_table(packages: &[RepoDataRecord]) {
let mut table = Table::new();
Expand Down Expand Up @@ -309,12 +312,30 @@ 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, &GlobVec::default(), &GlobVec::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
5 changes: 5 additions & 0 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ impl Output {
let span = tracing::info_span!("Fetching source code");
let _enter = span.enter();

// if the work directory already exists, we should remove it
if self.build_configuration.directories.work_dir.exists() {
fs::remove_dir_all(&self.build_configuration.directories.work_dir)?;
}

if let Some(finalized_sources) = &self.finalized_sources {
fetch_sources(
finalized_sources,
Expand Down
Loading