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
1 change: 1 addition & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PIXI_PR_NUMBER=4875
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
initial content
18 changes: 18 additions & 0 deletions tests/data/pixi_build/out-of-tree-source/package/pixi.toml
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 6 additions & 0 deletions tests/data/pixi_build/out-of-tree-source/package/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package:
name: out-of-tree-source
version: 1.0.0

source:
path: ../out_of_tree_source
9 changes: 9 additions & 0 deletions tests/data/pixi_build/out-of-tree-source/pixi.toml
Original file line number Diff line number Diff line change
@@ -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" }
74 changes: 74 additions & 0 deletions tests/integration_python/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,80 @@ 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, build_data: Path, tmp_pixi_workspace: Path
) -> 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
"""
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)

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(
[
pixi,
"install",
"-v",
"--manifest-path",
manifest_path,
],
)

conda_build_params = 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",
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")

verify_cli_command(
[
pixi,
"install",
"-v",
"--manifest-path",
manifest_path,
],
)

# 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:
Expand Down
Loading