1{ lib
2, fetchurl
3, fetchpatch
4, llvmPackages
5, python
6, cmake
7, autoPatchelfHook
8, stdenv
9}:
10
11let
12 stdenv' = if stdenv.cc.isClang then stdenv else llvmPackages.stdenv;
13in
14stdenv'.mkDerivation rec {
15 pname = "shiboken6";
16 version = "6.6.0";
17
18 src = fetchurl {
19 # https://download.qt.io/official_releases/QtForPython/shiboken6/
20 url = "https://download.qt.io/official_releases/QtForPython/shiboken6/PySide6-${version}-src/pyside-setup-everywhere-src-${version}.tar.xz";
21 sha256 = "sha256-LdAC24hRqHFzNU84qoxuxC0P8frJnqQisp4t/OUtFjg=";
22 };
23
24 sourceRoot = "pyside-setup-everywhere-src-${lib.removeSuffix ".0" version}/sources/${pname}";
25
26 patches = [
27 ./fix-include-qt-headers.patch
28 # TODO: remove after bumping above 6.6.0
29 (fetchpatch {
30 name = "shiboken6-improve-api-extractor-argument-parsing.patch";
31 url = "https://code.qt.io/cgit/pyside/pyside-setup.git/patch/?id=6abde77c3df60ccac25089660df5797de7f6e68c";
32 hash = "sha256-uctp5rjY16X37BYzsZzg9AAgM2hwNVkcNxT1bCobb0I=";
33 stripLen = 2;
34 })
35 ];
36
37 nativeBuildInputs = [
38 cmake
39 (python.pythonOnBuildForHost.withPackages (ps: [ ps.setuptools ]))
40 ] ++ lib.optionals stdenv.isLinux [
41 autoPatchelfHook
42 ];
43
44 buildInputs = [
45 llvmPackages.llvm
46 llvmPackages.libclang
47 python.pkgs.qt6.qtbase
48 python.pkgs.ninja
49 python.pkgs.packaging
50 python.pkgs.setuptools
51 ];
52
53 cmakeFlags = [
54 "-DBUILD_TESTS=OFF"
55 ];
56
57 # We intentionally use single quotes around `${BASH}` since it expands from a CMake
58 # variable available in this file.
59 postPatch = ''
60 substituteInPlace cmake/ShibokenHelpers.cmake --replace '#!/bin/bash' '#!''${BASH}'
61 '';
62
63 # Due to Shiboken.abi3.so being linked to libshiboken6.abi3.so.6.6 in the build tree,
64 # we need to remove the build tree reference from the RPATH and then add the correct
65 # directory to the RPATH. On Linux, the second part is handled by autoPatchelfHook.
66 # https://bugreports.qt.io/browse/PYSIDE-2233
67 preFixup = ''
68 echo "fixing RPATH of Shiboken.abi3.so"
69 '' + lib.optionalString stdenv.isDarwin ''
70 install_name_tool -change {@rpath,$out/lib}/libshiboken6.abi3.6.6.dylib $out/${python.sitePackages}/shiboken6/Shiboken.abi3.so
71 '' + lib.optionalString stdenv.isLinux ''
72 patchelf $out/${python.sitePackages}/shiboken6/Shiboken.abi3.so --shrink-rpath --allowed-rpath-prefixes ${builtins.storeDir}
73 '';
74
75 postInstall = ''
76 cd ../../..
77 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=shiboken6
78 cp -r shiboken6.egg-info $out/${python.sitePackages}/
79 '';
80
81 dontWrapQtApps = true;
82
83 meta = with lib; {
84 description = "Generator for the pyside6 Qt bindings";
85 license = with licenses; [ lgpl3Only gpl2Only gpl3Only ];
86 homepage = "https://wiki.qt.io/Qt_for_Python";
87 maintainers = with maintainers; [ gebner Enzime ];
88 platforms = platforms.all;
89 };
90}