1{ lib, fetchurl, pythonPackages, pkgconfig
2, dbus
3, qmake, lndir
4, qtbase
5, qtsvg
6, qtdeclarative
7, qtwebchannel
8, withConnectivity ? false, qtconnectivity
9, withMultimedia ? false, qtmultimedia
10, withWebKit ? false, qtwebkit
11, withWebSockets ? false, qtwebsockets
12}:
13
14let
15
16 inherit (pythonPackages) buildPythonPackage python isPy3k dbus-python enum34;
17
18 sip = (pythonPackages.sip.override { sip-module = "PyQt5.sip"; }).overridePythonAttrs(oldAttrs: {
19 # If we install sip in another folder, then we need to create a __init__.py as well
20 # if we want to be able to import it with Python 2.
21 # Python 3 could rely on it being an implicit namespace package, however,
22 # PyQt5 we made an explicit namespace package so sip should be as well.
23 postInstall = ''
24 cat << EOF > $out/${python.sitePackages}/PyQt5/__init__.py
25 from pkgutil import extend_path
26 __path__ = extend_path(__path__, __name__)
27 EOF
28 '';
29 });
30
31in buildPythonPackage rec {
32 pname = "pyqt";
33 version = "5.13.0";
34 format = "other";
35
36 src = fetchurl {
37 url = "https://www.riverbankcomputing.com/static/Downloads/PyQt5/${version}/PyQt5_gpl-${version}.tar.gz";
38 sha256 = "1ydgdz28f1v17qqz3skyv26k5l0w63fr4dncc5xm49jr2gjzznqc";
39 };
40
41 outputs = [ "out" "dev" ];
42
43 nativeBuildInputs = [
44 pkgconfig
45 qmake
46 lndir
47 sip
48 qtbase
49 qtsvg
50 qtdeclarative
51 qtwebchannel
52 ]
53 ++ lib.optional withConnectivity qtconnectivity
54 ++ lib.optional withMultimedia qtmultimedia
55 ++ lib.optional withWebKit qtwebkit
56 ++ lib.optional withWebSockets qtwebsockets
57 ;
58
59 buildInputs = [
60 dbus
61 qtbase
62 qtsvg
63 qtdeclarative
64 ]
65 ++ lib.optional withConnectivity qtconnectivity
66 ++ lib.optional withWebKit qtwebkit
67 ++ lib.optional withWebSockets qtwebsockets
68 ;
69
70 propagatedBuildInputs = [
71 dbus-python
72 sip
73 ] ++ lib.optional (!isPy3k) enum34;
74
75 patches = [
76 # Fix some wrong assumptions by ./configure.py
77 # TODO: figure out how to send this upstream
78 ./pyqt5-fix-dbus-mainloop-support.patch
79 ];
80
81 passthru = {
82 inherit sip;
83 };
84
85 configurePhase = ''
86 runHook preConfigure
87
88 export PYTHONPATH=$PYTHONPATH:$out/${python.sitePackages}
89
90 ${python.executable} configure.py -w \
91 --confirm-license \
92 --dbus-moduledir=$out/${python.sitePackages}/dbus/mainloop \
93 --no-qml-plugin \
94 --bindir=$out/bin \
95 --destdir=$out/${python.sitePackages} \
96 --stubsdir=$out/${python.sitePackages}/PyQt5 \
97 --sipdir=$out/share/sip/PyQt5 \
98 --designer-plugindir=$out/plugins/designer
99
100 runHook postConfigure
101 '';
102
103 postInstall = ''
104 ln -s ${sip}/${python.sitePackages}/PyQt5/sip.* $out/${python.sitePackages}/PyQt5/
105 for i in $out/bin/*; do
106 wrapProgram $i --prefix PYTHONPATH : "$PYTHONPATH"
107 done
108
109 # Let's make it a namespace package
110 cat << EOF > $out/${python.sitePackages}/PyQt5/__init__.py
111 from pkgutil import extend_path
112 __path__ = extend_path(__path__, __name__)
113 EOF
114 '';
115
116 installCheckPhase = let
117 modules = [
118 "PyQt5"
119 "PyQt5.QtCore"
120 "PyQt5.QtQml"
121 "PyQt5.QtWidgets"
122 "PyQt5.QtGui"
123 ]
124 ++ lib.optional withWebSockets "PyQt5.QtWebSockets"
125 ++ lib.optional withWebKit "PyQt5.QtWebKit"
126 ++ lib.optional withMultimedia "PyQt5.QtMultimedia"
127 ++ lib.optional withConnectivity "PyQt5.QtConnectivity"
128 ;
129 imports = lib.concatMapStrings (module: "import ${module};") modules;
130 in ''
131 echo "Checking whether modules can be imported..."
132 ${python.interpreter} -c "${imports}"
133 '';
134
135 doCheck = true;
136
137 enableParallelBuilding = true;
138
139 meta = with lib; {
140 description = "Python bindings for Qt5";
141 homepage = http://www.riverbankcomputing.co.uk;
142 license = licenses.gpl3;
143 platforms = platforms.mesaPlatforms;
144 maintainers = with maintainers; [ sander ];
145 };
146}