1{
2 lib,
3 fetchurl,
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.7.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 hash = "sha256-gurjcHN99ez1OcFl0J18gdX8YVOlQbjT03sRJ1+ePo8=";
22 };
23
24 sourceRoot = "pyside-setup-everywhere-src-${version}/sources/${pname}";
25
26 patches = [ ./fix-include-qt-headers.patch ];
27
28 nativeBuildInputs = [
29 cmake
30 (python.pythonOnBuildForHost.withPackages (ps: [ ps.setuptools ]))
31 ] ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
32
33 buildInputs = [
34 llvmPackages.llvm
35 llvmPackages.libclang
36 python.pkgs.qt6.qtbase
37 python.pkgs.ninja
38 python.pkgs.packaging
39 python.pkgs.setuptools
40 ];
41
42 cmakeFlags = [ "-DBUILD_TESTS=OFF" ];
43
44 # We intentionally use single quotes around `${BASH}` since it expands from a CMake
45 # variable available in this file.
46 postPatch = ''
47 substituteInPlace cmake/ShibokenHelpers.cmake --replace-fail '#!/bin/bash' '#!''${BASH}'
48 '';
49
50 # Due to Shiboken.abi3.so being linked to libshiboken6.abi3.so.6.6 in the build tree,
51 # we need to remove the build tree reference from the RPATH and then add the correct
52 # directory to the RPATH. On Linux, the second part is handled by autoPatchelfHook.
53 # https://bugreports.qt.io/browse/PYSIDE-2233
54 preFixup =
55 ''
56 echo "fixing RPATH of Shiboken.abi3.so"
57 ''
58 + lib.optionalString stdenv.isDarwin ''
59 install_name_tool -change {@rpath,$out/lib}/libshiboken6.abi3.6.6.dylib $out/${python.sitePackages}/shiboken6/Shiboken.abi3.so
60 ''
61 + lib.optionalString stdenv.isLinux ''
62 patchelf $out/${python.sitePackages}/shiboken6/Shiboken.abi3.so --shrink-rpath --allowed-rpath-prefixes ${builtins.storeDir}
63 '';
64
65 postInstall = ''
66 cd ../../..
67 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=shiboken6
68 cp -r shiboken6.egg-info $out/${python.sitePackages}/
69 '';
70
71 dontWrapQtApps = true;
72
73 meta = with lib; {
74 description = "Generator for the pyside6 Qt bindings";
75 license = with licenses; [
76 lgpl3Only
77 gpl2Only
78 gpl3Only
79 ];
80 homepage = "https://wiki.qt.io/Qt_for_Python";
81 maintainers = with maintainers; [
82 gebner
83 Enzime
84 ];
85 platforms = platforms.all;
86 };
87}