From 55e0de19bd8622899514327e408b6e1f99ba182f Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Mon, 18 Aug 2025 14:15:09 +0200 Subject: [PATCH 01/10] tests(global): add tests for recursive source deps --- .../pixi_build/multi-output-simple/pixi.toml | 6 -- .../multi-output-simple/recipe.yaml | 34 ---------- .../package_a/pyproject.toml | 3 + .../package_a/src/package_a/__init__.py | 4 ++ tests/integration_python/test_global.py | 63 +++++++++++++++---- 5 files changed, 57 insertions(+), 53 deletions(-) delete mode 100644 tests/data/pixi_build/multi-output-simple/pixi.toml delete mode 100644 tests/data/pixi_build/multi-output-simple/recipe.yaml diff --git a/tests/data/pixi_build/multi-output-simple/pixi.toml b/tests/data/pixi_build/multi-output-simple/pixi.toml deleted file mode 100644 index ecdad24..0000000 --- a/tests/data/pixi_build/multi-output-simple/pixi.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "multi-output" -version = "0.1.0" - -[package.build] -backend = { name = "pixi-build-rattler-build", version = "*" } diff --git a/tests/data/pixi_build/multi-output-simple/recipe.yaml b/tests/data/pixi_build/multi-output-simple/recipe.yaml deleted file mode 100644 index 06bf2c2..0000000 --- a/tests/data/pixi_build/multi-output-simple/recipe.yaml +++ /dev/null @@ -1,34 +0,0 @@ -recipe: - name: multi-output - version: "0.1.0" - -outputs: - - package: - name: foobar - build: - script: - - if: win - then: - - mkdir -p %PREFIX%\bin - - echo @echo off > %PREFIX%\bin\foobar.bat - - echo echo Hello from foobar >> %PREFIX%\bin\foobar.bat - else: - - mkdir -p $PREFIX/bin - - echo "#!/usr/bin/env bash" > $PREFIX/bin/foobar - - echo "echo Hello from foobar" >> $PREFIX/bin/foobar - - chmod +x $PREFIX/bin/foobar - - - package: - name: bizbar - build: - script: - - if: win - then: - - mkdir -p %PREFIX%\bin - - echo @echo off > %PREFIX%\bin\bizbar.bat - - echo echo Hello from bizbar >> %PREFIX%\bin\bizbar.bat - else: - - mkdir -p $PREFIX/bin - - echo "#!/usr/bin/env bash" > $PREFIX/bin/bizbar - - echo "echo Hello from bizbar" >> $PREFIX/bin/bizbar - - chmod +x $PREFIX/bin/bizbar diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_a/pyproject.toml b/tests/data/pixi_build/recursive_source_run_dep/package_a/pyproject.toml index e3b5d5c..9fbce2a 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_a/pyproject.toml +++ b/tests/data/pixi_build/recursive_source_run_dep/package_a/pyproject.toml @@ -8,3 +8,6 @@ version = "0.1.0" [build-system] build-backend = "hatchling.build" requires = ["hatchling"] + +[project.scripts] +package-a = "package_a:main" diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py b/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py index 7157d8a..45e2992 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py +++ b/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py @@ -1,2 +1,6 @@ +import subprocess + + def main() -> None: print("Pixi Build is number 1") + subprocess.run("package-b", check=True) diff --git a/tests/integration_python/test_global.py b/tests/integration_python/test_global.py index d9e274b..6f42d2f 100644 --- a/tests/integration_python/test_global.py +++ b/tests/integration_python/test_global.py @@ -20,7 +20,6 @@ def test_install_path_dependency( pixi: Path, tmp_path: Path, build_data: Path, package_name: str | None, relative: bool ) -> None: """Test installing a pixi project from a git repository.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} @@ -102,7 +101,6 @@ def test_install_git_repository( package_name: str | None, ) -> None: """Test installing a pixi project from a git repository.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} @@ -129,7 +127,6 @@ def test_add_git_repository_to_existing_environment( pixi: Path, tmp_path: Path, build_data: Path, dummy_channel_1: Path ) -> None: """Test adding a git-based source package to an existing global environment.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} @@ -178,7 +175,6 @@ def test_add_git_repository_to_existing_environment( def test_update(pixi: Path, tmp_path: Path, build_data: Path) -> None: """Test that pixi global update works with path dependencies.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} @@ -228,12 +224,11 @@ def test_install_multi_output_failing( build_data: Path, ) -> None: """Test installing a pixi project from a git repository.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} # Specify the project - source_project = build_data.joinpath("multi-output-simple") + source_project = build_data.joinpath("multi-output", "recipe") # Test install without any specs mentioned # It should tell you which outputs are available @@ -251,19 +246,20 @@ def test_install_multi_output_single( build_data: Path, ) -> None: """Test installing a pixi project from a git repository.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} # Specify the project - source_project = build_data.joinpath("multi-output-simple") + source_project = build_data.joinpath("multi-output", "recipe") # Test install and explicitly requesting `foobar` - verify_cli_command([pixi, "global", "install", "--path", source_project, "foobar"], env=env) + verify_cli_command( + [pixi, "global", "install", "--path", source_project, "foobar-desktop"], env=env + ) # Check that the package was installed - foobar = pixi_home / "bin" / exec_extension("foobar") - verify_cli_command([foobar], env=env, stdout_contains="Hello from foobar") + foobar_desktop = pixi_home / "bin" / exec_extension("foobar") + verify_cli_command([foobar_desktop], env=env, stdout_contains="Hello from foobar-desktop") def test_install_multi_output_multiple( @@ -272,12 +268,11 @@ def test_install_multi_output_multiple( build_data: Path, ) -> None: """Test installing a pixi project from a git repository.""" - # Make it one level deeper so that we do no pollute git with the global pixi_home = tmp_path / "pixi_home" env = {"PIXI_HOME": str(pixi_home)} # Specify the project - source_project = build_data.joinpath("multi-output-simple") + source_project = build_data.joinpath("multi-output", "recipe") # Test install and explicitly requesting `foobar` and `bizbar` verify_cli_command( @@ -289,3 +284,45 @@ def test_install_multi_output_multiple( bizbar = pixi_home / "bin" / exec_extension("bizbar") verify_cli_command([foobar], env=env, stdout_contains="Hello from foobar") verify_cli_command([bizbar], env=env, stdout_contains="Hello from bizbar") + + +def test_install_recursive_source_run_dependencies( + pixi: Path, + tmp_path: Path, + build_data: Path, +) -> None: + pixi_home = tmp_path / "pixi_home" + env = {"PIXI_HOME": str(pixi_home)} + + # Specify the project + source_project = build_data.joinpath("recursive_source_run_dep", "package_a") + + verify_cli_command([pixi, "global", "install", "--path", source_project], env=env) + + # Check that package_a is exposed and works + package_a = pixi_home / "bin" / exec_extension("package-a") + verify_cli_command( + [package_a], env=env, stdout_contains=["Pixi Build is number 1", "hello from package-b"] + ) + + # Check that package_b is not exposed + package_b = pixi_home / "bin" / exec_extension("package_b") + assert not package_b.is_file() + + +def test_install_recursive_source_build_dependencies( + pixi: Path, + tmp_path: Path, + build_data: Path, +) -> None: + pixi_home = tmp_path / "pixi_home" + env = {"PIXI_HOME": str(pixi_home)} + + # Specify the project + source_project = build_data.joinpath("recursive_source_build_dep", "package_a") + + verify_cli_command([pixi, "global", "install", "--path", source_project], env=env) + + # Check that package_a is exposed and works + package_a = pixi_home / "bin" / exec_extension("package-a") + verify_cli_command([package_a], env=env, stdout_contains=["5 + 3 = 8"]) From 54dc99488ea60b92f9f431bda1e2fd84088817e0 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Mon, 18 Aug 2025 14:18:32 +0200 Subject: [PATCH 02/10] Remove unused recipe --- .../data/pixi_build/multi-output/recipe.yaml | 34 ------------------- 1 file changed, 34 deletions(-) delete mode 100644 tests/data/pixi_build/multi-output/recipe.yaml diff --git a/tests/data/pixi_build/multi-output/recipe.yaml b/tests/data/pixi_build/multi-output/recipe.yaml deleted file mode 100644 index 06bf2c2..0000000 --- a/tests/data/pixi_build/multi-output/recipe.yaml +++ /dev/null @@ -1,34 +0,0 @@ -recipe: - name: multi-output - version: "0.1.0" - -outputs: - - package: - name: foobar - build: - script: - - if: win - then: - - mkdir -p %PREFIX%\bin - - echo @echo off > %PREFIX%\bin\foobar.bat - - echo echo Hello from foobar >> %PREFIX%\bin\foobar.bat - else: - - mkdir -p $PREFIX/bin - - echo "#!/usr/bin/env bash" > $PREFIX/bin/foobar - - echo "echo Hello from foobar" >> $PREFIX/bin/foobar - - chmod +x $PREFIX/bin/foobar - - - package: - name: bizbar - build: - script: - - if: win - then: - - mkdir -p %PREFIX%\bin - - echo @echo off > %PREFIX%\bin\bizbar.bat - - echo echo Hello from bizbar >> %PREFIX%\bin\bizbar.bat - else: - - mkdir -p $PREFIX/bin - - echo "#!/usr/bin/env bash" > $PREFIX/bin/bizbar - - echo "echo Hello from bizbar" >> $PREFIX/bin/bizbar - - chmod +x $PREFIX/bin/bizbar From 2653c611f7755263e7356961c42d22d2ce3a9592 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Mon, 18 Aug 2025 14:29:56 +0200 Subject: [PATCH 03/10] xfail one of the tests --- tests/integration_python/test_global.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/integration_python/test_global.py b/tests/integration_python/test_global.py index 6f42d2f..dfd602c 100644 --- a/tests/integration_python/test_global.py +++ b/tests/integration_python/test_global.py @@ -240,6 +240,9 @@ def test_install_multi_output_failing( ) +@pytest.mark.xfail( + reason="multi output recipes where one package depends on another doesn't work yet with pixi global" +) def test_install_multi_output_single( pixi: Path, tmp_path: Path, @@ -247,7 +250,9 @@ def test_install_multi_output_single( ) -> None: """Test installing a pixi project from a git repository.""" pixi_home = tmp_path / "pixi_home" - env = {"PIXI_HOME": str(pixi_home)} + env = { + "PIXI_HOME": str(pixi_home), + } # Specify the project source_project = build_data.joinpath("multi-output", "recipe") From 27da6789adf376c4bb658e1cc9429fa35d5e42a1 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Mon, 18 Aug 2025 16:35:21 +0200 Subject: [PATCH 04/10] Add verbose output --- tests/integration_python/test_global.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_python/test_global.py b/tests/integration_python/test_global.py index dfd602c..3a22db5 100644 --- a/tests/integration_python/test_global.py +++ b/tests/integration_python/test_global.py @@ -302,7 +302,7 @@ def test_install_recursive_source_run_dependencies( # Specify the project source_project = build_data.joinpath("recursive_source_run_dep", "package_a") - verify_cli_command([pixi, "global", "install", "--path", source_project], env=env) + verify_cli_command([pixi, "global", "install", "-vvv", "--path", source_project], env=env) # Check that package_a is exposed and works package_a = pixi_home / "bin" / exec_extension("package-a") From 4059643621e9a0ae4378e681657d8e8f71ac8a2a Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Mon, 18 Aug 2025 16:40:45 +0200 Subject: [PATCH 05/10] Remove verbose flags again --- tests/integration_python/test_global.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_python/test_global.py b/tests/integration_python/test_global.py index 3a22db5..dfd602c 100644 --- a/tests/integration_python/test_global.py +++ b/tests/integration_python/test_global.py @@ -302,7 +302,7 @@ def test_install_recursive_source_run_dependencies( # Specify the project source_project = build_data.joinpath("recursive_source_run_dep", "package_a") - verify_cli_command([pixi, "global", "install", "-vvv", "--path", source_project], env=env) + verify_cli_command([pixi, "global", "install", "--path", source_project], env=env) # Check that package_a is exposed and works package_a = pixi_home / "bin" / exec_extension("package-a") From 3ebe82b1ff0e0b188fb35fb394a051ccd6a25b0e Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 20 Aug 2025 14:06:27 +0200 Subject: [PATCH 06/10] Try to use forward slashes --- .../recursive_source_run_dep/package_b/recipe.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml index 4ad4c0e..c7cb92f 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml +++ b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml @@ -7,9 +7,9 @@ build: script: - if: win then: - - mkdir %PREFIX%\bin - - echo @echo off > %PREFIX%\bin\package-b.bat - - echo echo hello from package-b >> %PREFIX%\bin\package-b.bat + - mkdir %PREFIX%/bin + - echo @echo off > %PREFIX%/bin/package-b.bat + - echo echo hello from package-b >> %PREFIX%/bin/package-b.bat else: - mkdir -p $PREFIX/bin - echo "#!/usr/bin/env bash" > $PREFIX/bin/package-b From 60742ecdb944a2271bf3ca72f7c3ea43a41edd97 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 20 Aug 2025 14:11:53 +0200 Subject: [PATCH 07/10] Try to backlashes --- .../recursive_source_run_dep/package_b/recipe.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml index c7cb92f..77add15 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml +++ b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml @@ -7,9 +7,9 @@ build: script: - if: win then: - - mkdir %PREFIX%/bin - - echo @echo off > %PREFIX%/bin/package-b.bat - - echo echo hello from package-b >> %PREFIX%/bin/package-b.bat + - mkdir %PREFIX%\\bin + - echo @echo off > %PREFIX%\\bin\\package-b.bat + - echo echo hello from package-b >> %PREFIX%\\bin\\package-b.bat else: - mkdir -p $PREFIX/bin - echo "#!/usr/bin/env bash" > $PREFIX/bin/package-b From c094699cf75e472773c694a2f8916219d4423cd7 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 20 Aug 2025 14:15:51 +0200 Subject: [PATCH 08/10] Go back to backslashes --- .../recursive_source_run_dep/package_b/recipe.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml index 77add15..4ad4c0e 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml +++ b/tests/data/pixi_build/recursive_source_run_dep/package_b/recipe.yaml @@ -7,9 +7,9 @@ build: script: - if: win then: - - mkdir %PREFIX%\\bin - - echo @echo off > %PREFIX%\\bin\\package-b.bat - - echo echo hello from package-b >> %PREFIX%\\bin\\package-b.bat + - mkdir %PREFIX%\bin + - echo @echo off > %PREFIX%\bin\package-b.bat + - echo echo hello from package-b >> %PREFIX%\bin\package-b.bat else: - mkdir -p $PREFIX/bin - echo "#!/usr/bin/env bash" > $PREFIX/bin/package-b From d87050b63f4255fd7baa956fb6d9474497f65b52 Mon Sep 17 00:00:00 2001 From: Julian Hofer Date: Wed, 20 Aug 2025 15:50:44 +0200 Subject: [PATCH 09/10] Fix assert --- tests/integration_python/test_global.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_python/test_global.py b/tests/integration_python/test_global.py index dfd602c..a683446 100644 --- a/tests/integration_python/test_global.py +++ b/tests/integration_python/test_global.py @@ -311,7 +311,7 @@ def test_install_recursive_source_run_dependencies( ) # Check that package_b is not exposed - package_b = pixi_home / "bin" / exec_extension("package_b") + package_b = pixi_home / "bin" / exec_extension("package-b") assert not package_b.is_file() From 4db397ab2fe9b1c94f463cfe4f7bfc7ed62ddb49 Mon Sep 17 00:00:00 2001 From: Ruben Arts Date: Wed, 20 Aug 2025 16:03:25 +0200 Subject: [PATCH 10/10] fix: windows uses shell=true to run the package-b.bat --- .../package_a/src/package_a/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py b/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py index 45e2992..f10f884 100644 --- a/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py +++ b/tests/data/pixi_build/recursive_source_run_dep/package_a/src/package_a/__init__.py @@ -1,6 +1,5 @@ import subprocess - def main() -> None: print("Pixi Build is number 1") - subprocess.run("package-b", check=True) + subprocess.run("package-b", check=True, shell=True)