python313Packages.i3ipc: fix build, refactor (#438729)

dotlambda a3887e95 455c77bf

Changed files
+79 -28
pkgs
development
python-modules
+51 -28
pkgs/development/python-modules/i3ipc/default.nix
···
lib,
buildPythonPackage,
fetchFromGitHub,
-
xorg,
-
pytest,
+
coreutils,
+
setuptools,
+
xlib,
+
fontconfig,
+
pytestCheckHook,
+
writableTmpDirAsHomeHook,
+
pytest-asyncio,
+
pytest-timeout,
pytest-xvfb,
i3,
-
xlib,
-
xdpyinfo,
-
makeFontsConf,
-
coreutils,
+
xorg,
}:
buildPythonPackage rec {
pname = "i3ipc";
version = "2.2.1";
-
format = "setuptools";
+
pyproject = true;
src = fetchFromGitHub {
-
owner = "acrisci";
+
owner = "altdesktop";
repo = "i3ipc-python";
-
rev = "v${version}";
-
sha256 = "13bzs9dcv27czpnnbgz7a037lm8h991c8gk0qzzk5mq5yak24715";
+
tag = "v${version}";
+
hash = "sha256-JRwipvIF1zL/x2A+xEJKEFV6BlDnv2Xt/eyIzVrSf40=";
};
-
propagatedBuildInputs = [ xlib ];
+
+
patches = [
+
# Upstream expects a very old version of pytest-asyncio. This patch correctly
+
# decorates async fixtures using pytest-asyncio and configures `loop_scope`
+
# where needed.
+
./fix-async-tests.patch
+
];
+
+
postPatch = ''
+
substituteInPlace test/i3.config \
+
--replace-fail /bin/true ${coreutils}/bin/true
+
'';
+
+
build-system = [ setuptools ];
+
dependencies = [ xlib ];
+
+
# Fontconfig error: Cannot load default config file
+
env.FONTCONFIG_FILE = "${fontconfig.out}/etc/fonts/fonts.conf";
-
fontsConf = makeFontsConf { fontDirectories = [ ]; };
-
FONTCONFIG_FILE = fontsConf; # Fontconfig error: Cannot load default config file
nativeCheckInputs = [
-
pytest
-
xdpyinfo
+
pytestCheckHook
+
writableTmpDirAsHomeHook
+
pytest-asyncio
+
pytest-timeout
pytest-xvfb
+
i3
+
xorg.xdpyinfo
xorg.xvfb
-
i3
];
-
postPatch = ''
-
substituteInPlace test/i3.config \
-
--replace /bin/true ${coreutils}/bin/true
-
'';
+
disabledTestPaths = [
+
# Timeout
+
"test/test_shutdown_event.py::TestShutdownEvent::test_shutdown_event_reconnect"
+
"test/aio/test_shutdown_event.py::TestShutdownEvent::test_shutdown_event_reconnect"
+
# Flaky
+
"test/test_window.py::TestWindow::test_detailed_window_event"
+
"test/aio/test_workspace.py::TestWorkspace::test_workspace"
+
];
-
checkPhase = ''
-
py.test --ignore=test/aio/test_shutdown_event.py \
-
--ignore=test/test_shutdown_event.py
-
'';
+
pythonImportsCheck = [ "i3ipc" ];
-
meta = with lib; {
+
meta = {
description = "Improved Python library to control i3wm and sway";
-
homepage = "https://github.com/acrisci/i3ipc-python";
-
license = licenses.bsd3;
-
maintainers = with maintainers; [ vanzef ];
+
homepage = "https://github.com/altdesktop/i3ipc-python";
+
changelog = "https://github.com/altdesktop/i3ipc-python/releases/tag/${src.tag}";
+
license = lib.licenses.bsd3;
+
maintainers = with lib.maintainers; [ vanzef ];
};
}
+28
pkgs/development/python-modules/i3ipc/fix-async-tests.patch
···
+
diff --git a/test/aio/ipctest.py b/test/aio/ipctest.py
+
index 88e4cda..3d0fd9c 100644
+
--- a/test/aio/ipctest.py
+
+++ b/test/aio/ipctest.py
+
@@ -1,5 +1,6 @@
+
from subprocess import Popen
+
import pytest
+
+import pytest_asyncio
+
+
from i3ipc.aio import Connection
+
from i3ipc import CommandReply
+
@@ -19,7 +20,7 @@ class IpcTest:
+
def event_loop(self):
+
return asyncio.get_event_loop()
+
+
- @pytest.fixture(scope='class')
+
+ @pytest_asyncio.fixture(scope='class', loop_scope='class')
+
async def i3(self):
+
process = Popen(['i3', '-c', 'test/i3.config'])
+
# wait for i3 to start up
+
diff --git a/pytest.ini b/pytest.ini
+
index 1ea6b80..788bdac 100644
+
--- a/pytest.ini
+
+++ b/pytest.ini
+
@@ -1,2 +1,3 @@
+
[pytest]
+
timeout = 5
+
+asyncio_default_test_loop_scope = class