about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyqtwebengine/default.nix
blob: e8b1da7fdc871331725f8f6ca83cef1ed91acc34 (plain) (blame)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
  lib,
  stdenv,
  pythonPackages,
  fetchPypi,
  pkg-config,
  qmake,
  qtbase,
  qtsvg,
  qtwebengine,
  qtwebchannel,
  qtdeclarative,
  wrapQtAppsHook,
  darwin,
  buildPackages,
}:

let
  inherit (pythonPackages)
    buildPythonPackage
    python
    isPy27
    pyqt5
    sip
    pyqt-builder
    ;
  inherit (darwin) autoSignDarwinBinariesHook;
in
buildPythonPackage (
  rec {
    pname = "pyqtwebengine";
    version = "5.15.6";
    format = "pyproject";

    disabled = isPy27;

    src = fetchPypi {
      pname = "PyQtWebEngine";
      inherit version;
      hash = "sha256-riQe8qYceCk5xYtSwq6lOtmbMPOTTINY1eCm67P9ByE=";
    };

    postPatch = ''
      substituteInPlace pyproject.toml \
        --replace "[tool.sip.project]" "[tool.sip.project]''\nsip-include-dirs = [\"${pyqt5}/${python.sitePackages}/PyQt5/bindings\"]"
    '';

    outputs = [
      "out"
      "dev"
    ];

    nativeBuildInputs =
      [
        pkg-config
        qmake
      ]
      ++ lib.optionals (stdenv.buildPlatform == stdenv.hostPlatform) [ sip ]
      ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
        python.pythonOnBuildForHost.pkgs.sip
      ]
      ++ [
        qtbase
        qtsvg
        qtwebengine
        pyqt-builder
        pythonPackages.setuptools
      ]
      ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ qtdeclarative ]
      ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook ];

    buildInputs =
      [
        sip
        qtbase
        qtsvg
        qtwebengine
      ]
      ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
        qtwebchannel
        qtdeclarative
      ];

    propagatedBuildInputs = [ pyqt5 ];

    dontWrapQtApps = true;

    # Avoid running qmake, which is in nativeBuildInputs
    dontConfigure = true;

    # Checked using pythonImportsCheck
    doCheck = false;

    pythonImportsCheck = [
      "PyQt5.QtWebEngine"
      "PyQt5.QtWebEngineWidgets"
    ];

    enableParallelBuilding = true;

    passthru = {
      inherit wrapQtAppsHook;
    };

    meta = with lib; {
      description = "Python bindings for Qt5";
      homepage = "http://www.riverbankcomputing.co.uk";
      license = licenses.gpl3;
      hydraPlatforms = lib.lists.intersectLists qtwebengine.meta.platforms platforms.mesaPlatforms;
    };
  }
  // lib.optionalAttrs (stdenv.buildPlatform != stdenv.hostPlatform) {
    # TODO: figure out why the env hooks aren't adding these inclusions automatically
    env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " [
      "-I${lib.getDev qtbase}/include/QtPrintSupport/"
      "-I${lib.getDev qtwebchannel}/include/QtWebChannel/"
    ];
  }
)