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.3.2";
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-/jKauq+G3Nz91n/keTZGNDTaW5EhdyCx4c2Nylxqc+0=";
31 };
32
33 nativeBuildInputs = [
34 setuptools-scm
35 qt5.wrapQtAppsHook
36 ];
37
38 propagatedBuildInputs = [
39 bottle
40 pyqtwebengine
41 proxy-tools
42 six
43 ] ++ lib.optionals (pythonOlder "3.7") [ importlib-resources ];
44
45 nativeCheckInputs = [
46 pygobject3
47 pytest
48 qtpy
49 xvfb-run
50 ];
51
52 checkPhase = ''
53 # a Qt wrapper is required to run the Qt backend
54 # since the upstream script does not have a way to disable tests individually pytest is used directly instead
55 makeQtWrapper "$(command -v pytest)" tests/run.sh \
56 --set PYWEBVIEW_LOG debug \
57 --add-flags "--deselect tests/test_js_api.py::test_concurrent"
58
59 # HOME and XDG directories are required for the tests
60 env \
61 HOME=$TMPDIR \
62 XDG_RUNTIME_DIR=$TMPDIR/xdg-runtime-dir \
63 xvfb-run -s '-screen 0 800x600x24' tests/run.sh
64 '';
65
66 pythonImportsCheck = [ "webview" ];
67
68 meta = with lib; {
69 description = "Lightweight cross-platform wrapper around a webview";
70 homepage = "https://github.com/r0x0r/pywebview";
71 license = licenses.bsd3;
72 maintainers = with maintainers; [ jojosch ];
73 };
74}