1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools-scm,
8
9 # dependencies
10 matplotlib,
11 mizani,
12 pandas,
13 patsy,
14 scipy,
15 statsmodels,
16
17 # tests
18 geopandas,
19 pytestCheckHook,
20 scikit-misc,
21}:
22
23buildPythonPackage rec {
24 pname = "plotnine";
25 version = "0.14.5";
26 pyproject = true;
27
28 src = fetchFromGitHub {
29 owner = "has2k1";
30 repo = "plotnine";
31 tag = "v${version}";
32 hash = "sha256-3ImNLmZ8RhhqRGv/FtdjbHmdOtgQC7hjUsViEQYE8Ao=";
33 };
34
35 postPatch = ''
36 substituteInPlace pyproject.toml \
37 --replace-fail " --cov=plotnine --cov-report=xml" ""
38 '';
39
40 build-system = [ setuptools-scm ];
41
42 dependencies = [
43 matplotlib
44 mizani
45 pandas
46 patsy
47 scipy
48 statsmodels
49 ];
50
51 nativeCheckInputs = [
52 geopandas
53 pytestCheckHook
54 scikit-misc
55 ];
56
57 preCheck = ''
58 export HOME=$(mktemp -d)
59 '';
60
61 pythonImportsCheck = [ "plotnine" ];
62
63 disabledTests = [
64 # Tries to change locale. The issued warning causes this test to fail.
65 # UserWarning: Could not set locale to English/United States. Some date-related tests may fail
66 "test_no_after_scale_warning"
67 ];
68
69 disabledTestPaths = [
70 # Assertion Errors:
71 # Generated plot images do not exactly match the expected files.
72 # After manually checking, this is caused by extremely subtle differences in label placement.
73 "tests/test_aes.py"
74 "tests/test_annotation_logticks.py"
75 "tests/test_coords.py"
76 "tests/test_facet_labelling.py"
77 "tests/test_facets.py"
78 "tests/test_geom_bar_col_histogram.py"
79 "tests/test_geom_bin_2d.py"
80 "tests/test_geom_boxplot.py"
81 "tests/test_geom_count.py"
82 "tests/test_geom_density_2d.py"
83 "tests/test_geom_density.py"
84 "tests/test_geom_dotplot.py"
85 "tests/test_geom_freqpoly.py"
86 "tests/test_geom_map.py"
87 "tests/test_geom_path_line_step.py"
88 "tests/test_geom_point.py"
89 "tests/test_geom_raster.py"
90 "tests/test_geom_rect_tile.py"
91 "tests/test_geom_ribbon_area.py"
92 "tests/test_geom_sina.py"
93 "tests/test_geom_smooth.py"
94 "tests/test_geom_text_label.py"
95 "tests/test_geom_violin.py"
96 "tests/test_layout.py"
97 "tests/test_position.py"
98 "tests/test_qplot.py"
99 "tests/test_scale_internals.py"
100 "tests/test_scale_labelling.py"
101 "tests/test_stat_ecdf.py"
102 "tests/test_stat_function.py"
103 "tests/test_stat_summary.py"
104 "tests/test_theme.py"
105
106 # Linting / formatting: useless as it has nothing to do with the package functioning
107 # Disabling this prevents adding a dependency on 'ruff' and 'black'.
108 "tests/test_lint_and_format.py"
109 ];
110
111 meta = {
112 description = "Grammar of graphics for Python";
113 homepage = "https://plotnine.readthedocs.io/";
114 changelog = "https://github.com/has2k1/plotnine/releases/tag/${src.tag}";
115 license = lib.licenses.mit;
116 maintainers = with lib.maintainers; [ onny ];
117 };
118}