Commit 2ced75be authored by FliegendeWurst's avatar FliegendeWurst
Browse files

python312Packages.imgsize: fix build, misc. cleanup

parent 815c8411
Loading
Loading
Loading
Loading
+31 −5
Original line number Diff line number Diff line
@@ -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 ];
  };
}