mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-15 17:34:04 +00:00
python312Packages.mss: modernize, test on linux
This commit is contained in:
parent
c00b953741
commit
00ea3170af
@ -3,12 +3,28 @@
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
pythonOlder,
|
||||
stdenv,
|
||||
substituteAll,
|
||||
|
||||
# build-system
|
||||
hatchling,
|
||||
|
||||
# native dependencies
|
||||
xorg,
|
||||
|
||||
# tests
|
||||
lsof,
|
||||
pillow,
|
||||
pytest-cov-stub,
|
||||
pytest,
|
||||
pyvirtualdisplay,
|
||||
xvfb-run,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "mss";
|
||||
version = "9.0.2";
|
||||
format = "setuptools";
|
||||
pyproject = true;
|
||||
|
||||
disabled = pythonOlder "3.6";
|
||||
|
||||
@ -17,13 +33,33 @@ buildPythonPackage rec {
|
||||
hash = "sha256-yWpOxzIk2n2yK8B+88+qGPi4aQDRhy4pETu87wCToh4=";
|
||||
};
|
||||
|
||||
prePatch = ''
|
||||
# By default it attempts to build Windows-only functionality
|
||||
rm src/mss/windows.py
|
||||
'';
|
||||
patches = lib.optionals stdenv.isLinux [
|
||||
(substituteAll {
|
||||
src = ./linux-paths.patch;
|
||||
x11 = "${xorg.libX11}/lib/libX11.so";
|
||||
xfixes = "${xorg.libXfixes}/lib/libXfixes.so";
|
||||
xrandr = "${xorg.libXrandr}/lib/libXrandr.so";
|
||||
})
|
||||
];
|
||||
|
||||
# Skipping tests due to most relying on DISPLAY being set
|
||||
doCheck = false;
|
||||
build-system = [ hatchling ];
|
||||
|
||||
doCheck = stdenv.isLinux;
|
||||
|
||||
nativeCheckInputs = [
|
||||
lsof
|
||||
pillow
|
||||
pytest-cov-stub
|
||||
pytest
|
||||
pyvirtualdisplay
|
||||
xvfb-run
|
||||
];
|
||||
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
xvfb-run pytest -k "not test_grab_with_tuple and not test_grab_with_tuple_percents and not test_resource_leaks"
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
pythonImportsCheck = [ "mss" ];
|
||||
|
||||
|
17
pkgs/development/python-modules/mss/linux-paths.patch
Normal file
17
pkgs/development/python-modules/mss/linux-paths.patch
Normal file
@ -0,0 +1,17 @@
|
||||
diff --git a/src/mss/linux.py b/src/mss/linux.py
|
||||
index 6dac52b..c90bd93 100644
|
||||
--- a/src/mss/linux.py
|
||||
+++ b/src/mss/linux.py
|
||||
@@ -185,9 +185,9 @@ class XWindowAttributes(Structure):
|
||||
|
||||
|
||||
_ERROR = {}
|
||||
-_X11 = find_library("X11")
|
||||
-_XFIXES = find_library("Xfixes")
|
||||
-_XRANDR = find_library("Xrandr")
|
||||
+_X11 = "@x11@"
|
||||
+_XFIXES = "@xfixes@"
|
||||
+_XRANDR = "@xrandr@"
|
||||
|
||||
|
||||
@CFUNCTYPE(c_int, POINTER(Display), POINTER(XErrorEvent))
|
Loading…
Reference in New Issue
Block a user