1{
2 lib,
3 stdenv,
4 fetchpatch,
5 cmake,
6 cups,
7 ninja,
8 python,
9 pythonImportsCheckHook,
10 moveBuildTree,
11 shiboken6,
12 llvmPackages,
13 symlinkJoin,
14}:
15let
16 packages = with python.pkgs.qt6; [
17 # required
18 python.pkgs.ninja
19 python.pkgs.packaging
20 python.pkgs.setuptools
21 qtbase
22
23 # optional
24 qt3d
25 qtcharts
26 qtconnectivity
27 qtdatavis3d
28 qtdeclarative
29 qthttpserver
30 qtmultimedia
31 qtnetworkauth
32 qtquick3d
33 qtremoteobjects
34 qtscxml
35 qtsensors
36 qtspeech
37 qtsvg
38 qtwebchannel
39 qtwebsockets
40 qtpositioning
41 qtlocation
42 qtshadertools
43 qtserialport
44 qtserialbus
45 qtgraphs
46 qttools
47 ];
48 qt_linked = symlinkJoin {
49 name = "qt_linked";
50 paths = packages;
51 };
52in
53
54stdenv.mkDerivation (finalAttrs: {
55 pname = "pyside6";
56
57 inherit (shiboken6) version src;
58
59 sourceRoot = "pyside-setup-everywhere-src-6.8.0/sources/pyside6";
60
61 patches = [
62 # Manual backport of https://code.qt.io/cgit/pyside/pyside-setup.git/patch/?id=cacc9c5803a6dec820dd46211a836453183c8dab
63 # to fit our structure.
64 # FIXME: remove for 6.8.1
65 ./fix-installing-docs.patch
66 ];
67
68 # cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS
69 # reside in the same directory as QtCore.framework, which is not true for Nix.
70 # We therefore symLink all required and optional Qt modules in one directory tree ("qt_linked").
71 postPatch =
72 ''
73 # Don't ignore optional Qt modules
74 substituteInPlace cmake/PySideHelpers.cmake \
75 --replace-fail \
76 'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \
77 'set (found_basepath 0)'
78 ''
79 + lib.optionalString stdenv.hostPlatform.isDarwin ''
80 substituteInPlace cmake/PySideHelpers.cmake \
81 --replace-fail \
82 "Designer" ""
83 '';
84
85 # "Couldn't find libclang.dylib You will likely need to add it manually to PATH to ensure the build succeeds."
86 env = lib.optionalAttrs stdenv.hostPlatform.isDarwin {
87 LLVM_INSTALL_DIR = "${lib.getLib llvmPackages.libclang}/lib";
88 };
89
90 nativeBuildInputs = [
91 cmake
92 ninja
93 python
94 pythonImportsCheckHook
95 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ moveBuildTree ];
96
97 buildInputs = (
98 if stdenv.hostPlatform.isLinux then
99 # qtwebengine fails under darwin
100 # see https://github.com/NixOS/nixpkgs/pull/312987
101 packages ++ [ python.pkgs.qt6.qtwebengine ]
102 else
103 python.pkgs.qt6.darwinVersionInputs
104 ++ [
105 qt_linked
106 cups
107 ]
108 );
109
110 propagatedBuildInputs = [ shiboken6 ];
111
112 cmakeFlags = [ "-DBUILD_TESTS=OFF" ];
113
114 dontWrapQtApps = true;
115
116 postInstall = ''
117 cd ../../..
118 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=pyside6
119 cp -r PySide6.egg-info $out/${python.sitePackages}/
120 '';
121
122 pythonImportsCheck = [ "PySide6" ];
123
124 meta = {
125 description = "Python bindings for Qt";
126 license = with lib.licenses; [
127 lgpl3Only
128 gpl2Only
129 gpl3Only
130 ];
131 homepage = "https://wiki.qt.io/Qt_for_Python";
132 changelog = "https://code.qt.io/cgit/pyside/pyside-setup.git/tree/doc/changelogs/changes-${finalAttrs.version}?h=v${finalAttrs.version}";
133 maintainers = with lib.maintainers; [ gebner ];
134 platforms = lib.platforms.all;
135 };
136})