From e9120ab7773f8483ab41de5c48263db25665e984 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 1 Sep 2021 16:36:31 +0200 Subject: [PATCH] python3Packages.screeninfo: fix build --- .../python-modules/screeninfo/default.nix | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/pkgs/development/python-modules/screeninfo/default.nix b/pkgs/development/python-modules/screeninfo/default.nix index 887542130969..21b3f30e1323 100644 --- a/pkgs/development/python-modules/screeninfo/default.nix +++ b/pkgs/development/python-modules/screeninfo/default.nix @@ -1,36 +1,50 @@ -{ lib, buildPythonApplication, fetchPypi, isPy27, isPy36, dataclasses, libX11, libXinerama, libXrandr }: +{ lib +, buildPythonApplication +, dataclasses +, fetchPypi +, libX11 +, libXinerama +, libXrandr +, pytestCheckHook +, pythonOlder +}: buildPythonApplication rec { pname = "screeninfo"; version = "0.7"; - disabled = isPy27; # dataclasses isn't available for python2 + + disabled = pythonOlder "3.6"; src = fetchPypi { inherit pname version; sha256 = "12a97c3527e3544ac5dbd7c1204283e2653d655cbd15844c990a83b1b13ef500"; }; - # dataclasses is a compatibility shim for python 3.6 ONLY - patchPhase = if isPy36 then "" else '' - substituteInPlace setup.py \ - --replace "\"dataclasses\"," "" - '' + '' - 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\")" - ''; + propagatedBuildInputs = lib.optionals (pythonOlder "3.7") [ + dataclasses + ]; - propagatedBuildInputs = lib.optional isPy36 dataclasses; + buildInputs = [ + libX11 + libXinerama + libXrandr + ]; - buildInputs = [ libX11 libXinerama libXrandr]; + checkInputs = [ + pytestCheckHook + ]; + + disabledTestPaths = [ + # We don't have a screen + "screeninfo/test_screeninfo.py" + ]; + + pythonImportsCheck = [ "screeninfo" ]; meta = with lib; { description = "Fetch location and size of physical screens"; homepage = "https://github.com/rr-/screeninfo"; license = licenses.mit; - maintainers = [ maintainers.nickhu ]; + maintainers = with maintainers; [ nickhu ]; }; }