1 { lib, stdenv, fetchPypi, python, buildPythonPackage, pycairo, backports_functools_lru_cache
2 , which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver
3 , freetype, libpng, pkg-config, mock, pytz, pygobject3, gobject-introspection, functools32, subprocess32
5 , enableGhostscript ? false, ghostscript ? null, gtk3
6 , enableGtk3 ? false, cairo
7 # darwin has its own "MacOSX" backend
8 , enableTk ? !stdenv.isDarwin, tcl ? null, tk ? null, tkinter ? null, libX11 ? null
9 , enableQt ? false, pyqt4
14 assert enableGhostscript -> ghostscript != null;
15 assert enableTk -> (tcl != null)
20 assert enableQt -> pyqt4 != null;
22 buildPythonPackage rec {
27 inherit pname version;
28 sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5";
32 # https://github.com/matplotlib/matplotlib/pull/12478
34 name = "numpy-1.16-compat.patch";
35 url = "https://github.com/matplotlib/matplotlib/commit/2980184d092382a40ab21f95b79582ffae6e19d6.patch";
36 sha256 = "1c0wj28zy8s5h6qiavx9zzbhlmhjwpzbc3fyyw9039mbnqk0spg2";
40 XDG_RUNTIME_DIR = "/tmp";
42 nativeBuildInputs = [ pkg-config ];
44 buildInputs = [ which sphinx ]
45 ++ lib.optional enableGhostscript ghostscript
46 ++ lib.optional stdenv.isDarwin [ Cocoa ];
48 propagatedBuildInputs =
49 [ cycler dateutil nose numpy pyparsing tornado freetype kiwisolver
51 ++ lib.optional (pythonOlder "3.3") backports_functools_lru_cache
52 ++ lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ]
53 ++ lib.optionals enableTk [ tcl tk tkinter libX11 ]
54 ++ lib.optionals enableQt [ pyqt4 ]
55 ++ lib.optionals python.isPy2 [ functools32 subprocess32 ];
57 setup_cfg = ./setup.cfg;
59 cp "$setup_cfg" ./setup.cfg
62 # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the
63 # corresponding interpreter object for its library paths. This fails if
64 # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both
65 # installed under the same path which is not true in Nix.
66 # With the following patch we just hard-code these paths into the install
70 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
72 lib.optionalString enableTk
73 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py";
75 # Matplotlib needs to be built against a specific version of freetype in
76 # order for all of the tests to pass.
80 description = "Python plotting library, making publication quality plots";
81 homepage = "https://matplotlib.org/";
82 maintainers = with maintainers; [ lovek323 veprbl ];