Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 2.7 kB view raw
1{ stdenv, fetchPypi, python, buildPythonPackage, isPy3k, pycairo, backports_functools_lru_cache 2, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver 3, freetype, libpng, pkgconfig, mock, pytz, pygobject3, gobject-introspection 4, certifi, pillow 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 10, Cocoa 11, pythonOlder 12}: 13 14assert enableGhostscript -> ghostscript != null; 15assert enableTk -> (tcl != null) 16 && (tk != null) 17 && (tkinter != null) 18 && (libX11 != null) 19 ; 20assert enableQt -> pyqt5 != null; 21 22buildPythonPackage rec { 23 version = "3.3.1"; 24 pname = "matplotlib"; 25 26 disabled = !isPy3k; 27 28 src = fetchPypi { 29 inherit pname version; 30 sha256 = "87f53bcce90772f942c2db56736788b39332d552461a5cb13f05ff45c1680f0e"; 31 }; 32 33 XDG_RUNTIME_DIR = "/tmp"; 34 35 nativeBuildInputs = [ pkgconfig ]; 36 37 buildInputs = [ which sphinx ] 38 ++ stdenv.lib.optional enableGhostscript ghostscript 39 ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ]; 40 41 propagatedBuildInputs = 42 [ cycler dateutil numpy pyparsing tornado freetype kiwisolver 43 certifi libpng mock pytz pillow ] 44 ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ] 45 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] 46 ++ stdenv.lib.optionals enableQt [ pyqt5 ]; 47 48 setup_cfg = if stdenv.isDarwin then ./setup-darwin.cfg else ./setup.cfg; 49 preBuild = '' 50 cp "$setup_cfg" ./setup.cfg 51 ''; 52 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 58 # script. 59 postPatch = 60 let 61 inherit (stdenv.lib.strings) substring; 62 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; 63 in 64 stdenv.lib.optionalString enableTk 65 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; 66 67 # Matplotlib needs to be built against a specific version of freetype in 68 # order for all of the tests to pass. 69 doCheck = false; 70 71 meta = with stdenv.lib; { 72 description = "Python plotting library, making publication quality plots"; 73 homepage = "https://matplotlib.org/"; 74 maintainers = with maintainers; [ lovek323 veprbl ]; 75 }; 76 77}