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