1{ stdenv
2, lib
3, buildPythonPackage
4, dataclasses
5, fetchFromGitHub
6, libX11
7, libXinerama
8, libXrandr
9, poetry-core
10, pytestCheckHook
11, pythonOlder
12}:
13
14buildPythonPackage rec {
15 pname = "screeninfo";
16 version = "0.8.1";
17 format = "pyproject";
18
19 disabled = pythonOlder "3.6";
20
21 src = fetchFromGitHub {
22 owner = "rr-";
23 repo = pname;
24 rev = "refs/tags/${version}";
25 hash = "sha256-TEy4wff0eRRkX98yK9054d33Tm6G6qWrd9Iv+ITcFmA=";
26 };
27
28 nativeBuildInputs = [
29 poetry-core
30 ];
31
32 propagatedBuildInputs = lib.optionals (pythonOlder "3.7") [
33 dataclasses
34 ];
35
36 postPatch = ''
37 substituteInPlace screeninfo/enumerators/xinerama.py \
38 --replace 'load_library("X11")' 'ctypes.cdll.LoadLibrary("${libX11}/lib/libX11.so")' \
39 --replace 'load_library("Xinerama")' 'ctypes.cdll.LoadLibrary("${libXinerama}/lib/libXinerama.so")'
40 substituteInPlace screeninfo/enumerators/xrandr.py \
41 --replace 'load_library("X11")' 'ctypes.cdll.LoadLibrary("${libX11}/lib/libX11.so")' \
42 --replace 'load_library("Xrandr")' 'ctypes.cdll.LoadLibrary("${libXrandr}/lib/libXrandr.so")'
43 '';
44
45 checkInputs = [
46 pytestCheckHook
47 ];
48
49 disabledTestPaths = [
50 # We don't have a screen
51 "tests/test_screeninfo.py"
52 ];
53
54 pythonImportsCheck = [ "screeninfo" ];
55
56 meta = with lib; {
57 broken = stdenv.isDarwin;
58 description = "Fetch location and size of physical screens";
59 homepage = "https://github.com/rr-/screeninfo";
60 license = licenses.mit;
61 maintainers = with maintainers; [ nickhu ];
62 };
63}