about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pyqtwebengine/default.nix
blob: 3c0ae904557ac450d8182424ac56fe3b77ae4e6c (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
{ lib, pythonPackages, pkgconfig
, qmake, qtbase, qtsvg, qtwebengine
, wrapQtAppsHook
}:

let

  inherit (pythonPackages) buildPythonPackage python isPy3k pyqt5 enum34;
  inherit (pyqt5) sip;

in buildPythonPackage rec {
  pname = "PyQtWebEngine";
  version = "5.14.0";
  format = "other";

  src = pythonPackages.fetchPypi {
    inherit pname version;
    sha256 = "14hw49akb35n9pgiw564x8ykmsifihn9p2ax2x4zmywb3w2ra5g1";
  };

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [
    pkgconfig
    qmake
    sip
    qtbase
    qtsvg
    qtwebengine
  ];

  buildInputs = [
    sip
    qtbase
    qtsvg
    qtwebengine
  ];

  propagatedBuildInputs = [ pyqt5 ]
    ++ lib.optional (!isPy3k) enum34;

  configurePhase = ''
    runHook preConfigure

    mkdir -p "$out/share/sip/PyQt5"

    # FIXME: Without --no-dist-info, I get
    #     unable to create /nix/store/yv4pzx3lxk3lscq0pw3hqzs7k4x76xsm-python3-3.7.2/lib/python3.7/site-packages/PyQtWebEngine-5.12.dist-info
    ${python.executable} configure.py -w \
      --destdir="$out/${python.sitePackages}/PyQt5" \
      --no-dist-info \
      --apidir="$out/api/${python.libPrefix}" \
      --sipdir="$out/share/sip/PyQt5" \
      --pyqt-sipdir="${pyqt5}/share/sip/PyQt5" \
      --stubsdir="$out/${python.sitePackages}/PyQt5"

    runHook postConfigure
  '';

  postInstall = ''
    # Let's make it a namespace package
    cat << EOF > $out/${python.sitePackages}/PyQt5/__init__.py
    from pkgutil import extend_path
    __path__ = extend_path(__path__, __name__)
    EOF
  '';

  installCheckPhase = let
    modules = [
      "PyQt5.QtWebEngine"
      "PyQt5.QtWebEngineWidgets"
    ];
    imports = lib.concatMapStrings (module: "import ${module};") modules;
  in ''
    echo "Checking whether modules can be imported..."
    PYTHONPATH=$PYTHONPATH:$out/${python.sitePackages} ${python.interpreter} -c "${imports}"
  '';

  doCheck = true;

  enableParallelBuilding = true;

  passthru = {
    inherit wrapQtAppsHook;
  };

  meta = with lib; {
    description = "Python bindings for Qt5";
    homepage    = "http://www.riverbankcomputing.co.uk";
    license     = licenses.gpl3;
    platforms   = platforms.mesaPlatforms;
  };
}