From 2ced75bec1431c984f1d1b58ccd08a183c66a032 Mon Sep 17 00:00:00 2001 From: FliegendeWurst Date: Sat, 1 Feb 2025 09:19:00 +0100 Subject: [PATCH] python312Packages.imgsize: fix build, misc. cleanup --- .../python-modules/imgsize/default.nix | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/pkgs/development/python-modules/imgsize/default.nix b/pkgs/development/python-modules/imgsize/default.nix index 140472e7c043..66eb4fd5b7b6 100644 --- a/pkgs/development/python-modules/imgsize/default.nix +++ b/pkgs/development/python-modules/imgsize/default.nix @@ -2,24 +2,50 @@ lib, buildPythonPackage, fetchFromGitHub, + pytestCheckHook, + pythonOlder, + rustPlatform, }: buildPythonPackage rec { pname = "imgsize"; version = "3.0.1"; - format = "setuptools"; + pyproject = true; + + disabled = pythonOlder "3.10"; src = fetchFromGitHub { owner = "ojii"; - repo = pname; + repo = "imgsize"; tag = version; sha256 = "sha256-i0YCt5jTnDAxnaxKSTloWrQn27yLAvZnghZlCgwZh0Q="; }; - meta = with lib; { + cargoDeps = rustPlatform.fetchCargoVendor { + inherit pname version src; + hash = "sha256-V/24lqMVTCw+9YMZQ7ABXnA0tzX8IQNxHtmNkHRbXbU="; + }; + + nativeBuildInputs = [ + rustPlatform.cargoSetupHook + rustPlatform.maturinBuildHook + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + # remove useless dev setup in conftest.py + preCheck = '' + substituteInPlace python-tests/conftest.py \ + --replace-fail 'assert sys.prefix != sys.base_prefix, "must be in virtualenv"' "" \ + --replace-fail 'check_call(' "# " + ''; + + meta = { description = "Pure Python image size library"; homepage = "https://github.com/ojii/imgsize"; - license = with licenses; [ bsd3 ]; - maintainers = with maintainers; [ twey ]; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ twey ]; }; }