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