1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, setuptools-scm
5, bottle
6, importlib-resources
7, proxy-tools
8, pygobject3
9, pyqtwebengine
10, pytest
11, pythonOlder
12, qt5
13, qtpy
14, six
15, xvfb-run
16}:
17
18buildPythonPackage rec {
19 pname = "pywebview";
20 version = "4.3.3";
21 pyproject = true;
22
23 disabled = pythonOlder "3.5";
24
25 src = fetchFromGitHub {
26 owner = "r0x0r";
27 repo = "pywebview";
28 rev = "refs/tags/${version}";
29 hash = "sha256-8BkbO7C8cYDIQWWCKaXFjfD45L5KVG1tDZJl+uW5g9g=";
30 };
31
32 nativeBuildInputs = [
33 setuptools-scm
34 qt5.wrapQtAppsHook
35 ];
36
37 propagatedBuildInputs = [
38 bottle
39 pyqtwebengine
40 proxy-tools
41 six
42 ] ++ lib.optionals (pythonOlder "3.7") [
43 importlib-resources
44 ];
45
46 nativeCheckInputs = [
47 pygobject3
48 pytest
49 qtpy
50 xvfb-run
51 ];
52
53 env.SETUPTOOLS_SCM_PRETEND_VERSION = version;
54
55 checkPhase = ''
56 # Cannot create directory /homeless-shelter/.... Error: FILE_ERROR_ACCESS_DENIED
57 export HOME=$TMPDIR
58 # QStandardPaths: XDG_RUNTIME_DIR not set
59 export XDG_RUNTIME_DIR=$HOME/xdg-runtime-dir
60
61 pushd tests
62 substituteInPlace run.sh \
63 --replace "PYTHONPATH=.." "PYTHONPATH=$PYTHONPATH" \
64 --replace "pywebviewtest test_js_api.py::test_concurrent ''${PYTEST_OPTIONS}" "# skip flaky test_js_api.py::test_concurrent"
65
66 patchShebangs run.sh
67 wrapQtApp run.sh
68
69 xvfb-run -s '-screen 0 800x600x24' ./run.sh
70 popd
71 '';
72
73 pythonImportsCheck = [
74 "webview"
75 ];
76
77 meta = with lib; {
78 description = "Lightweight cross-platform wrapper around a webview";
79 homepage = "https://github.com/r0x0r/pywebview";
80 license = licenses.bsd3;
81 maintainers = with maintainers; [ jojosch ];
82 };
83}