Skip to content

Commit

Permalink
feat(nix/package): run tests on pillow-jxl-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
xarvex committed Mar 8, 2025
1 parent 7afe414 commit 8572d2b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
9 changes: 7 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
let
python = pkgs.python312Packages;

pillow-jxl-plugin = python.callPackage ./nix/package/pillow-jxl-plugin.nix { };
pillow-jxl-plugin = python.callPackage ./nix/package/pillow-jxl-plugin.nix {
inherit (pkgs) cmake;
inherit pyexiv2;
inherit (pkgs) rustPlatform;
};
pyexiv2 = python.callPackage ./nix/package/pyexiv2.nix { inherit (pkgs) exiv2; };
vtf2img = python.callPackage ./nix/package/vtf2img.nix { };
in
rec {
Expand All @@ -44,7 +49,7 @@
};
tagstudio-jxl = tagstudio.override { withJXLSupport = true; };

inherit pillow-jxl-plugin vtf2img;
inherit pillow-jxl-plugin pyexiv2 vtf2img;
};

devShells = rec {
Expand Down
23 changes: 21 additions & 2 deletions nix/package/pillow-jxl-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
cmake,
fetchPypi,
lib,
numpy,
packaging,
pillow,
pyexiv2,
pytestCheckHook,
rustPlatform,
}:

buildPythonPackage rec {
pname = "pillow_jxl_plugin";
pname = "pillow-jxl-plugin";
version = "1.3.2";
pyproject = true;

src = fetchPypi {
inherit pname version;
pname = builtins.replaceStrings [ "-" ] [ "_" ] pname;
inherit version;
hash = "sha256-efBoek8yUFR+ArhS55lm9F2XhkZ7/I3GsScQEe8U/2I=";
};

Expand All @@ -29,6 +33,21 @@ buildPythonPackage rec {
rustPlatform.maturinBuildHook
];

nativeCheckInputs = [
numpy
pyexiv2
pytestCheckHook
];

# INFO: Working directory takes precedence in the Python path. Remove
# `pillow_jxl` to prevent it from being loaded during pytest, rather than the
# built module, as it includes a `pillow_jxl.pillow_jxl` .so that is imported.
# See: https://github.com/NixOS/nixpkgs/issues/255262
# See: https://github.com/NixOS/nixpkgs/pull/255471
preCheck = ''
rm -r pillow_jxl
'';

dontUseCmakeConfigure = true;

pythonImportsCheck = [ "pillow_jxl" ];
Expand Down
32 changes: 32 additions & 0 deletions nix/package/pyexiv2.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
autoPatchelfHook,
buildPythonPackage,
exiv2,
fetchFromGitHub,
lib,
}:

buildPythonPackage rec {
pname = "pyexiv2";
version = "2.15.3";

src = fetchFromGitHub {
owner = "LeoHsiao1";
repo = pname;
rev = "v${version}";
hash = "sha256-83bFMaoXncvhRJNcCgkkC7B29wR5pjuLO/EdkQdqxxo=";
};

nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [ exiv2.lib ];

pythonImportsCheck = [ "pyexiv2" ];

meta = {
description = "Read and write image metadata, including EXIF, IPTC, XMP, ICC Profile.";
homepage = "https://github.com/LeoHsiao1/pyexiv2";
license = lib.licenses.gpl3;
maintainers = with lib.maintainers; [ xarvex ];
platforms = with lib.platforms; darwin ++ linux ++ windows;
};
}

0 comments on commit 8572d2b

Please sign in to comment.