1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 cython,
9 setuptools,
10
11 # dependencies
12 guidata,
13 numpy,
14 pillow,
15 pythonqwt,
16 scikit-image,
17 scipy,
18 tifffile,
19
20 # tests
21 pytestCheckHook,
22 qt6,
23 pyqt6,
24
25 # passthru.tests
26 plotpy,
27 pyside6,
28 qt5,
29 pyqt5,
30 pyside2,
31}:
32
33buildPythonPackage rec {
34 pname = "plotpy";
35 version = "2.7.5";
36 pyproject = true;
37
38 src = fetchFromGitHub {
39 owner = "PlotPyStack";
40 repo = "PlotPy";
41 tag = "v${version}";
42 hash = "sha256-g26CWUQTaky7h1wHd9CAB4AEvk24frN7f6wqs1fefJw=";
43 };
44
45 build-system = [
46 cython
47 setuptools
48 ];
49
50 dependencies = [
51 guidata
52 numpy
53 pillow
54 pythonqwt
55 scikit-image
56 scipy
57 tifffile
58 ];
59
60 nativeCheckInputs = [
61 pytestCheckHook
62 # Not propagating this, to allow one to choose to choose a pyqt / pyside
63 # implementation.
64 pyqt6
65 ];
66
67 preCheck = ''
68 export QT_PLUGIN_PATH="${lib.getBin qt6.qtbase}/${qt6.qtbase.qtPluginPrefix}"
69 export QT_QPA_PLATFORM=offscreen
70 # https://github.com/NixOS/nixpkgs/issues/255262
71 cd $out
72 '';
73
74 disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [
75 # Fatal Python error: Segmentation fault
76 # in plotpy/widgets/resizedialog.py", line 99 in __init__
77 "test_resize_dialog"
78 "test_tool"
79 ];
80
81 pythonImportsCheck = [
82 "plotpy"
83 "plotpy.tests"
84 ];
85
86 passthru = {
87 tests = {
88 withPyQt6 = plotpy.override {
89 pyqt6 = pyqt6;
90 qt6 = qt6;
91 };
92 withPyQt5 = plotpy.override {
93 pyqt6 = pyqt5;
94 qt6 = qt5;
95 };
96 };
97 # Upstream doesn't officially supports all of them, although they use
98 # qtpy, see: https://github.com/PlotPyStack/PlotPy/issues/20
99 knownFailingTests = {
100 # Was failing with a peculiar segmentation fault during the tests, since
101 # this package was added to Nixpkgs. This is not too bad as PySide2
102 # shouldn't be used for modern applications.
103 withPySide2 = plotpy.override {
104 pyqt6 = pyside2;
105 qt6 = qt5;
106 };
107 # Has started failing too similarly to pyside2, ever since a certain
108 # version bump. See also:
109 # https://github.com/PlotPyStack/PlotPy/blob/v2.7.4/README.md?plain=1#L62
110 withPySide6 = plotpy.override {
111 pyqt6 = pyside6;
112 qt6 = qt6;
113 };
114 };
115 };
116
117 meta = {
118 description = "Curve and image plotting tools for Python/Qt applications";
119 homepage = "https://github.com/PlotPyStack/PlotPy";
120 changelog = "https://github.com/PlotPyStack/PlotPy/blob/${src.tag}/CHANGELOG.md";
121 license = lib.licenses.bsd3;
122 maintainers = with lib.maintainers; [ doronbehar ];
123 };
124}