1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools-scm,
6 bottle,
7 importlib-resources,
8 proxy-tools,
9 pygobject3,
10 pyqtwebengine,
11 pytest,
12 pythonOlder,
13 qt5,
14 qtpy,
15 six,
16 xvfb-run,
17}:
18
19buildPythonPackage rec {
20 pname = "pywebview";
21 version = "5.4";
22 pyproject = true;
23
24 disabled = pythonOlder "3.5";
25
26 src = fetchFromGitHub {
27 owner = "r0x0r";
28 repo = "pywebview";
29 tag = version;
30 hash = "sha256-HQ95tg1BuOr+SyOEDCbIc6Xm2dzzWS0mMcnV4bHMNBs=";
31 };
32
33 nativeBuildInputs = [
34 setuptools-scm
35 qt5.wrapQtAppsHook
36 ];
37
38 propagatedBuildInputs = [
39 bottle
40 pyqtwebengine
41 proxy-tools
42 six
43 ]
44 ++ lib.optionals (pythonOlder "3.7") [ importlib-resources ];
45
46 nativeCheckInputs = [
47 pygobject3
48 pytest
49 qtpy
50 xvfb-run
51 ];
52
53 checkPhase = ''
54 # a Qt wrapper is required to run the Qt backend
55 # since the upstream script does not have a way to disable tests individually pytest is used directly instead
56 makeQtWrapper "$(command -v pytest)" tests/run.sh \
57 --set PYWEBVIEW_LOG debug \
58 --add-flags "--deselect tests/test_js_api.py::test_concurrent"
59
60 # HOME and XDG directories are required for the tests
61 env \
62 HOME=$TMPDIR \
63 XDG_RUNTIME_DIR=$TMPDIR/xdg-runtime-dir \
64 xvfb-run -s '-screen 0 800x600x24' tests/run.sh
65 '';
66
67 pythonImportsCheck = [ "webview" ];
68
69 meta = with lib; {
70 description = "Lightweight cross-platform wrapper around a webview";
71 homepage = "https://github.com/r0x0r/pywebview";
72 license = licenses.bsd3;
73 maintainers = with maintainers; [ jojosch ];
74 };
75}