From fad0b63482a7264fb2aab5130e7a9f5b7167ded8 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Wed, 2 Oct 2024 18:52:42 +0200 Subject: [PATCH] fix: actually install packages for `cache` (#1078) --- src/cache.rs | 8 +++++++- src/render/resolved_dependencies.rs | 13 ++++++------ test-data/recipes/cache/recipe-cmake.yaml | 25 +++++++++++++++++++++++ test/end-to-end/test_simple.py | 13 ++++++++++++ 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 test-data/recipes/cache/recipe-cmake.yaml diff --git a/src/cache.rs b/src/cache.rs index f5d8d473..e8ac3fe2 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -16,7 +16,9 @@ use crate::{ metadata::{build_reindexed_channels, Output}, packaging::{contains_prefix_binary, contains_prefix_text, content_type, Files}, recipe::parser::{Dependency, Requirements}, - render::resolved_dependencies::{resolve_dependencies, FinalizedDependencies}, + render::resolved_dependencies::{ + install_environments, resolve_dependencies, FinalizedDependencies, + }, source::copy_dir::{copy_file, create_symlink, CopyOptions}, }; @@ -178,6 +180,10 @@ impl Output { .await .unwrap(); + install_environments(self, &finalized_dependencies, tool_configuration) + .await + .into_diagnostic()?; + cache .build .script() diff --git a/src/render/resolved_dependencies.rs b/src/render/resolved_dependencies.rs index 0d1088f3..c2c978ba 100644 --- a/src/render/resolved_dependencies.rs +++ b/src/render/resolved_dependencies.rs @@ -608,13 +608,9 @@ async fn amend_run_exports( pub async fn install_environments( output: &Output, + dependencies: &FinalizedDependencies, tool_configuration: &tool_configuration::Configuration, ) -> Result<(), ResolveError> { - let dependencies = output - .finalized_dependencies - .as_ref() - .ok_or(ResolveError::FinalizedDependencyNotFound)?; - const EMPTY_RECORDS: Vec = Vec::new(); install_packages( "build", @@ -1007,7 +1003,12 @@ impl Output { &self, tool_configuration: &Configuration, ) -> Result<(), ResolveError> { - install_environments(self, tool_configuration).await + let dependencies = self + .finalized_dependencies + .as_ref() + .ok_or(ResolveError::FinalizedDependencyNotFound)?; + + install_environments(self, dependencies, tool_configuration).await } } diff --git a/test-data/recipes/cache/recipe-cmake.yaml b/test-data/recipes/cache/recipe-cmake.yaml new file mode 100644 index 00000000..d740ecd6 --- /dev/null +++ b/test-data/recipes/cache/recipe-cmake.yaml @@ -0,0 +1,25 @@ +context: + version: 0.1.0 + build_num: 0 + +recipe: + name: cache-installation + version: ${{ version }} + +build: + number: ${{ build_num }} + +cache: + requirements: + build: + - cmake + build: + script: + - cmake --version + +outputs: + - package: + name: check-1 + + - package: + name: check-2 diff --git a/test/end-to-end/test_simple.py b/test/end-to-end/test_simple.py index d3b3a5df..207342b0 100644 --- a/test/end-to-end/test_simple.py +++ b/test/end-to-end/test_simple.py @@ -956,3 +956,16 @@ def test_used_vars(rattler_build: RattlerBuild, recipes: Path, tmp_path: Path): assert rendered[0]["build_configuration"]["variant"] == { "target_platform": "noarch" } + + +def test_cache_install( + rattler_build: RattlerBuild, recipes: Path, tmp_path: Path, snapshot_json +): + rattler_build.build( + recipes / "cache/recipe-cmake.yaml", tmp_path, extra_args=["--experimental"] + ) + + pkg1 = get_extracted_package(tmp_path, "check-1") + pkg2 = get_extracted_package(tmp_path, "check-2") + assert (pkg1 / "info/index.json").exists() + assert (pkg2 / "info/index.json").exists() \ No newline at end of file