summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/screeninfo/default.nix
blob: fbdd13160345dbdc37da45bd2a4b650294bc1069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  stdenv,
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  libX11,
  libXinerama,
  libXrandr,
  poetry-core,
  pytestCheckHook,
}:

buildPythonPackage rec {
  pname = "screeninfo";
  version = "0.8.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "rr-";
    repo = "screeninfo";
    tag = version;
    hash = "sha256-TEy4wff0eRRkX98yK9054d33Tm6G6qWrd9Iv+ITcFmA=";
  };

  nativeBuildInputs = [ poetry-core ];

  postPatch = ''
    substituteInPlace screeninfo/enumerators/xinerama.py \
      --replace 'load_library("X11")' 'ctypes.cdll.LoadLibrary("${libX11}/lib/libX11.so")' \
      --replace 'load_library("Xinerama")' 'ctypes.cdll.LoadLibrary("${libXinerama}/lib/libXinerama.so")'
    substituteInPlace screeninfo/enumerators/xrandr.py \
      --replace 'load_library("X11")' 'ctypes.cdll.LoadLibrary("${libX11}/lib/libX11.so")' \
      --replace 'load_library("Xrandr")' 'ctypes.cdll.LoadLibrary("${libXrandr}/lib/libXrandr.so")'
  '';

  nativeCheckInputs = [ pytestCheckHook ];

  disabledTestPaths = [
    # We don't have a screen
    "tests/test_screeninfo.py"
  ];

  pythonImportsCheck = [ "screeninfo" ];

  meta = {
    broken = stdenv.hostPlatform.isDarwin;
    description = "Fetch location and size of physical screens";
    homepage = "https://github.com/rr-/screeninfo";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ nickhu ];
  };
}