1{ lib
2, stdenv
3, buildPythonPackage
4, setuptools
5, isPy27
6, fetchPypi
7, pkg-config
8, dbus
9, lndir
10, dbus-python
11, sip
12, pyqt5_sip
13, pyqt-builder
14, libsForQt5
15, withConnectivity ? false
16, withMultimedia ? false
17, withWebKit ? false
18, withWebSockets ? false
19, withLocation ? false
20}:
21
22buildPythonPackage rec {
23 pname = "PyQt5";
24 version = "5.15.9";
25 format = "pyproject";
26
27 disabled = isPy27;
28
29 src = fetchPypi {
30 inherit pname version;
31 hash = "sha256-3EHoQBqQ3D4raStBG9VJKrVZrieidCTu1L05FVZOxMA=";
32 };
33
34 patches = [
35 # Fix some wrong assumptions by ./project.py
36 # TODO: figure out how to send this upstream
37 ./pyqt5-fix-dbus-mainloop-support.patch
38 # confirm license when installing via pyqt5_sip
39 ./pyqt5-confirm-license.patch
40 ];
41
42 postPatch =
43 # be more verbose
44 ''
45 cat >> pyproject.toml <<EOF
46 [tool.sip.project]
47 verbose = true
48 ''
49 # Due to bug in SIP .whl name generation we have to bump minimal macos sdk upto 11.0 for
50 # aarch64-darwin. This patch can be removed once SIP will fix it in upstream,
51 # see https://github.com/NixOS/nixpkgs/pull/186612#issuecomment-1214635456.
52 + lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
53 minimum-macos-version = "11.0"
54 '' + ''
55 EOF
56 '';
57
58 enableParallelBuilding = true;
59 # HACK: paralellize compilation of make calls within pyqt's setup.py
60 # pkgs/stdenv/generic/setup.sh doesn't set this for us because
61 # make gets called by python code and not its build phase
62 # format=pyproject means the pip-build-hook hook gets used to build this project
63 # pkgs/development/interpreters/python/hooks/pip-build-hook.sh
64 # does not use the enableParallelBuilding flag
65 postUnpack = ''
66 export MAKEFLAGS+="''${enableParallelBuilding:+-j$NIX_BUILD_CORES}"
67 '';
68
69 outputs = [ "out" "dev" ];
70
71 dontWrapQtApps = true;
72
73 nativeBuildInputs = with libsForQt5; [
74 pkg-config
75 qmake
76 setuptools
77 lndir
78 sip
79 qtbase
80 qtsvg
81 qtdeclarative
82 qtwebchannel
83 ]
84 ++ lib.optional withConnectivity qtconnectivity
85 ++ lib.optional withMultimedia qtmultimedia
86 ++ lib.optional withWebKit qtwebkit
87 ++ lib.optional withWebSockets qtwebsockets
88 ++ lib.optional withLocation qtlocation
89 ;
90
91 buildInputs = with libsForQt5; [
92 dbus
93 qtbase
94 qtsvg
95 qtdeclarative
96 pyqt-builder
97 ]
98 ++ lib.optional withConnectivity qtconnectivity
99 ++ lib.optional withWebKit qtwebkit
100 ++ lib.optional withWebSockets qtwebsockets
101 ++ lib.optional withLocation qtlocation
102 ;
103
104 propagatedBuildInputs = [
105 dbus-python
106 pyqt5_sip
107 ];
108
109 passthru = {
110 inherit sip pyqt5_sip;
111 multimediaEnabled = withMultimedia;
112 webKitEnabled = withWebKit;
113 WebSocketsEnabled = withWebSockets;
114 };
115
116 dontConfigure = true;
117
118 # Checked using pythonImportsCheck
119 doCheck = false;
120
121 pythonImportsCheck = [
122 "PyQt5"
123 "PyQt5.QtCore"
124 "PyQt5.QtQml"
125 "PyQt5.QtWidgets"
126 "PyQt5.QtGui"
127 ]
128 ++ lib.optional withWebSockets "PyQt5.QtWebSockets"
129 ++ lib.optional withWebKit "PyQt5.QtWebKit"
130 ++ lib.optional withMultimedia "PyQt5.QtMultimedia"
131 ++ lib.optional withConnectivity "PyQt5.QtBluetooth"
132 ++ lib.optional withLocation "PyQt5.QtPositioning"
133 ;
134
135 meta = with lib; {
136 description = "Python bindings for Qt5";
137 homepage = "https://riverbankcomputing.com/";
138 license = licenses.gpl3Only;
139 platforms = platforms.mesaPlatforms;
140 maintainers = with maintainers; [ sander ];
141 };
142}