Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python312Packages.pyside6: allow optional dependencies for darwin #329238

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 86 additions & 37 deletions pkgs/development/python-modules/pyside6/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,55 @@
lib,
stdenv,
cmake,
cups,
ninja,
python,
pythonImportsCheckHook,
moveBuildTree,
shiboken6,
llvmPackages,
symlinkJoin,
libGL,
darwin,
}:
let
packages = with python.pkgs.qt6; [
# required
python.pkgs.ninja
python.pkgs.packaging
python.pkgs.setuptools
qtbase

# optional
qt3d
qtcharts
qtconnectivity
qtdatavis3d
qtdeclarative
qthttpserver
qtmultimedia
qtnetworkauth
qtquick3d
qtremoteobjects
qtscxml
qtsensors
qtspeech
qtsvg
qtwebchannel
qtwebsockets
qtpositioning
qtlocation
qtshadertools
qtserialport
qtserialbus
qtgraphs
qttools
];
qt_linked = symlinkJoin {
name = "qt_linked";
paths = packages;
};
in

stdenv.mkDerivation (finalAttrs: {
pname = "pyside6";
Expand All @@ -15,52 +59,55 @@ stdenv.mkDerivation (finalAttrs: {

sourceRoot = "pyside-setup-everywhere-src-${finalAttrs.version}/sources/pyside6";

# FIXME: cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS
# cmake/Macros/PySideModules.cmake supposes that all Qt frameworks on macOS
# reside in the same directory as QtCore.framework, which is not true for Nix.
postPatch = lib.optionalString stdenv.isLinux ''
# Don't ignore optional Qt modules
substituteInPlace cmake/PySideHelpers.cmake \
--replace-fail \
'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \
'set (found_basepath 0)'
'';
# We therefore symLink all required and optional Qt modules in one directory tree ("qt_linked").
# Also we remove "Designer" from darwin build, due to linking failure
postPatch =
''
# Don't ignore optional Qt modules
substituteInPlace cmake/PySideHelpers.cmake \
--replace-fail \
'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \
'set (found_basepath 0)'
''
+ lib.optionalString stdenv.isDarwin ''
substituteInPlace cmake/PySideHelpers.cmake \
--replace-fail \
"Designer" ""
'';

# "Couldn't find libclang.dylib You will likely need to add it manually to PATH to ensure the build succeeds."
env = lib.optionalAttrs stdenv.isDarwin { LLVM_INSTALL_DIR = "${llvmPackages.libclang.lib}/lib"; };

nativeBuildInputs = [
cmake
ninja
python
pythonImportsCheckHook
] ++ lib.optionals stdenv.isDarwin [ moveBuildTree ];

buildInputs =
with python.pkgs.qt6;
[
# required
qtbase
python.pkgs.ninja
python.pkgs.packaging
python.pkgs.setuptools
]
++ lib.optionals stdenv.isLinux [
# optional
qt3d
qtcharts
qtconnectivity
qtdatavis3d
qtdeclarative
qthttpserver
qtmultimedia
qtnetworkauth
qtquick3d
qtremoteobjects
qtscxml
qtsensors
qtspeech
qtsvg
qttools
qtwebchannel
qtwebengine
qtwebsockets
];
if stdenv.isLinux then
# qtwebengine fails under darwin
# see https://github.com/NixOS/nixpkgs/pull/312987
packages ++ [ python.pkgs.qt6.qtwebengine ]
else
with darwin.apple_sdk_11_0.frameworks;
[
qt_linked
libGL
cups
# frameworks
IOKit
DiskArbitration
CoreBluetooth
EventKit
AVFoundation
Contacts
AGL
AppKit
];

propagatedBuildInputs = [ shiboken6 ];

Expand All @@ -74,6 +121,8 @@ stdenv.mkDerivation (finalAttrs: {
cp -r PySide6.egg-info $out/${python.sitePackages}/
'';

pythonImportsCheck = [ "PySide6" ];

meta = {
description = "Python bindings for Qt";
license = with lib.licenses; [
Expand Down