From a417a6919dbe5a3fe76080d67275f9413267de97 Mon Sep 17 00:00:00 2001 From: Hermenix Date: Sun, 11 Oct 2026 23:01:25 +0000 Subject: [PATCH] tests: find libjpeg-turbo by TURBOJPEG_PATH, not LD_LIBRARY_PATH The unit check failed with the library present: in nativeBuildInputs is a nix wrapper that sets LD_LIBRARY_PATH itself, so an export from the builder script is overwritten before the tests run. TURBOJPEG_PATH is read first by jpeg._load_library, no wrapper touches it, and the package's console scripts now set it too. --- checks/unit.nix | 6 ++++++ nix/package.nix | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/checks/unit.nix b/checks/unit.nix index 749d986..f5b91ac 100644 --- a/checks/unit.nix +++ b/checks/unit.nix @@ -71,7 +71,13 @@ runCommand "hhstream-unit" # library -- and it needs the *loader* to find it, because the encoder reaches # it through `ctypes` and nothing links it. Same reason nix/package.nix wraps # the console scripts with this path. + # + # `TURBOJPEG_PATH` decides, not `LD_LIBRARY_PATH`: the `pytest` in + # `nativeBuildInputs` is a nix wrapper that sets `LD_LIBRARY_PATH` itself, so + # exporting it here had no effect and the suite failed with the library plainly + # present on the machine. `jpeg._load_library` reads this variable first. export LD_LIBRARY_PATH=${libjpeg_turbo}/lib + export TURBOJPEG_PATH=${libjpeg_turbo}/lib/libturbojpeg.so export PYTHONDONTWRITEBYTECODE=1 export HOME=$PWD python3 -c 'import hhstream; print("testing hhstream", hhstream.__version__, "from", hhstream.__file__)' diff --git a/nix/package.nix b/nix/package.nix index 0d049ec..117ce53 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -31,8 +31,14 @@ python3.pkgs.buildPythonApplication { # LD_LIBRARY_PATH. The wrapper is what makes `ctypes.util.find_library` succeed # inside the unit -- and it is the same library grim already links, so the # frames stay byte-compatible with the existing stream. + # + # Both variables, deliberately. `LD_LIBRARY_PATH` is the conventional one, but + # a nix Python wrapper sets that variable *itself* -- which is how the unit + # check failed with the library plainly present -- so `TURBOJPEG_PATH` is the + # one that actually decides, and `jpeg._load_library` checks it first. makeWrapperArgs = [ "--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libjpeg_turbo ]}" + "--set TURBOJPEG_PATH ${libjpeg_turbo}/lib/libturbojpeg.so" ]; # Unit tests are wired up in the flake's `checks` so they can run without