summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyside2/default.nix
blob: 4a0215fe59dafda6e9142386dd30c490ce18d9e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
  python,
  fetchurl,
  lib,
  stdenv,
  cmake,
  ninja,
  qt5,
  shiboken2,
  withWebengine ? false, # vulnerable, so omit by default
}:
stdenv.mkDerivation rec {
  pname = "pyside2";
  version = "5.15.17";

  src = fetchurl {
    url = "https://download.qt.io/official_releases/QtForPython/pyside2/PySide2-${version}-src/pyside-setup-opensource-src-${version}.tar.xz";
    hash = "sha256-hKSzKPamAjW4cXrVIriKe2AAWSYMV6IYntAFEJ8kxSc=";
  };

  patches = [
    ./nix_compile_cflags.patch
    ./Final-details-to-enable-3.12-wheel-compatibility.patch
    ./Python-3.12-Fix-the-structure-of-class-property.patch
    ./Support-running-PySide-on-Python-3.12.patch
    ./shiboken2-clang-Fix-and-simplify-resolveType-helper.patch
    ./shiboken2-clang-Fix-build-with-clang-16.patch
    ./shiboken2-clang-Fix-clashes-between-type-name-and-enumera.patch
    ./shiboken2-clang-Record-scope-resolution-of-arguments-func.patch
    ./shiboken2-clang-Remove-typedef-expansion.patch
    ./shiboken2-clang-Suppress-class-scope-look-up-for-paramete.patch
    ./shiboken2-clang-Write-scope-resolution-for-all-parameters.patch
    ./dont_ignore_optional_modules.patch
    ./Modify-sendCommand-signatures.patch
  ];

  postPatch = ''
    cd sources/pyside2
    for i in {.,doc}/CMakeLists.txt; do
      substituteInPlace $i --replace-fail \
        "cmake_minimum_required(VERSION 3.1)" \
        "cmake_minimum_required(VERSION 3.10)"
      substituteInPlace $i --replace-fail \
        "cmake_policy(VERSION 3.1)" \
        "cmake_policy(VERSION 3.10)"
    done
  '';

  cmakeFlags = [
    "-DBUILD_TESTS=OFF"
    "-DPYTHON_EXECUTABLE=${python.interpreter}"
  ];

  env.NIX_CFLAGS_COMPILE = "-I${qt5.qtdeclarative.dev}/include/QtQuick/${qt5.qtdeclarative.version}/QtQuick";

  nativeBuildInputs = [
    cmake
    ninja
    qt5.qmake
    (python.withPackages (
      ps: with ps; [
        distutils
        setuptools
      ]
    ))
  ];

  buildInputs =
    (with qt5; [
      qtbase
      qtxmlpatterns
      qtmultimedia
      qttools
      qtx11extras
      qtlocation
      qtscript
      qtwebsockets
      qtwebchannel
      qtcharts
      qtsensors
      qtsvg
      qt3d
    ])
    ++ lib.optionals withWebengine [
      qt5.qtwebengine
    ]
    ++ (with python.pkgs; [ setuptools ]);

  propagatedBuildInputs = [ shiboken2 ];

  dontWrapQtApps = true;

  postInstall = ''
    cd ../../..
    ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=pyside2
    cp -r PySide2.egg-info $out/${python.sitePackages}/
  '';

  meta = {
    description = "LGPL-licensed Python bindings for Qt";
    license = lib.licenses.lgpl21;
    homepage = "https://wiki.qt.io/Qt_for_Python";
    maintainers = [ ];
    platforms = lib.platforms.all;
    broken = stdenv.hostPlatform.isDarwin;
  };
}