Merge pull request #329238 from gador/pyside6-darwin

python312Packages.pyside6: allow optional dependencies for darwin

authored by Florian and committed by GitHub 556126cb 7d297227

+86 -37
+86 -37
pkgs/development/python-modules/pyside6/default.nix
··· 2 2 lib, 3 3 stdenv, 4 4 cmake, 5 + cups, 5 6 ninja, 6 7 python, 8 + pythonImportsCheckHook, 7 9 moveBuildTree, 8 10 shiboken6, 11 + llvmPackages, 12 + symlinkJoin, 13 + libGL, 14 + darwin, 9 15 }: 16 + let 17 + packages = with python.pkgs.qt6; [ 18 + # required 19 + python.pkgs.ninja 20 + python.pkgs.packaging 21 + python.pkgs.setuptools 22 + qtbase 23 + 24 + # optional 25 + qt3d 26 + qtcharts 27 + qtconnectivity 28 + qtdatavis3d 29 + qtdeclarative 30 + qthttpserver 31 + qtmultimedia 32 + qtnetworkauth 33 + qtquick3d 34 + qtremoteobjects 35 + qtscxml 36 + qtsensors 37 + qtspeech 38 + qtsvg 39 + qtwebchannel 40 + qtwebsockets 41 + qtpositioning 42 + qtlocation 43 + qtshadertools 44 + qtserialport 45 + qtserialbus 46 + qtgraphs 47 + qttools 48 + ]; 49 + qt_linked = symlinkJoin { 50 + name = "qt_linked"; 51 + paths = packages; 52 + }; 53 + in 10 54 11 55 stdenv.mkDerivation (finalAttrs: { 12 56 pname = "pyside6"; ··· 15 59 16 60 sourceRoot = "pyside-setup-everywhere-src-${finalAttrs.version}/sources/pyside6"; 17 61 18 - # FIXME: cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS 62 + # cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS 19 63 # reside in the same directory as QtCore.framework, which is not true for Nix. 20 - postPatch = lib.optionalString stdenv.isLinux '' 21 - # Don't ignore optional Qt modules 22 - substituteInPlace cmake/PySideHelpers.cmake \ 23 - --replace-fail \ 24 - 'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \ 25 - 'set (found_basepath 0)' 26 - ''; 64 + # We therefore symLink all required and optional Qt modules in one directory tree ("qt_linked"). 65 + # Also we remove "Designer" from darwin build, due to linking failure 66 + postPatch = 67 + '' 68 + # Don't ignore optional Qt modules 69 + substituteInPlace cmake/PySideHelpers.cmake \ 70 + --replace-fail \ 71 + 'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \ 72 + 'set (found_basepath 0)' 73 + '' 74 + + lib.optionalString stdenv.isDarwin '' 75 + substituteInPlace cmake/PySideHelpers.cmake \ 76 + --replace-fail \ 77 + "Designer" "" 78 + ''; 79 + 80 + # "Couldn't find libclang.dylib You will likely need to add it manually to PATH to ensure the build succeeds." 81 + env = lib.optionalAttrs stdenv.isDarwin { LLVM_INSTALL_DIR = "${llvmPackages.libclang.lib}/lib"; }; 27 82 28 83 nativeBuildInputs = [ 29 84 cmake 30 85 ninja 31 86 python 87 + pythonImportsCheckHook 32 88 ] ++ lib.optionals stdenv.isDarwin [ moveBuildTree ]; 33 89 34 90 buildInputs = 35 - with python.pkgs.qt6; 36 - [ 37 - # required 38 - qtbase 39 - python.pkgs.ninja 40 - python.pkgs.packaging 41 - python.pkgs.setuptools 42 - ] 43 - ++ lib.optionals stdenv.isLinux [ 44 - # optional 45 - qt3d 46 - qtcharts 47 - qtconnectivity 48 - qtdatavis3d 49 - qtdeclarative 50 - qthttpserver 51 - qtmultimedia 52 - qtnetworkauth 53 - qtquick3d 54 - qtremoteobjects 55 - qtscxml 56 - qtsensors 57 - qtspeech 58 - qtsvg 59 - qttools 60 - qtwebchannel 61 - qtwebengine 62 - qtwebsockets 63 - ]; 91 + if stdenv.isLinux then 92 + # qtwebengine fails under darwin 93 + # see https://github.com/NixOS/nixpkgs/pull/312987 94 + packages ++ [ python.pkgs.qt6.qtwebengine ] 95 + else 96 + with darwin.apple_sdk_11_0.frameworks; 97 + [ 98 + qt_linked 99 + libGL 100 + cups 101 + # frameworks 102 + IOKit 103 + DiskArbitration 104 + CoreBluetooth 105 + EventKit 106 + AVFoundation 107 + Contacts 108 + AGL 109 + AppKit 110 + ]; 64 111 65 112 propagatedBuildInputs = [ shiboken6 ]; 66 113 ··· 73 120 ${python.pythonOnBuildForHost.interpreter} setup.py egg_info --build-type=pyside6 74 121 cp -r PySide6.egg-info $out/${python.sitePackages}/ 75 122 ''; 123 + 124 + pythonImportsCheck = [ "PySide6" ]; 76 125 77 126 meta = { 78 127 description = "Python bindings for Qt";