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