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