Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 19.09 94 lines 3.4 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 4, enableGhostscript ? true, ghostscript ? null, gtk3 5, enableGtk2 ? false, pygtk ? null, gobject-introspection 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, libcxx 11, Cocoa 12, pythonOlder 13}: 14 15assert enableGhostscript -> ghostscript != null; 16assert enableGtk2 -> pygtk != null; 17assert enableTk -> (tcl != null) 18 && (tk != null) 19 && (tkinter != null) 20 && (libX11 != null) 21 ; 22assert enableQt -> pyqt4 != null; 23 24buildPythonPackage rec { 25 version = "3.1.1"; 26 pname = "matplotlib"; 27 28 disabled = !isPy3k; 29 30 src = fetchPypi { 31 inherit pname version; 32 sha256 = "1febd22afe1489b13c6749ea059d392c03261b2950d1d45c17e3aed812080c93"; 33 }; 34 35 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; 36 37 XDG_RUNTIME_DIR = "/tmp"; 38 39 nativeBuildInputs = [ pkgconfig ]; 40 41 buildInputs = [ python which sphinx stdenv ] 42 ++ stdenv.lib.optional enableGhostscript ghostscript 43 ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ]; 44 45 propagatedBuildInputs = 46 [ cycler dateutil nose numpy pyparsing tornado freetype kiwisolver 47 libpng mock pytz ] 48 ++ stdenv.lib.optional (pythonOlder "3.3") backports_functools_lru_cache 49 ++ stdenv.lib.optional enableGtk2 pygtk 50 ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ] 51 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] 52 ++ stdenv.lib.optionals enableQt [ pyqt4 ]; 53 54 patches = 55 [ ./basedirlist.patch ]; 56 57 # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the 58 # corresponding interpreter object for its library paths. This fails if 59 # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both 60 # installed under the same path which is not true in Nix. 61 # With the following patch we just hard-code these paths into the install 62 # script. 63 postPatch = 64 let 65 inherit (stdenv.lib.strings) substring; 66 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; 67 in 68 stdenv.lib.optionalString enableTk 69 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; 70 71 checkPhase = '' 72 ${python.interpreter} tests.py 73 ''; 74 75 # Test data is not included in the distribution (the `tests` folder 76 # is missing) 77 doCheck = false; 78 79 prePatch = '' 80 # Failing test: ERROR: matplotlib.tests.test_style.test_use_url 81 sed -i 's/test_use_url/fails/' lib/matplotlib/tests/test_style.py 82 # Failing test: ERROR: test suite for <class 'matplotlib.sphinxext.tests.test_tinypages.TestTinyPages'> 83 sed -i 's/TestTinyPages/fails/' lib/matplotlib/sphinxext/tests/test_tinypages.py 84 # Transient errors 85 sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py 86 ''; 87 88 meta = with stdenv.lib; { 89 description = "Python plotting library, making publication quality plots"; 90 homepage = "https://matplotlib.org/"; 91 maintainers = with maintainers; [ lovek323 ]; 92 }; 93 94}