git.iko.soy/typeable/nixpkgs
on master help sign in
matplotlib: 2.2.3 -> 3.0.2

Python 3 will use the new matplotlib 3.x while Python 2 will use 2.x. matplotlib: keep 2.2.3 for Python2k

commit880fae6a084a66dae6d92dd5fe4416bd4eed4978 authorSebastien Maret <sebastien.maret@univ-grenoble-alpes.fr> dateSat 3 Nov 2018, 13:40 (8 years ago) parent961180a
5 files changed+121−16
pkgs/development/python-modules/matplotlib/2.nix+91 pkgs/development/python-modules/matplotlib/darwin-stdenv-2.2.3.patch+10 pkgs/development/python-modules/matplotlib/darwin-stdenv.patch+8−6 pkgs/development/python-modules/matplotlib/default.nix+8−8 pkgs/top-level/python-packages.nix+4−2
pkgs/development/python-modules/matplotlib/2.nixnew file+91
@@ -0,0 +1,91 @@
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+, 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+, enableQt ? false, pyqt4
9+, libcxx
10+, Cocoa
11+, pythonOlder
12+}:
13+
14+assert enableGhostscript -> ghostscript != null;
15+assert enableGtk2 -> pygtk != null;
16+assert enableTk -> (tcl != null)
17+ && (tk != null)
18+ && (tkinter != null)
19+ && (libX11 != null)
20+ ;
21+assert enableQt -> pyqt4 != null;
22+
23+buildPythonPackage rec {
24+ version = "2.2.3";
25+ pname = "matplotlib";
26+
27+ src = fetchPypi {
28+ inherit pname version;
29+ sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5";
30+ };
31+
32+ NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
33+
34+ XDG_RUNTIME_DIR = "/tmp";
35+
36+ buildInputs = [ python which sphinx stdenv ]
37+ ++ stdenv.lib.optional enableGhostscript ghostscript
38+ ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ];
39+
40+ propagatedBuildInputs =
41+ [ cycler dateutil nose numpy pyparsing tornado freetype kiwisolver
42+ libpng pkgconfig mock pytz ]
43+ ++ stdenv.lib.optional (pythonOlder "3.3") backports_functools_lru_cache
44+ ++ stdenv.lib.optional enableGtk2 pygtk
45+ ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ]
46+ ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ]
47+ ++ stdenv.lib.optionals enableQt [ pyqt4 ]
48+ ++ stdenv.lib.optionals (builtins.hasAttr "isPy2" python) [ functools32 subprocess32 ];
49+
50+ patches =
51+ [ ./basedirlist.patch ] ++
52+ stdenv.lib.optionals stdenv.isDarwin [ ./darwin-stdenv-2.2.3.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+}
pkgs/development/python-modules/matplotlib/darwin-stdenv-2.2.3.patchnew file+10
@@ -0,0 +1,10 @@
1+--- a/src/_macosx.m 2015-10-30 00:46:20.000000000 +0200
2++++ b/src/_macosx.m 2015-11-01 14:52:25.000000000 +0200
3+@@ -6264,6 +6264,7 @@
4+
5+ static bool verify_framework(void)
6+ {
7++ return true; /* nixpkgs darwin stdenv */
8+ #ifdef COMPILING_FOR_10_6
9+ NSRunningApplication* app = [NSRunningApplication currentApplication];
10+ NSApplicationActivationPolicy activationPolicy = [app activationPolicy];
pkgs/development/python-modules/matplotlib/darwin-stdenv.patch+8−6
@@ -1,10 +1,12 @@
1−--- a/src/_macosx.m 2015-10-30 00:46:20.000000000 +0200
2−+++ b/src/_macosx.m 2015-11-01 14:52:25.000000000 +0200
3−@@ -6264,6 +6264,7 @@
1+diff -ruN matplotlib-3.0.0/src/_macosx.m matplotlib-3.0.0.patched/src/_macosx.m
2+--- matplotlib-3.0.0/src/_macosx.m 2018-09-16 00:35:21.000000000 +0200
3++++ matplotlib-3.0.0.patched/src/_macosx.m 2018-11-03 13:14:33.000000000 +0100
4+@@ -2577,6 +2577,7 @@
45
56 static bool verify_framework(void)
67 {
78+ return true; /* nixpkgs darwin stdenv */
8− #ifdef COMPILING_FOR_10_6
9− NSRunningApplication* app = [NSRunningApplication currentApplication];
10− NSApplicationActivationPolicy activationPolicy = [app activationPolicy];
9+ ProcessSerialNumber psn;
10+ /* These methods are deprecated, but they don't require the app to
11+ have started */
12+
pkgs/development/python-modules/matplotlib/default.nix+8−8
@@ -1,7 +1,7 @@
1−{ stdenv, fetchPypi, python, buildPythonPackage, pycairo, backports_functools_lru_cache
1+{ stdenv, fetchPypi, python, buildPythonPackage, isPy3k, pycairo, backports_functools_lru_cache
22, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver
33, freetype, libpng, pkgconfig, mock, pytz, pygobject3, functools32, subprocess32
4−, enableGhostscript ? false, ghostscript ? null, gtk3
4+, enableGhostscript ? true, ghostscript ? null, gtk3
55, enableGtk2 ? false, pygtk ? null, gobjectIntrospection
66, enableGtk3 ? false, cairo
77, enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null
@@ -21,12 +21,14 @@ assert enableTk -> (tcl != null)
2121assert enableQt -> pyqt4 != null;
2222
2323buildPythonPackage rec {
24− version = "2.2.3";
24+ version = "3.0.2";
2525 pname = "matplotlib";
2626
27+ disabled = !isPy3k;
28+
2729 src = fetchPypi {
2830 inherit pname version;
29− sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5";
31+ sha256 = "c94b792af431f6adb6859eb218137acd9a35f4f7442cea57e4a59c54751c36af";
3032 };
3133
3234 NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";
@@ -44,8 +46,7 @@ buildPythonPackage rec {
4446 ++ stdenv.lib.optional enableGtk2 pygtk
4547 ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ]
4648 ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ]
47− ++ stdenv.lib.optionals enableQt [ pyqt4 ]
48− ++ stdenv.lib.optionals (builtins.hasAttr "isPy2" python) [ functools32 subprocess32 ];
49+ ++ stdenv.lib.optionals enableQt [ pyqt4 ];
4950
5051 patches =
5152 [ ./basedirlist.patch ] ++
@@ -84,9 +85,8 @@ buildPythonPackage rec {
8485
8586 meta = with stdenv.lib; {
8687 description = "Python plotting library, making publication quality plots";
87− homepage = "http://matplotlib.sourceforge.net/";
88+ homepage = "https://matplotlib.org/";
8889 maintainers = with maintainers; [ lovek323 ];
89− platforms = platforms.unix;
9090 };
9191
9292}
pkgs/top-level/python-packages.nix+4−2
@@ -2746,9 +2746,11 @@ in {
27462746
27472747 mathics = callPackage ../development/python-modules/mathics { };
27482748
2749− matplotlib = callPackage ../development/python-modules/matplotlib {
2749+ matplotlib = let
2750+ path = if isPy3k then ../development/python-modules/matplotlib/default.nix else
2751+ ../development/python-modules/matplotlib/2.nix;
2752+ in callPackage path {
27502753 stdenv = if stdenv.isDarwin then pkgs.clangStdenv else pkgs.stdenv;
2751− enableGhostscript = true;
27522754 inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa;
27532755 };
27542756