1{
2 lib,
3 buildPythonPackage,
4 fetchPypi,
5 pythonOlder,
6 stdenv,
7 substituteAll,
8
9 # build-system
10 hatchling,
11
12 # native dependencies
13 xorg,
14
15 # tests
16 lsof,
17 pillow,
18 pytest-cov-stub,
19 pytest,
20 pyvirtualdisplay,
21 xvfb-run,
22}:
23
24buildPythonPackage rec {
25 pname = "mss";
26 version = "10.0.0";
27 pyproject = true;
28
29 disabled = pythonOlder "3.6";
30
31 src = fetchPypi {
32 inherit pname version;
33 hash = "sha256-2QPg1RJivw+HgoQc8W6qbX4+HxLq41q0HC4xiDfGY38=";
34 };
35
36 patches = lib.optionals stdenv.hostPlatform.isLinux [
37 (substituteAll {
38 src = ./linux-paths.patch;
39 x11 = "${xorg.libX11}/lib/libX11.so";
40 xfixes = "${xorg.libXfixes}/lib/libXfixes.so";
41 xrandr = "${xorg.libXrandr}/lib/libXrandr.so";
42 })
43 ];
44
45 build-system = [ hatchling ];
46
47 doCheck = stdenv.hostPlatform.isLinux;
48
49 nativeCheckInputs = [
50 lsof
51 pillow
52 pytest-cov-stub
53 pytest
54 pyvirtualdisplay
55 xvfb-run
56 ];
57
58 checkPhase = ''
59 runHook preCheck
60 xvfb-run pytest -k "not test_grab_with_tuple and not test_grab_with_tuple_percents and not test_resource_leaks"
61 runHook postCheck
62 '';
63
64 pythonImportsCheck = [ "mss" ];
65
66 meta = with lib; {
67 description = "Cross-platform multiple screenshots module";
68 mainProgram = "mss";
69 homepage = "https://github.com/BoboTiG/python-mss";
70 changelog = "https://github.com/BoboTiG/python-mss/blob/v${version}/CHANGELOG.md";
71 license = licenses.mit;
72 maintainers = with maintainers; [ austinbutler ];
73 };
74}