1 { lib, stdenv, fetchPypi, python, buildPythonPackage, isPy3k, 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
5 , enableGhostscript ? true, 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, pyqt5 ? null
14 assert enableGhostscript -> ghostscript != null;
15 assert enableTk -> (tcl != null)
20 assert enableQt -> pyqt5 != null;
22 buildPythonPackage rec {
29 inherit pname version;
30 sha256 = "3e477db76c22929e4c6876c44f88d790aacdf3c3f8f3a90cb1975c0bf37825b0";
33 XDG_RUNTIME_DIR = "/tmp";
35 nativeBuildInputs = [ pkg-config ];
37 buildInputs = [ which sphinx ]
38 ++ lib.optional enableGhostscript ghostscript
39 ++ lib.optional stdenv.isDarwin [ Cocoa ];
41 propagatedBuildInputs =
42 [ cycler dateutil numpy pyparsing tornado freetype kiwisolver
43 certifi libpng mock pytz pillow ]
44 ++ lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ]
45 ++ lib.optionals enableTk [ tcl tk tkinter libX11 ]
46 ++ lib.optionals enableQt [ pyqt5 ];
48 setup_cfg = if stdenv.isDarwin then ./setup-darwin.cfg else ./setup.cfg;
50 cp "$setup_cfg" ./setup.cfg
53 # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the
54 # corresponding interpreter object for its library paths. This fails if
55 # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both
56 # installed under the same path which is not true in Nix.
57 # With the following patch we just hard-code these paths into the install
61 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
63 lib.optionalString enableTk
64 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py";
66 # Matplotlib needs to be built against a specific version of freetype in
67 # order for all of the tests to pass.
71 description = "Python plotting library, making publication quality plots";
72 homepage = "https://matplotlib.org/";
73 maintainers = with maintainers; [ lovek323 veprbl ];