git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #16476 from aherrmann/matplotlib-tkagg

Matplotlib tkagg

commit59c7eb60254431f1d2f7df550065100ccd852a0c authorFrederik Rietdijk <freddyrietdijk@fridh.nl> dateFri 24 Jun 2016, 20:41 (10 years ago) parentde0264ced14f12
2 files changed+33−2
pkgs/development/python-modules/matplotlib/basedirlist.patch+8 pkgs/development/python-modules/matplotlib/default.nix+25−2
pkgs/development/python-modules/matplotlib/basedirlist.patchnew file+8
@@ -0,0 +1,8 @@
1+diff --git a/setup.cfg b/setup.cfg
2+new file mode 100644
3+index 0000000..6f81985
4+--- /dev/null
5++++ b/setup.cfg
6+@@ -0,0 +1,2 @@
7++[directories]
8++basedirlist = .
pkgs/development/python-modules/matplotlib/default.nix+25−2
@@ -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,9 +39,26 @@ 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
38− patches = stdenv.lib.optionals stdenv.isDarwin [ ./darwin-stdenv.patch ];
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";
3962
4063 checkPhase = ''
4164 ${python.interpreter} tests.py