1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 cython_0,
8 setuptools,
9
10 # dependencies
11 guidata,
12 numpy,
13 pillow,
14 pythonqwt,
15 scikit-image,
16 scipy,
17 tifffile,
18
19 # tests
20 pytestCheckHook,
21 qt6,
22 pyqt6,
23
24 # passthru.tests
25 plotpy,
26 pyside6,
27 qt5,
28 pyqt5,
29 pyside2,
30}:
31
32buildPythonPackage rec {
33 pname = "plotpy";
34 version = "2.6.3";
35 pyproject = true;
36
37 src = fetchFromGitHub {
38 owner = "PlotPyStack";
39 repo = "PlotPy";
40 rev = "refs/tags/v${version}";
41 hash = "sha256-kMVq8X6XP18B5x35BTuC7Q5uFFwds1JxCaxlDuD/UfE=";
42 };
43
44 build-system = [
45 cython_0
46 setuptools
47 ];
48 # Both numpy versions are supported, see:
49 # https://github.com/PlotPyStack/PlotPy/blob/v2.6.2/pyproject.toml#L8-L9
50 postConfigure = ''
51 substituteInPlace pyproject.toml \
52 --replace-fail 'numpy >= 2.0.0' numpy
53 '';
54
55 dependencies = [
56 guidata
57 numpy
58 pillow
59 pythonqwt
60 scikit-image
61 scipy
62 tifffile
63 ];
64
65 nativeCheckInputs = [
66 pytestCheckHook
67 # Not propagating this, to allow one to choose to choose a pyqt / pyside
68 # implementation.
69 pyqt6
70 ];
71
72 preCheck = ''
73 export QT_PLUGIN_PATH="${lib.getBin qt6.qtbase}/${qt6.qtbase.qtPluginPrefix}"
74 export QT_QPA_PLATFORM=offscreen
75 # https://github.com/NixOS/nixpkgs/issues/255262
76 cd $out
77 '';
78
79 pythonImportsCheck = [
80 "plotpy"
81 "plotpy.tests"
82 ];
83
84 passthru = {
85 tests = {
86 # Upstream doesn't officially supports all of them, although they use
87 # qtpy, see: https://github.com/PlotPyStack/PlotPy/issues/20 . When this
88 # package was created, all worked besides withPySide2, with which there
89 # was a peculiar segmentation fault during the tests. In anycase, PySide2
90 # shouldn't be used for modern applications.
91 withPyQt6 = plotpy.override {
92 pyqt6 = pyqt6;
93 qt6 = qt6;
94 };
95 withPySide6 = plotpy.override {
96 pyqt6 = pyside6;
97 qt6 = qt6;
98 };
99 withPyQt5 = plotpy.override {
100 pyqt6 = pyqt5;
101 qt6 = qt5;
102 };
103 withPySide2 = plotpy.override {
104 pyqt6 = pyside2;
105 qt6 = qt5;
106 };
107 };
108 };
109
110 meta = {
111 description = "Curve and image plotting tools for Python/Qt applications";
112 homepage = "https://github.com/PlotPyStack/PlotPy";
113 changelog = "https://github.com/PlotPyStack/PlotPy/blob/${src.rev}/CHANGELOG.md";
114 license = lib.licenses.bsd3;
115 maintainers = with lib.maintainers; [ doronbehar ];
116 };
117}