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

pyside6: ensure PySide6 can be imported and used #1808

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
poetry = {
# https://wiki.nixos.org/wiki/Flakes
type = "app";
program = pkgs.poetry;
program = "${pkgs.poetry}/bin/poetry";
};
poetry2nix = flake-utils.lib.mkApp { drv = packages.poetry2nix; };
default = apps.poetry2nix;
Expand Down
40 changes: 27 additions & 13 deletions overrides/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ lib.composeManyExtensions [

msgspec = prev.msgspec.overridePythonAttrs (old: {
# crash during integer serialization - see https://github.com/jcrist/msgspec/issues/730
hardeningDisable = old.hardeningDisable or [] ++ [ "fortify" ];
hardeningDisable = old.hardeningDisable or [ ] ++ [ "fortify" ];
});

munch = prev.munch.overridePythonAttrs (
Expand Down Expand Up @@ -2774,15 +2774,12 @@ lib.composeManyExtensions [
});

pyside6-essentials = prev.pyside6-essentials.overridePythonAttrs (old: lib.optionalAttrs stdenv.isLinux {
autoPatchelfIgnoreMissingDeps = [ "libmysqlclient.so.21" "libmimerapi.so" "libQt6*" ];
autoPatchelfIgnoreMissingDeps = [ "libmysqlclient.so.21" "libmimerapi.so" "libQt6EglFsKmsGbmSupport.so*" ];
preFixup = ''
addAutoPatchelfSearchPath $out/${final.python.sitePackages}/PySide6
addAutoPatchelfSearchPath ${final.shiboken6}/${final.python.sitePackages}/shiboken6
'';
postInstall = ''
rm -r $out/${final.python.sitePackages}/PySide6/__pycache__
'';
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [
pkgs.qt6.full
pkgs.libxkbcommon
pkgs.gtk3
pkgs.speechd
Expand All @@ -2802,30 +2799,47 @@ lib.composeManyExtensions [
pkgs.xorg.xcbutilwm
pkgs.libdrm
pkgs.pulseaudio
final.shiboken6
];
pythonImportsCheck = [
"PySide6"
"PySide6.QtCore"
];
postInstall = ''
python -c 'import PySide6; print(PySide6.__all__)'
'';
});

pyside6-addons = prev.pyside6-addons.overridePythonAttrs (old: lib.optionalAttrs stdenv.isLinux {
pyside6-addons = prev.pyside6-addons.overridePythonAttrs (_old: lib.optionalAttrs stdenv.isLinux {
autoPatchelfIgnoreMissingDeps = [
"libmysqlclient.so.21"
"libmimerapi.so"
"libQt6Quick3DSpatialAudio.so.6"
"libQt6Quick3DHelpersImpl.so.6"
];
preFixup = ''
addAutoPatchelfSearchPath ${final.shiboken6}/${final.python.sitePackages}/shiboken6
addAutoPatchelfSearchPath ${final.pyside6-essentials}/${final.python.sitePackages}/PySide6
addAutoPatchelfSearchPath $out/${final.python.sitePackages}/PySide6
'';
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [
buildInputs = [
pkgs.nss
pkgs.xorg.libXtst
pkgs.alsa-lib
pkgs.xorg.libxshmfence
pkgs.xorg.libxkbfile
];
postInstall = ''
rm -r $out/${final.python.sitePackages}/PySide6/__pycache__
});
pyside6 = prev.pyside6.overridePythonAttrs (_old: {
# The PySide6/__init__.py script tries to find the Qt libraries
# relative to its own path in the installed site-packages directory.
# This then fails to find the paths from pyside6-essentials and
# pyside6-addons because they are installed into different directories.
#
# To work around this issue we symlink all of the files resulting from
# those packages into the aggregated `pyside6` output directories.
#
# See https://github.com/nix-community/poetry2nix/issues/1791 for more details.
postFixup = ''
${pkgs.xorg.lndir}/bin/lndir ${final.pyside6-essentials}/${final.python.sitePackages}/PySide6 $out/${final.python.sitePackages}/PySide6
${pkgs.xorg.lndir}/bin/lndir ${final.pyside6-addons}/${final.python.sitePackages}/PySide6 $out/${final.python.sitePackages}/PySide6
'';
});

Expand Down
29 changes: 22 additions & 7 deletions tests/pyside6/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
{ lib, poetry2nix, python310 }:

poetry2nix.mkPoetryApplication {
python = python310;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
{ lib, poetry2nix, python310, runCommand, gnugrep }:
let
app = poetry2nix.mkPoetryApplication {
python = python310;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
src = lib.cleanSource ./.;
pythonImportsCheck = [
"test_pyside6"
];
};
in
(runCommand "test-pyside6"
{
nativeBuildInputs = [ gnugrep ];
} ''
set -euo pipefail
${app}/bin/test_pyside6 > $out
grep QPoint < $out
grep Success < $out
'') // {
inherit (app.python.pkgs) pyside6-addons pyside6-essentials;
}
4 changes: 4 additions & 0 deletions tests/pyside6/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "test_pyside6"
version = "0.1.0"
description = ""
authors = ["considerate <[email protected]>"]
packages = [{include = "test_pyside6", from = "."}]

[tool.poetry.dependencies]
python = ">=3.10,<3.12"
Expand All @@ -11,6 +12,9 @@ pyside6 = "<6.5.3"

[tool.poetry.dev-dependencies]

[tool.poetry.scripts]
test_pyside6 = "test_pyside6:main"

[build-system]
requires = ["poetry-core>=1"]
build-backend = "poetry.core.masonry.api"
Empty file removed tests/pyside6/test_pyside6.py
Empty file.
12 changes: 12 additions & 0 deletions tests/pyside6/test_pyside6/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from PySide6.QtCore import QPoint
import sys


def main():
print(QPoint(2.5, 6.0))

print("Success")


if __name__ == "__main__":
main()
Loading