python312Packages.{mss,pyvirtualdisplay}: modernize, enable tests on linux (#351482)
This commit is contained in:
@@ -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" ];
|
||||
|
||||
|
||||
@@ -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))
|
||||
@@ -1,16 +1,28 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
buildPythonPackage,
|
||||
fetchPypi,
|
||||
substituteAll,
|
||||
xorg,
|
||||
|
||||
# build-system
|
||||
setuptools,
|
||||
|
||||
# tests
|
||||
easyprocess,
|
||||
entrypoint2,
|
||||
pillow,
|
||||
psutil,
|
||||
pytest-xdist,
|
||||
pytestCheckHook,
|
||||
vncdo,
|
||||
}:
|
||||
|
||||
buildPythonPackage rec {
|
||||
pname = "pyvirtualdisplay";
|
||||
version = "3.0";
|
||||
format = "setuptools";
|
||||
|
||||
propagatedBuildInputs = [ easyprocess ];
|
||||
pyproject = true;
|
||||
|
||||
src = fetchPypi {
|
||||
pname = "PyVirtualDisplay";
|
||||
@@ -18,8 +30,30 @@ buildPythonPackage rec {
|
||||
hash = "sha256-CXVbw86263JfsH7KVCX0PyNY078I4A0qm3kqGu3RYVk=";
|
||||
};
|
||||
|
||||
# requires X server
|
||||
doCheck = false;
|
||||
patches = lib.optionals stdenv.isLinux [
|
||||
(substituteAll {
|
||||
src = ./paths.patch;
|
||||
xauth = lib.getExe xorg.xauth;
|
||||
xdpyinfo = lib.getExe xorg.xdpyinfo;
|
||||
})
|
||||
];
|
||||
|
||||
build-system = [ setuptools ];
|
||||
|
||||
doCheck = stdenv.isLinux;
|
||||
|
||||
nativeCheckInputs = [
|
||||
easyprocess
|
||||
entrypoint2
|
||||
pillow
|
||||
psutil
|
||||
pytest-xdist
|
||||
pytestCheckHook
|
||||
(vncdo.overridePythonAttrs { doCheck = false; })
|
||||
xorg.xorgserver
|
||||
xorg.xmessage
|
||||
xorg.xvfb
|
||||
];
|
||||
|
||||
meta = with lib; {
|
||||
description = "Python wrapper for Xvfb, Xephyr and Xvnc";
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
diff --git a/pyvirtualdisplay/abstractdisplay.py b/pyvirtualdisplay/abstractdisplay.py
|
||||
index dd93943..c694209 100644
|
||||
--- a/pyvirtualdisplay/abstractdisplay.py
|
||||
+++ b/pyvirtualdisplay/abstractdisplay.py
|
||||
@@ -242,7 +242,7 @@ class AbstractDisplay(object):
|
||||
|
||||
try:
|
||||
xdpyinfo = subprocess.Popen(
|
||||
- ["xdpyinfo"],
|
||||
+ ["@xdpyinfo@"],
|
||||
env=self._env(),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
diff --git a/pyvirtualdisplay/xauth.py b/pyvirtualdisplay/xauth.py
|
||||
index ce0f804..7734e21 100644
|
||||
--- a/pyvirtualdisplay/xauth.py
|
||||
+++ b/pyvirtualdisplay/xauth.py
|
||||
@@ -14,7 +14,7 @@ def is_installed():
|
||||
"""
|
||||
try:
|
||||
xauth = subprocess.Popen(
|
||||
- ["xauth", "-V"],
|
||||
+ ["@xauth@", "-V"],
|
||||
# env=self._env(),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
@@ -43,7 +43,7 @@ def call(*args):
|
||||
Call xauth with the given args.
|
||||
"""
|
||||
xauth = subprocess.Popen(
|
||||
- ["xauth"] + list(args),
|
||||
+ ["@xauth@"] + list(args),
|
||||
# env=self._env(),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
Reference in New Issue
Block a user