1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6 pytestCheckHook,
7 setuptools,
8 matplotlib,
9 numpy,
10 networkx,
11 pypng,
12 scipy,
13}:
14
15buildPythonPackage rec {
16 pname = "matplotx";
17 version = "0.3.10";
18 format = "pyproject";
19
20 src = fetchFromGitHub {
21 owner = "nschloe";
22 repo = "matplotx";
23 rev = "v${version}";
24 hash = "sha256-EWEiEY23uFwd/vgWVLCH/buUmgRqz1rqqlJEdXINYMg=";
25 };
26
27 propagatedBuildInputs = [
28 setuptools
29 matplotlib
30 numpy
31 ];
32
33 optional-dependencies = {
34 all = [
35 networkx
36 pypng
37 scipy
38 ];
39 contour = [ networkx ];
40 spy = [
41 pypng
42 scipy
43 ];
44 };
45
46 # This variable is needed to suppress the "Trace/BPT trap: 5" error in Darwin's checkPhase.
47 # Not sure of the details, but we can avoid it by changing the matplotlib backend during testing.
48 env.MPLBACKEND = lib.optionalString stdenv.hostPlatform.isDarwin "Agg";
49
50 nativeCheckInputs = [ pytestCheckHook ] ++ optional-dependencies.all;
51
52 disabledTestPaths = [
53 "tests/test_spy.py" # Requires meshzoo (non-free) and pytest-codeblocks (not packaged)
54 ];
55
56 pythonImportsCheck = [ "matplotx" ];
57
58 meta = {
59 homepage = "https://github.com/nschloe/matplotx";
60 description = "More styles and useful extensions for Matplotlib";
61 mainProgram = "matplotx";
62 changelog = "https://github.com/nschloe/matplotx/releases/tag/v${version}";
63 license = lib.licenses.mit;
64 maintainers = with lib.maintainers; [ swflint ];
65 };
66}