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