summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyside2-tools/default.nix
blob: 79eb5fb328492d7c38cdb561711c0455e881a56c (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
{
  wrapPython,
  python,
  lib,
  stdenv,
  cmake,
  qt5,
  distutils,
  shiboken2,
  pyside2,
}:

stdenv.mkDerivation {
  pname = "pyside2-tools";

  inherit (pyside2) version src;

  patches = [
    # Upstream has a crazy build system only geared towards producing binary
    # wheels distributed via pypi.  For this, they copy the `uic` and `rcc`
    # binaries to the wheel.
    ./remove_hacky_binary_copying.patch
  ];

  postPatch = ''
    cd sources/pyside2-tools
    substituteInPlace CMakeLists.txt --replace-fail \
      "cmake_minimum_required(VERSION 3.1)" \
      "cmake_minimum_required(VERSION 3.10)"
  '';

  nativeBuildInputs = [
    cmake
    distutils
    wrapPython
  ];
  propagatedBuildInputs = [
    shiboken2
    pyside2
  ];
  buildInputs = [
    python
    qt5.qtbase
  ];

  cmakeFlags = [ "-DBUILD_TESTS=OFF" ];

  dontWrapQtApps = true;

  # The upstream build system consists of a `setup.py` whichs builds three
  # different python libraries and calls cmake as a subprocess.  We call cmake
  # directly because that's easier to get working.  However, the `setup.py`
  # build also creates a few wrapper scripts, which we replicate here:
  postInstall = ''
    rm $out/bin/pyside_tool.py

    for tool in uic rcc; do
      makeWrapper "$(command -v $tool)" $out/bin/pyside2-$tool --add-flags "-g python"
    done
  '';

  postFixup = ''
    wrapPythonPrograms
  '';

  meta = {
    description = "PySide2 development tools";
    license = lib.licenses.gpl2;
    homepage = "https://wiki.qt.io/Qt_for_Python";
    maintainers = [ ];
  };
}