From 20985f8985d810092a84f31a705144b9318235dd Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Tue, 14 May 2024 11:18:58 -0400 Subject: Test that llama-cpp is buildable This small Llamacpp.py file is simply intended to test that llama.cpp can build. This was previously not working, I guess, because the build system doesn't verify that the final executable has its dependencies set properly in $PATH. Not sure if it *should* do that verification or not. Anyway, I rewrote this to actually test if it could call `llama`, and it could not, because the Python builder needed the rundeps in its propagatedBuildInputs. That alone makes `llama` available to the final artifact, but the test still failed. This is because the wrapPythonPrograms function from nixpkgs (which adds stuff to PATH) is called in postFixup, which happens after installPhase, but checkPhase happens before installPhase. So I was testing a program that didn't have PATH set yet. Moving the test to installCheck fixed this because it runs after the postFixup phase. I opted to keep the lint/typecheck stuff in the checkPhase because they don't need any external dependencies, and having those fail earlier is probably better? Maybe doesn't make a huge difference time-wise but it kinda makes the intention clearer to be separate, in checkPhase you are checking the code itself, in installCheck you are including the installation environment as well. --- Biz/Bild/Builder.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Biz/Bild') diff --git a/Biz/Bild/Builder.nix b/Biz/Bild/Builder.nix index cf4d1e0..df5aeba 100644 --- a/Biz/Bild/Builder.nix +++ b/Biz/Bild/Builder.nix @@ -7,6 +7,15 @@ with bild; let analysis = builtins.fromJSON analysisJSON; + + # common bash functions for the builder + commonBash = builtins.toFile "common.bash" '' + # Check that a command succeeds, fail and log if not. + function check { + $@ || { echo "fail: $name: $3"; exit 1; } + } + ''; + build = _: target: let name = target.out; @@ -107,13 +116,12 @@ let python = python.buildPythonApplication rec { inherit name src CODEROOT; - propagatedBuildInputs = langdeps_ ++ sysdeps_; + nativeBuildInputs = [ makeWrapper ]; + propagatedBuildInputs = langdeps_ ++ sysdeps_ ++ rundeps_; buildInputs = sysdeps_; nativeCheckInputs = [ pkgs.ruff python.packages.mypy ]; checkPhase = '' - check() { - $@ || { echo "fail: $name: $3"; exit 1; } - } + . ${commonBash} cp ${../../pyproject.toml} ./pyproject.toml check ruff format --exclude 'setup.py' --check . check ruff check --exclude 'setup.py' --exclude '__init__.py' . @@ -123,6 +131,9 @@ let --no-error-summary \ --exclude 'setup\.py$' \ . + ''; + installCheck = '' + . ${commonBash} check python -m ${mainModule} test ''; preBuild = '' -- cgit v1.2.3