From a616e864fc3207a9d6718507f12a63e12f4672e3 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Wed, 29 Oct 2025 09:18:40 +0100 Subject: [PATCH 1/3] add test for out-of-tree builds/rebuilds --- .env.ci | 1 + tests/integration_python/test_build.py | 71 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .env.ci diff --git a/.env.ci b/.env.ci new file mode 100644 index 0000000..99f159b --- /dev/null +++ b/.env.ci @@ -0,0 +1 @@ +PIXI_PR_NUMBER=4839 diff --git a/tests/integration_python/test_build.py b/tests/integration_python/test_build.py index 7531918..72f5de8 100644 --- a/tests/integration_python/test_build.py +++ b/tests/integration_python/test_build.py @@ -112,6 +112,77 @@ def test_source_change_trigger_rebuild(pixi: Path, simple_workspace: Workspace) assert conda_build_params.is_file() +def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspace) -> None: + """ + Test that if you have an out-of-tree build with a something like + + [package.build] + source = "some-dir" + That it rebuilds correctly when changed and does not rebuild when unchanged + """ + # Create an out-of-tree directory + out_of_tree_dir = simple_workspace.workspace_dir.joinpath("out_of_tree_source") + out_of_tree_dir.mkdir() + # Write out a file we will modify later on + external_file = out_of_tree_dir.joinpath("external.txt") + external_file.write_text("initial content", encoding="utf-8") + + # Change the build section + build_section = simple_workspace.package_manifest["package"]["build"] + build_section["source"] = {"path": "../out_of_tree_source"} + configuration = build_section.setdefault("configuration", {}) + # Add external glob for detection + configuration["extra-input-globs"] = ["external.txt"] + simple_workspace.recipe["source"] = {"path": "../out_of_tree_source"} + + simple_workspace.write_files() + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + simple_workspace.workspace_dir, + ], + ) + + conda_build_params = simple_workspace.debug_dir.joinpath("conda_outputs_params.json") + assert conda_build_params.is_file() + + # Remove debug file to detect subsequent rebuilds + conda_build_params.unlink() + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + simple_workspace.workspace_dir, + ], + ) + + # Out-of-tree sources should be cached when unchanged + assert not conda_build_params.exists() + + # Modifying the external source should trigger a rebuild + external_file.write_text("updated content", encoding="utf-8") + + verify_cli_command( + [ + pixi, + "install", + "-v", + "--manifest-path", + simple_workspace.workspace_dir, + ], + ) + + # And it should be back because the package has been rebuilt + assert conda_build_params.is_file() + + def test_project_model_change_trigger_rebuild( pixi: Path, simple_workspace: Workspace, dummy_channel_1: Path ) -> None: From c23966f1e7f231358c203326ef8fd7afb641f4c3 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 29 Oct 2025 14:11:18 +0100 Subject: [PATCH 2/3] Let codex put things into files --- .../out_of_tree_source/external.txt | 1 + .../out-of-tree-source/package/pixi.toml | 18 ++++++++ .../out-of-tree-source/package/recipe.yaml | 6 +++ .../pixi_build/out-of-tree-source/pixi.toml | 9 ++++ tests/integration_python/test_build.py | 43 ++++++++++--------- 5 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt create mode 100644 tests/data/pixi_build/out-of-tree-source/package/pixi.toml create mode 100644 tests/data/pixi_build/out-of-tree-source/package/recipe.yaml create mode 100644 tests/data/pixi_build/out-of-tree-source/pixi.toml diff --git a/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt b/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt new file mode 100644 index 0000000..f2376e2 --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/out_of_tree_source/external.txt @@ -0,0 +1 @@ +initial content diff --git a/tests/data/pixi_build/out-of-tree-source/package/pixi.toml b/tests/data/pixi_build/out-of-tree-source/package/pixi.toml new file mode 100644 index 0000000..b08034d --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/package/pixi.toml @@ -0,0 +1,18 @@ +[package] +name = "out-of-tree-source" +version = "1.0.0" + +[package.build] +source = { path = "../out_of_tree_source" } + +[package.build.backend] +channels = [ + "https://prefix.dev/pixi-build-backends", + "https://prefix.dev/conda-forge", +] +name = "pixi-build-rattler-build" +version = "*" + +[package.build.configuration] +debug-dir = "{debug_dir}" +extra-input-globs = ["external.txt"] diff --git a/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml b/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml new file mode 100644 index 0000000..6ca686c --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/package/recipe.yaml @@ -0,0 +1,6 @@ +package: + name: out-of-tree-source + version: 1.0.0 + +source: + path: ../out_of_tree_source diff --git a/tests/data/pixi_build/out-of-tree-source/pixi.toml b/tests/data/pixi_build/out-of-tree-source/pixi.toml new file mode 100644 index 0000000..02a5a7f --- /dev/null +++ b/tests/data/pixi_build/out-of-tree-source/pixi.toml @@ -0,0 +1,9 @@ +[workspace] +channels = ["https://prefix.dev/conda-forge"] +name = "out-of-tree-source" +platforms = ["linux-64", "osx-arm64", "win-64"] +preview = ["pixi-build"] +version = "1.0.0" + +[dependencies] +out-of-tree-source = { path = "package" } diff --git a/tests/integration_python/test_build.py b/tests/integration_python/test_build.py index 72f5de8..c663028 100644 --- a/tests/integration_python/test_build.py +++ b/tests/integration_python/test_build.py @@ -112,7 +112,9 @@ def test_source_change_trigger_rebuild(pixi: Path, simple_workspace: Workspace) assert conda_build_params.is_file() -def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspace) -> None: +def test_out_of_tree_source_respects_cache( + pixi: Path, build_data: Path, tmp_pixi_workspace: Path +) -> None: """ Test that if you have an out-of-tree build with a something like @@ -120,22 +122,22 @@ def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspa source = "some-dir" That it rebuilds correctly when changed and does not rebuild when unchanged """ - # Create an out-of-tree directory - out_of_tree_dir = simple_workspace.workspace_dir.joinpath("out_of_tree_source") - out_of_tree_dir.mkdir() - # Write out a file we will modify later on - external_file = out_of_tree_dir.joinpath("external.txt") - external_file.write_text("initial content", encoding="utf-8") - - # Change the build section - build_section = simple_workspace.package_manifest["package"]["build"] - build_section["source"] = {"path": "../out_of_tree_source"} - configuration = build_section.setdefault("configuration", {}) - # Add external glob for detection - configuration["extra-input-globs"] = ["external.txt"] - simple_workspace.recipe["source"] = {"path": "../out_of_tree_source"} + project = "out-of-tree-source" + test_data = build_data.joinpath(project) + target_dir = tmp_pixi_workspace.joinpath(project) + copytree_with_local_backend(test_data, target_dir) - simple_workspace.write_files() + manifest_path = target_dir.joinpath("pixi.toml") + package_manifest_path = target_dir.joinpath("package", "pixi.toml") + + package_manifest = tomllib.loads(package_manifest_path.read_text(encoding="utf-8")) + configuration = package_manifest["package"]["build"].setdefault("configuration", {}) + + debug_dir = target_dir.joinpath("debug_dir") + debug_dir.mkdir(parents=True, exist_ok=True) + configuration["debug-dir"] = str(debug_dir) + + package_manifest_path.write_text(tomli_w.dumps(package_manifest), encoding="utf-8") verify_cli_command( [ @@ -143,11 +145,11 @@ def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspa "install", "-v", "--manifest-path", - simple_workspace.workspace_dir, + manifest_path, ], ) - conda_build_params = simple_workspace.debug_dir.joinpath("conda_outputs_params.json") + conda_build_params = debug_dir.joinpath("conda_outputs_params.json") assert conda_build_params.is_file() # Remove debug file to detect subsequent rebuilds @@ -159,13 +161,14 @@ def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspa "install", "-v", "--manifest-path", - simple_workspace.workspace_dir, + manifest_path, ], ) # Out-of-tree sources should be cached when unchanged assert not conda_build_params.exists() + external_file = target_dir.joinpath("out_of_tree_source", "external.txt") # Modifying the external source should trigger a rebuild external_file.write_text("updated content", encoding="utf-8") @@ -175,7 +178,7 @@ def test_out_of_tree_source_respects_cache(pixi: Path, simple_workspace: Workspa "install", "-v", "--manifest-path", - simple_workspace.workspace_dir, + manifest_path, ], ) From e08143026e041cb02ad23976ab91f124ea397536 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra <4995967+baszalmstra@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:01:20 +0100 Subject: [PATCH 3/3] point to other pr --- .env.ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.ci b/.env.ci index 99f159b..88cb36b 100644 --- a/.env.ci +++ b/.env.ci @@ -1 +1 @@ -PIXI_PR_NUMBER=4839 +PIXI_PR_NUMBER=4875