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