Merge pull request #230986 from Enzime/add/pyside6

python3.pkgs.{shiboken,pyside}6: init at 6.5.0
This commit is contained in:
Weijia Wang
2023-05-11 08:45:02 +03:00
committed by GitHub
4 changed files with 240 additions and 0 deletions
@@ -0,0 +1,77 @@
{ lib
, stdenv
, cmake
, ninja
, qt6
, python
, shiboken6
, libxcrypt
}:
stdenv.mkDerivation rec {
pname = "pyside6";
inherit (shiboken6) version src;
sourceRoot = "pyside-setup-everywhere-src-${lib.versions.majorMinor version}/sources/${pname}";
postPatch = ''
# Don't ignore optional Qt modules
substituteInPlace cmake/PySideHelpers.cmake \
--replace \
'string(FIND "''${_module_dir}" "''${_core_abs_dir}" found_basepath)' \
'set (found_basepath 0)'
'';
nativeBuildInputs = [
cmake
ninja
python
];
buildInputs = with qt6; [
# required
qtbase
# optional
qt3d
qtcharts
qtconnectivity
qtdatavis3d
qtdeclarative
qthttpserver
qtmultimedia
qtnetworkauth
qtquick3d
qtremoteobjects
qtscxml
qtsensors
qtspeech
qtsvg
qttools
qtwebchannel
qtwebengine
qtwebsockets
] ++ lib.optionals (python.pythonOlder "3.9") [
# see similar issue: 202262
# libxcrypt is required for crypt.h for building older python modules
libxcrypt
];
propagatedBuildInputs = [
shiboken6
];
cmakeFlags = [
"-DBUILD_TESTS=OFF"
];
dontWrapQtApps = true;
meta = with lib; {
description = "Python bindings for Qt";
license = with licenses; [ lgpl3Only gpl2Only gpl3Only ];
homepage = "https://wiki.qt.io/Qt_for_Python";
maintainers = with maintainers; [ gebner Enzime ];
broken = stdenv.isDarwin;
};
}
@@ -0,0 +1,75 @@
{ lib
, fetchurl
, llvmPackages
, python
, qt6
, cmake
, autoPatchelfHook
, stdenv
, libxcrypt
}:
llvmPackages.stdenv.mkDerivation rec {
pname = "shiboken6";
version = "6.5.0";
src = fetchurl {
# https://download.qt.io/official_releases/QtForPython/shiboken6/
url = "https://download.qt.io/official_releases/QtForPython/shiboken6/PySide6-${version}-src/pyside-setup-everywhere-src-${version}.tar.xz";
sha256 = "sha256-bvU7KRJyZ+OBkX5vk5nOdg7cBkTNWDGYix3nLJ1YOrQ=";
};
sourceRoot = "pyside-setup-everywhere-src-${lib.versions.majorMinor version}/sources/${pname}";
patches = [
./fix-include-qt-headers.patch
];
# Due to Shiboken.abi3.so being linked to libshiboken6.abi3.so.6.5 in the build tree,
# we need to remove the build tree reference from the RPATH and then add the correct
# directory to the RPATH. On Linux, the second part is handled by autoPatchelfHook.
# https://bugreports.qt.io/browse/PYSIDE-2233
postBuild = ''
echo "fixing RPATH of Shiboken.abi3.so"
'' + (if stdenv.isDarwin then ''
invalid_rpaths=$(otool -l Shiboken.abi3.so | awk '
/^[^ ]/ {f = 0}
$2 == "LC_RPATH" && $1 == "cmd" {f = 1}
f && gsub(/^ *path | \(offset [0-9]+\)$/, "") == 2
' | grep --invert-match /nix/store)
install_name_tool $(echo $invalid_rpaths | sed 's/^/-delete_rpath /' | tr '\n' ' ' | sed 's/ $//') Shiboken.abi3.so
install_name_tool -add_rpath $out/lib Shiboken.abi3.so
'' else ''
patchelf Shiboken.abi3.so --shrink-rpath --allowed-rpath-prefixes /nix/store
'');
cmakeFlags = [
"-DBUILD_TESTS=OFF"
];
dontWrapQtApps = true;
nativeBuildInputs = [
cmake
python
] ++ lib.optionals stdenv.isLinux [
autoPatchelfHook
];
buildInputs = [
llvmPackages.llvm
llvmPackages.libclang
qt6.qtbase
] ++ (lib.optionals (python.pythonOlder "3.9") [
# see similar issue: 202262
# libxcrypt is required for crypt.h for building older python modules
libxcrypt
]);
meta = with lib; {
description = "Generator for the pyside6 Qt bindings";
license = with licenses; [ lgpl3Only gpl2Only gpl3Only ];
homepage = "https://wiki.qt.io/Qt_for_Python";
maintainers = with maintainers; [ gebner Enzime ];
};
}
@@ -0,0 +1,80 @@
--- a/ApiExtractor/clangparser/compilersupport.cpp
+++ b/ApiExtractor/clangparser/compilersupport.cpp
@@ -16,6 +16,7 @@
#include <QtCore/QStandardPaths>
#include <QtCore/QStringList>
#include <QtCore/QVersionNumber>
+#include <QtCore/QRegularExpression>
#include <clang-c/Index.h>
@@ -341,6 +342,13 @@ QByteArrayList emulatedCompilerOptions()
{
QByteArrayList result;
HeaderPaths headerPaths;
+
+ bool isNixDebug = qgetenv("NIX_DEBUG").toInt() > 0;
+ // examples:
+ // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtsensors-6.4.2-dev/include
+ // /nix/store/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-qtbase-6.4.2-dev/include
+ QRegularExpression qtHeaderRegex(uR"(/[0-9a-z]{32}-qt[a-z0-9]+-)"_s);
+
switch (compiler()) {
case Compiler::Msvc:
result.append(QByteArrayLiteral("-fms-compatibility-version=19.26.28806"));
@@ -352,9 +360,30 @@ QByteArrayList emulatedCompilerOptions()
appendClangBuiltinIncludes(&headerPaths);
break;
case Compiler::Clang:
- headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
+ // fix: error: cannot jump from switch statement to this case label: case Compiler::Gpp
+ // note: jump bypasses variable initialization: const HeaderPaths clangPaths =
+ {
+ //headerPaths.append(gppInternalIncludePaths(compilerFromCMake(u"clang++"_s)));
+ // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
+ // PySide requires that Qt headers are not -isystem
+ // https://bugreports.qt.io/browse/PYSIDE-787
+ const HeaderPaths clangPaths = gppInternalIncludePaths(compilerFromCMake(u"clang++"_qs));
+ for (const HeaderPath &h : clangPaths) {
+ auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
+ if (!match.hasMatch()) {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
+ // add using -isystem
+ headerPaths.append(h);
+ } else {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
+ headerPaths.append({h.path, HeaderType::Standard});
+ }
+ }
result.append(noStandardIncludeOption());
break;
+ }
case Compiler::Gpp:
if (needsClangBuiltinIncludes())
appendClangBuiltinIncludes(&headerPaths);
@@ -363,8 +392,20 @@ QByteArrayList emulatedCompilerOptions()
// <type_traits> etc (g++ 11.3).
const HeaderPaths gppPaths = gppInternalIncludePaths(compilerFromCMake(u"g++"_qs));
for (const HeaderPath &h : gppPaths) {
- if (h.path.contains("c++") || h.path.contains("sysroot"))
+ // fix: qt.shiboken: x is specified in typesystem, but not defined. This could potentially lead to compilation errors.
+ // PySide requires that Qt headers are not -isystem
+ // https://bugreports.qt.io/browse/PYSIDE-787
+ auto match = qtHeaderRegex.match(QString::fromUtf8(h.path));
+ if (!match.hasMatch()) {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found non-qt header: " << h.path;
+ // add using -isystem
headerPaths.append(h);
+ } else {
+ if (isNixDebug)
+ qDebug() << "shiboken compilersupport.cpp: found qt header: " << h.path;
+ headerPaths.append({h.path, HeaderType::Standard});
+ }
}
break;
}
--
2.39.0
+8
View File
@@ -9175,6 +9175,10 @@ self: super: with self; {
inherit (pkgs) cmake ninja qt5;
});
pyside6 = toPythonModule (callPackage ../development/python-modules/pyside6 {
inherit (pkgs) cmake ninja qt6;
});
pyside = callPackage ../development/python-modules/pyside {
inherit (pkgs) mesa;
};
@@ -10953,6 +10957,10 @@ self: super: with self; {
inherit (pkgs) cmake llvmPackages qt5;
});
shiboken6 = toPythonModule (callPackage ../development/python-modules/shiboken6 {
inherit (pkgs) cmake llvmPackages qt6;
});
shippai = callPackage ../development/python-modules/shippai { };
shiv = callPackage ../development/python-modules/shiv { };