Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 16.09 3.3 kB view raw
1{ stdenv, fetchurl, python, buildPythonPackage, pycairo 2, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado 3, freetype, libpng, pkgconfig, mock, pytz, pygobject3 4, enableGhostscript ? false, ghostscript ? null, gtk3 5, enableGtk2 ? false, pygtk ? null, gobjectIntrospection 6, enableGtk3 ? false, cairo 7, enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null 8, Cocoa, Foundation, CoreData, cf-private, libobjc, libcxx 9}: 10 11assert enableGhostscript -> ghostscript != null; 12assert enableGtk2 -> pygtk != null; 13assert enableTk -> (tcl != null) 14 && (tk != null) 15 && (tkinter != null) 16 && (libX11 != null) 17 ; 18 19buildPythonPackage rec { 20 name = "matplotlib-${version}"; 21 version = "1.5.1"; 22 23 src = fetchurl { 24 url = "mirror://pypi/m/matplotlib/${name}.tar.gz"; 25 sha256 = "3ab8d968eac602145642d0db63dd8d67c85e9a5444ce0e2ecb2a8fedc7224d40"; 26 }; 27 28 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; 29 30 XDG_RUNTIME_DIR = "/tmp"; 31 32 buildInputs = [ python which sphinx stdenv ] 33 ++ stdenv.lib.optional enableGhostscript ghostscript 34 ++ stdenv.lib.optionals stdenv.isDarwin [ Cocoa Foundation CoreData 35 cf-private libobjc ]; 36 37 propagatedBuildInputs = 38 [ cycler dateutil nose numpy pyparsing tornado freetype 39 libpng pkgconfig mock pytz 40 ] 41 ++ stdenv.lib.optional enableGtk2 pygtk 42 ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ] 43 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ]; 44 45 patches = 46 [ ./basedirlist.patch ] ++ 47 stdenv.lib.optionals stdenv.isDarwin [ ./darwin-stdenv.patch ]; 48 49 # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the 50 # corresponding interpreter object for its library paths. This fails if 51 # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both 52 # installed under the same path which is not true in Nix. 53 # With the following patch we just hard-code these paths into the install 54 # script. 55 postPatch = 56 let 57 inherit (stdenv.lib.strings) substring; 58 tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; 59 in 60 stdenv.lib.optionalString enableTk 61 "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; 62 63 checkPhase = '' 64 ${python.interpreter} tests.py 65 ''; 66 67 # The entry point for running tests, tests.py, is not included in the release. 68 # https://github.com/matplotlib/matplotlib/issues/6017 69 doCheck = false; 70 71 prePatch = '' 72 # Failing test: ERROR: matplotlib.tests.test_style.test_use_url 73 sed -i 's/test_use_url/fails/' lib/matplotlib/tests/test_style.py 74 # Failing test: ERROR: test suite for <class 'matplotlib.sphinxext.tests.test_tinypages.TestTinyPages'> 75 sed -i 's/TestTinyPages/fails/' lib/matplotlib/sphinxext/tests/test_tinypages.py 76 # Transient errors 77 sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py 78 ''; 79 80 meta = with stdenv.lib; { 81 description = "Python plotting library, making publication quality plots"; 82 homepage = "http://matplotlib.sourceforge.net/"; 83 maintainers = with maintainers; [ lovek323 ]; 84 platforms = platforms.unix; 85 }; 86 87}