1{
2 python,
3 fetchurl,
4 lib,
5 stdenv,
6 cmake,
7 libxcrypt,
8 ninja,
9 qt5,
10 shiboken2,
11 withWebengine ? false, # vulnerable, so omit by default
12}:
13stdenv.mkDerivation rec {
14 pname = "pyside2";
15 version = "5.15.17";
16
17 src = fetchurl {
18 url = "https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/pyside-setup-opensource-src-${version}.tar.xz";
19 hash = "sha256-hKSzKPamAjW4cXrVIriKe2AAWSYMV6IYntAFEJ8kxSc=";
20 };
21
22 patches = [
23 ./nix_compile_cflags.patch
24 ./Final-details-to-enable-3.12-wheel-compatibility.patch
25 ./Python-3.12-Fix-the-structure-of-class-property.patch
26 ./Support-running-PySide-on-Python-3.12.patch
27 ./shiboken2-clang-Fix-and-simplify-resolveType-helper.patch
28 ./shiboken2-clang-Fix-build-with-clang-16.patch
29 ./shiboken2-clang-Fix-clashes-between-type-name-and-enumera.patch
30 ./shiboken2-clang-Record-scope-resolution-of-arguments-func.patch
31 ./shiboken2-clang-Remove-typedef-expansion.patch
32 ./shiboken2-clang-Suppress-class-scope-look-up-for-paramete.patch
33 ./shiboken2-clang-Write-scope-resolution-for-all-parameters.patch
34 ./dont_ignore_optional_modules.patch
35 ./Modify-sendCommand-signatures.patch
36 ];
37
38 postPatch = ''
39 cd sources/pyside2
40 '';
41
42 cmakeFlags = [
43 "-DBUILD_TESTS=OFF"
44 "-DPYTHON_EXECUTABLE=${python.interpreter}"
45 ];
46
47 env.NIX_CFLAGS_COMPILE = "-I${qt5.qtdeclarative.dev}/include/QtQuick/${qt5.qtdeclarative.version}/QtQuick";
48
49 nativeBuildInputs = [
50 cmake
51 ninja
52 qt5.qmake
53 (python.withPackages (
54 ps: with ps; [
55 distutils
56 setuptools
57 ]
58 ))
59 ];
60
61 buildInputs =
62 (with qt5; [
63 qtbase
64 qtxmlpatterns
65 qtmultimedia
66 qttools
67 qtx11extras
68 qtlocation
69 qtscript
70 qtwebsockets
71 qtwebchannel
72 qtcharts
73 qtsensors
74 qtsvg
75 qt3d
76 ])
77 ++ lib.optionals withWebengine [
78 qt5.qtwebengine
79 ]
80 ++ (with python.pkgs; [ setuptools ])
81 ++ (lib.optionals (python.pythonOlder "3.9") [
82 # see similar issue: 202262
83 # libxcrypt is required for crypt.h for building older python modules
84 libxcrypt
85 ]);
86
87 propagatedBuildInputs = [ shiboken2 ];
88
89 dontWrapQtApps = true;
90
91 postInstall = ''
92 cd ../../..
93 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=pyside2
94 cp -r PySide2.egg-info $out/${python.sitePackages}/
95 '';
96
97 meta = with lib; {
98 description = "LGPL-licensed Python bindings for Qt";
99 license = licenses.lgpl21;
100 homepage = "https://wiki.qt.io/Qt_for_Python";
101 maintainers = with maintainers; [ ];
102 platforms = platforms.all;
103 broken = stdenv.hostPlatform.isDarwin;
104 };
105}