1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 pythonOlder,
7 rustPlatform,
8}:
9
10buildPythonPackage rec {
11 pname = "imgsize";
12 version = "3.0.3";
13 pyproject = true;
14
15 disabled = pythonOlder "3.10";
16
17 src = fetchFromGitHub {
18 owner = "ojii";
19 repo = "imgsize";
20 tag = version;
21 sha256 = "sha256-jpEgAqMcQHR5S6EH9mNxrG0+bCyxYFs2P4NxaZxxk/E=";
22 };
23
24 cargoDeps = rustPlatform.fetchCargoVendor {
25 inherit pname version src;
26 hash = "sha256-VgC0tp/X3T9K2ssdoUuBxsWZfe16rMRr2qXfwWsBXHM=";
27 };
28
29 nativeBuildInputs = [
30 rustPlatform.cargoSetupHook
31 rustPlatform.maturinBuildHook
32 ];
33
34 nativeCheckInputs = [
35 pytestCheckHook
36 ];
37
38 # remove useless dev setup in conftest.py
39 preCheck = ''
40 substituteInPlace python-tests/conftest.py \
41 --replace-fail 'assert sys.prefix != sys.base_prefix, "must be in virtualenv"' "" \
42 --replace-fail 'check_call(' "# "
43 '';
44
45 meta = {
46 description = "Pure Python image size library";
47 homepage = "https://github.com/ojii/imgsize";
48 license = lib.licenses.bsd3;
49 maintainers = with lib.maintainers; [ twey ];
50 };
51}