git.iko.soy/typeable/nixpkgs
on master help sign in
matplotlib: Add support for the TkAgg backend

Fixes #15993

commited14f12b89f096ee4f42f1744f3c1a0a17e569f3 authorAndreas Herrmann <andreash87@gmx.ch> dateSun 5 Jun 2016, 13:09 (10 years ago) parent616f846
1 file changed+22−1
pkgs/development/python-modules/matplotlib/default.nix+22−1
pkgs/development/python-modules/matplotlib/default.nix+22−1
@@ -4,11 +4,17 @@
44, enableGhostscript ? false, ghostscript ? null, gtk3
55, enableGtk2 ? false, pygtk ? null, gobjectIntrospection
66, enableGtk3 ? false, cairo
7+, enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null
78, Cocoa, Foundation, CoreData, cf-private, libobjc, libcxx
89}:
910
1011assert enableGhostscript -> ghostscript != null;
1112assert enableGtk2 -> pygtk != null;
13+assert enableTk -> (tcl != null)
14+ && (tk != null)
15+ && (tkinter != null)
16+ && (libX11 != null)
17+ ;
1218
1319buildPythonPackage rec {
1420 name = "matplotlib-${version}";
@@ -33,12 +39,27 @@ buildPythonPackage rec {
3339 libpng pkgconfig mock pytz
3440 ]
3541 ++ stdenv.lib.optional enableGtk2 pygtk
36− ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ];
42+ ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ]
43+ ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ];
3744
3845 patches =
3946 [ ./basedirlist.patch ] ++
4047 stdenv.lib.optionals stdenv.isDarwin [ ./darwin-stdenv.patch ];
4148
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+
4263 checkPhase = ''
4364 ${python.interpreter} tests.py
4465 '';