1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchzip,
6 pkg-config,
7 dbus,
8 lndir,
9 dbus-python,
10 sip,
11 pyqt6-sip,
12 pyqt-builder,
13 qt6Packages,
14 pythonOlder,
15 mesa,
16 withMultimedia ? true,
17 withWebSockets ? true,
18 withLocation ? true,
19 # Not currently part of PyQt6
20 #, withConnectivity ? true
21 withPrintSupport ? true,
22 withSerialPort ? false,
23 cups,
24}:
25
26buildPythonPackage rec {
27 pname = "pyqt6";
28 version = "6.9.0";
29 pyproject = true;
30
31 disabled = pythonOlder "3.9";
32
33 # It looks like a stable release, but is it? Who knows.
34 # It's not on PyPI proper yet, at least, and the current
35 # actually-released version does not build with Qt 6.9,
36 # so we kinda have to use it.
37 # "ffs smdh fam" - K900
38 src = fetchzip {
39 url = "https://web.archive.org/web/20250406083944/https://www.riverbankcomputing.com/pypi/packages/PyQt6/pyqt6-6.9.0.tar.gz";
40 hash = "sha256-UZSbz6MqdNtl2r4N8uvgNjQ+28KCzNFb5yFqPcooT5E=";
41 };
42
43 patches = [
44 # Fix some wrong assumptions by ./project.py
45 # TODO: figure out how to send this upstream
46 ./pyqt6-fix-dbus-mainloop-support.patch
47 # confirm license when installing via pyqt6_sip
48 ./pyqt5-confirm-license.patch
49 ];
50
51 build-system = [
52 sip
53 pyqt-builder
54 ];
55
56 dependencies = [
57 pyqt6-sip
58 dbus-python
59 ];
60
61 # be more verbose
62 # and normalize version
63 postPatch = ''
64 cat >> pyproject.toml <<EOF
65 [tool.sip.project]
66 verbose = true
67 EOF
68
69 substituteInPlace pyproject.toml \
70 --replace-fail 'version = "${version}"' 'version = "${lib.versions.pad 3 version}"'
71 '';
72
73 enableParallelBuilding = true;
74 # HACK: paralellize compilation of make calls within pyqt's setup.py
75 # pkgs/stdenv/generic/setup.sh doesn't set this for us because
76 # make gets called by python code and not its build phase
77 # format=pyproject means the pip-build-hook hook gets used to build this project
78 # pkgs/development/interpreters/python/hooks/pip-build-hook.sh
79 # does not use the enableParallelBuilding flag
80 postUnpack = ''
81 export MAKEFLAGS+="''${enableParallelBuilding:+-j$NIX_BUILD_CORES}"
82 '';
83
84 outputs = [
85 "out"
86 "dev"
87 ];
88
89 dontWrapQtApps = true;
90
91 nativeBuildInputs =
92 with qt6Packages;
93 [
94 pkg-config
95 lndir
96 qtbase
97 qtsvg
98 qtdeclarative
99 qtwebchannel
100 qmake
101 qtquick3d
102 qtquicktimeline
103 ]
104 # ++ lib.optional withConnectivity qtconnectivity
105 ++ lib.optional withMultimedia qtmultimedia
106 ++ lib.optional withWebSockets qtwebsockets
107 ++ lib.optional withLocation qtlocation
108 ++ lib.optional withSerialPort qtserialport;
109
110 buildInputs =
111 with qt6Packages;
112 [
113 dbus
114 qtbase
115 qtsvg
116 qtdeclarative
117 qtquick3d
118 qtquicktimeline
119 ]
120 # ++ lib.optional withConnectivity qtconnectivity
121 ++ lib.optional withMultimedia qtmultimedia
122 ++ lib.optional withWebSockets qtwebsockets
123 ++ lib.optional withLocation qtlocation
124 ++ lib.optional withSerialPort qtserialport;
125
126 propagatedBuildInputs =
127 # ld: library not found for -lcups
128 lib.optionals (withPrintSupport && stdenv.hostPlatform.isDarwin) [ cups ];
129
130 passthru = {
131 inherit sip pyqt6-sip;
132 multimediaEnabled = withMultimedia;
133 WebSocketsEnabled = withWebSockets;
134 serialPortEnabled = withSerialPort;
135 };
136
137 dontConfigure = true;
138
139 # Checked using pythonImportsCheck, has no tests
140
141 pythonImportsCheck = [
142 "PyQt6"
143 "PyQt6.QtCore"
144 "PyQt6.QtQml"
145 "PyQt6.QtWidgets"
146 "PyQt6.QtGui"
147 "PyQt6.QtQuick"
148 ]
149 ++ lib.optional withWebSockets "PyQt6.QtWebSockets"
150 ++ lib.optional withMultimedia "PyQt6.QtMultimedia"
151 # ++ lib.optional withConnectivity "PyQt6.QtConnectivity"
152 ++ lib.optional withLocation "PyQt6.QtPositioning"
153 ++ lib.optional withSerialPort "PyQt6.QtSerialPort";
154
155 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-Wno-address-of-temporary";
156
157 meta = with lib; {
158 description = "Python bindings for Qt6";
159 homepage = "https://riverbankcomputing.com/";
160 license = licenses.gpl3Only;
161 inherit (mesa.meta) platforms;
162 maintainers = with maintainers; [ LunNova ];
163 };
164}