summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pywebview/default.nix
blob: e6148c3a5b47046bf9e86f4cae23fc1f652e5d49 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{
  lib,
  buildPythonPackage,
  fetchFromGitHub,
  setuptools-scm,
  bottle,
  importlib-resources,
  proxy-tools,
  pygobject3,
  pyqtwebengine,
  pytest,
  pythonOlder,
  qt5,
  qtpy,
  six,
  xvfb-run,
}:

buildPythonPackage rec {
  pname = "pywebview";
  version = "5.3.2";
  pyproject = true;

  disabled = pythonOlder "3.5";

  src = fetchFromGitHub {
    owner = "r0x0r";
    repo = "pywebview";
    tag = version;
    hash = "sha256-/jKauq+G3Nz91n/keTZGNDTaW5EhdyCx4c2Nylxqc+0=";
  };

  nativeBuildInputs = [
    setuptools-scm
    qt5.wrapQtAppsHook
  ];

  propagatedBuildInputs = [
    bottle
    pyqtwebengine
    proxy-tools
    six
  ] ++ lib.optionals (pythonOlder "3.7") [ importlib-resources ];

  nativeCheckInputs = [
    pygobject3
    pytest
    qtpy
    xvfb-run
  ];

  checkPhase = ''
    # a Qt wrapper is required to run the Qt backend
    # since the upstream script does not have a way to disable tests individually pytest is used directly instead
    makeQtWrapper "$(command -v pytest)" tests/run.sh \
      --set PYWEBVIEW_LOG debug \
      --add-flags "--deselect tests/test_js_api.py::test_concurrent"

    # HOME and XDG directories are required for the tests
    env \
      HOME=$TMPDIR \
      XDG_RUNTIME_DIR=$TMPDIR/xdg-runtime-dir \
      xvfb-run -s '-screen 0 800x600x24' tests/run.sh
  '';

  pythonImportsCheck = [ "webview" ];

  meta = with lib; {
    description = "Lightweight cross-platform wrapper around a webview";
    homepage = "https://github.com/r0x0r/pywebview";
    license = licenses.bsd3;
    maintainers = with maintainers; [ jojosch ];
  };
}