1{ lib
2, buildPythonPackage
3, fetchPypi
4, fetchpatch
5, xorg
6, cffi
7, pytestCheckHook
8}:
9
10buildPythonPackage rec {
11 version = "1.2.0";
12 pname = "xcffib";
13
14 src = fetchPypi {
15 inherit pname version;
16 hash = "sha256-8yMCFEf55zB40hu5KMSPTavq6z87N+gDxta5hzXoFIM=";
17 };
18
19 patches = [
20 (fetchpatch {
21 name = "remove-leftover-six-import.patch";
22 url = "https://github.com/tych0/xcffib/commit/8a488867d30464913706376ca3a9f4c98ca6c5cf.patch";
23 hash = "sha256-wEms0gC7tVqtmKMjjpH/34kdQ6HUV0h67bUGbgijlqw=";
24 })
25 ];
26
27 postPatch = ''
28 # Hardcode cairo library path
29 sed -e 's,ffi\.dlopen(,&"${xorg.libxcb.out}/lib/" + ,' -i xcffib/__init__.py
30 '';
31
32 propagatedBuildInputs = [ cffi ];
33
34 propagatedNativeBuildInputs = [ cffi ];
35
36 nativeCheckInputs = [
37 pytestCheckHook
38 xorg.xeyes
39 xorg.xorgserver
40 ];
41
42 preCheck = ''
43 # import from $out
44 rm -r xcffib
45 '';
46
47 pythonImportsCheck = [ "xcffib" ];
48
49 meta = with lib; {
50 description = "A drop in replacement for xpyb, an XCB python binding";
51 homepage = "https://github.com/tych0/xcffib";
52 license = licenses.asl20;
53 maintainers = with maintainers; [ kamilchm ];
54 };
55}