Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 91 lines 3.3 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, enableGhostscript ? true, ghostscript ? null, gtk3 5, enableGtk3 ? false, cairo 6# darwin has its own "MacOSX" backend 7, enableTk ? !stdenv.isDarwin, tcl ? null, tk ? null, tkinter ? null, libX11 ? null 8, enableQt ? false, pyqt5 ? null 9, libcxx 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.1.3"; 24 pname = "matplotlib"; 25 26 disabled = !isPy3k; 27 28 src = fetchPypi { 29 inherit pname version; 30 sha256 = "db3121f12fb9b99f105d1413aebaeb3d943f269f3d262b45586d12765866f0c6"; 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.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ] 48 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] 49 ++ stdenv.lib.optionals enableQt [ pyqt5 ]; 50 51 patches = 52 [ ./basedirlist.patch ]; 53 54 # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the 55 # corresponding interpreter object for its library paths. This fails if 56 # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both 57 # installed under the same path which is not true in Nix. 58 # With the following patch we just hard-code these paths into the install 59 # script. 60 postPatch = 61 let 62 inherit (stdenv.lib.strings) substring; 63 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; 64 in 65 stdenv.lib.optionalString enableTk 66 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; 67 68 checkPhase = '' 69 ${python.interpreter} tests.py 70 ''; 71 72 # Test data is not included in the distribution (the `tests` folder 73 # is missing) 74 doCheck = false; 75 76 prePatch = '' 77 # Failing test: ERROR: matplotlib.tests.test_style.test_use_url 78 sed -i 's/test_use_url/fails/' lib/matplotlib/tests/test_style.py 79 # Failing test: ERROR: test suite for <class 'matplotlib.sphinxext.tests.test_tinypages.TestTinyPages'> 80 sed -i 's/TestTinyPages/fails/' lib/matplotlib/sphinxext/tests/test_tinypages.py 81 # Transient errors 82 sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py 83 ''; 84 85 meta = with stdenv.lib; { 86 description = "Python plotting library, making publication quality plots"; 87 homepage = "https://matplotlib.org/"; 88 maintainers = with maintainers; [ lovek323 ]; 89 }; 90 91}