Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv, fetchPypi, python, buildPythonPackage, pycairo, backports_functools_lru_cache 2, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver 3, freetype, libpng, pkgconfig, mock, pytz, pygobject3, gobject-introspection, functools32, subprocess32 4, fetchpatch 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 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 -> pyqt4 != null; 21 22buildPythonPackage rec { 23 version = "2.2.3"; 24 pname = "matplotlib"; 25 26 src = fetchPypi { 27 inherit pname version; 28 sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5"; 29 }; 30 31 patches = [ 32 # https://github.com/matplotlib/matplotlib/pull/12478 33 (fetchpatch { 34 name = "numpy-1.16-compat.patch"; 35 url = "https://github.com/matplotlib/matplotlib/commit/2980184d092382a40ab21f95b79582ffae6e19d6.patch"; 36 sha256 = "1c0wj28zy8s5h6qiavx9zzbhlmhjwpzbc3fyyw9039mbnqk0spg2"; 37 }) 38 ]; 39 40 XDG_RUNTIME_DIR = "/tmp"; 41 42 nativeBuildInputs = [ pkgconfig ]; 43 44 buildInputs = [ which sphinx ] 45 ++ stdenv.lib.optional enableGhostscript ghostscript 46 ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ]; 47 48 propagatedBuildInputs = 49 [ cycler dateutil nose numpy pyparsing tornado freetype kiwisolver 50 libpng mock pytz ] 51 ++ stdenv.lib.optional (pythonOlder "3.3") backports_functools_lru_cache 52 ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ] 53 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] 54 ++ stdenv.lib.optionals enableQt [ pyqt4 ] 55 ++ stdenv.lib.optionals python.isPy2 [ functools32 subprocess32 ]; 56 57 setup_cfg = ./setup.cfg; 58 preBuild = '' 59 cp "$setup_cfg" ./setup.cfg 60 ''; 61 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 67 # script. 68 postPatch = 69 let 70 inherit (stdenv.lib.strings) substring; 71 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; 72 in 73 stdenv.lib.optionalString enableTk 74 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; 75 76 # Matplotlib needs to be built against a specific version of freetype in 77 # order for all of the tests to pass. 78 doCheck = false; 79 80 meta = with stdenv.lib; { 81 description = "Python plotting library, making publication quality plots"; 82 homepage = "https://matplotlib.org/"; 83 maintainers = with maintainers; [ lovek323 veprbl ]; 84 }; 85 86}