diff options
author | Sebastien Maret <sebastien.maret@univ-grenoble-alpes.fr> | 2018-11-03 13:40:48 +0100 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2018-11-11 10:14:25 +0100 |
commit | 880fae6a084a66dae6d92dd5fe4416bd4eed4978 (patch) | |
tree | e53f541d152b334f4cb87d93a31adf667ac2d614 | |
parent | 961180afc8ef4efd94487e2fc9d86b10a6099d93 (diff) | |
download | nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar.gz nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar.bz2 nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar.lz nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar.xz nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.tar.zst nixlib-880fae6a084a66dae6d92dd5fe4416bd4eed4978.zip |
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
5 files changed, 121 insertions, 16 deletions
diff --git a/pkgs/development/python-modules/matplotlib/2.nix b/pkgs/development/python-modules/matplotlib/2.nix new file mode 100644 index 000000000000..f073e7baa4ed --- /dev/null +++ b/pkgs/development/python-modules/matplotlib/2.nix @@ -0,0 +1,91 @@ +{ stdenv, fetchPypi, python, buildPythonPackage, pycairo, backports_functools_lru_cache +, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver +, freetype, libpng, pkgconfig, mock, pytz, pygobject3, functools32, subprocess32 +, enableGhostscript ? false, ghostscript ? null, gtk3 +, enableGtk2 ? false, pygtk ? null, gobjectIntrospection +, enableGtk3 ? false, cairo +, enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null +, enableQt ? false, pyqt4 +, libcxx +, Cocoa +, pythonOlder +}: + +assert enableGhostscript -> ghostscript != null; +assert enableGtk2 -> pygtk != null; +assert enableTk -> (tcl != null) + && (tk != null) + && (tkinter != null) + && (libX11 != null) + ; +assert enableQt -> pyqt4 != null; + +buildPythonPackage rec { + version = "2.2.3"; + pname = "matplotlib"; + + src = fetchPypi { + inherit pname version; + sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5"; + }; + + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; + + XDG_RUNTIME_DIR = "/tmp"; + + buildInputs = [ python which sphinx stdenv ] + ++ stdenv.lib.optional enableGhostscript ghostscript + ++ stdenv.lib.optional stdenv.isDarwin [ Cocoa ]; + + propagatedBuildInputs = + [ cycler dateutil nose numpy pyparsing tornado freetype kiwisolver + libpng pkgconfig mock pytz ] + ++ stdenv.lib.optional (pythonOlder "3.3") backports_functools_lru_cache + ++ stdenv.lib.optional enableGtk2 pygtk + ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ] + ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] + ++ stdenv.lib.optionals enableQt [ pyqt4 ] + ++ stdenv.lib.optionals (builtins.hasAttr "isPy2" python) [ functools32 subprocess32 ]; + + patches = + [ ./basedirlist.patch ] ++ + stdenv.lib.optionals stdenv.isDarwin [ ./darwin-stdenv-2.2.3.patch ]; + + # Matplotlib tries to find Tcl/Tk by opening a Tk window and asking the + # corresponding interpreter object for its library paths. This fails if + # `$DISPLAY` is not set. The fallback option assumes that Tcl/Tk are both + # installed under the same path which is not true in Nix. + # With the following patch we just hard-code these paths into the install + # script. + postPatch = + let + inherit (stdenv.lib.strings) substring; + tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${substring 0 3 tk.version}"''; + in + stdenv.lib.optionalString enableTk + "sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py"; + + checkPhase = '' + ${python.interpreter} tests.py + ''; + + # Test data is not included in the distribution (the `tests` folder + # is missing) + doCheck = false; + + prePatch = '' + # Failing test: ERROR: matplotlib.tests.test_style.test_use_url + sed -i 's/test_use_url/fails/' lib/matplotlib/tests/test_style.py + # Failing test: ERROR: test suite for <class 'matplotlib.sphinxext.tests.test_tinypages.TestTinyPages'> + sed -i 's/TestTinyPages/fails/' lib/matplotlib/sphinxext/tests/test_tinypages.py + # Transient errors + sed -i 's/test_invisible_Line_rendering/noop/' lib/matplotlib/tests/test_lines.py + ''; + + meta = with stdenv.lib; { + description = "Python plotting library, making publication quality plots"; + homepage = "https://matplotlib.org/"; + maintainers = with maintainers; [ lovek323 ]; + }; + +} diff --git a/pkgs/development/python-modules/matplotlib/darwin-stdenv-2.2.3.patch b/pkgs/development/python-modules/matplotlib/darwin-stdenv-2.2.3.patch new file mode 100644 index 000000000000..ca399b4e6841 --- /dev/null +++ b/pkgs/development/python-modules/matplotlib/darwin-stdenv-2.2.3.patch @@ -0,0 +1,10 @@ +--- a/src/_macosx.m 2015-10-30 00:46:20.000000000 +0200 ++++ b/src/_macosx.m 2015-11-01 14:52:25.000000000 +0200 +@@ -6264,6 +6264,7 @@ + + static bool verify_framework(void) + { ++ return true; /* nixpkgs darwin stdenv */ + #ifdef COMPILING_FOR_10_6 + NSRunningApplication* app = [NSRunningApplication currentApplication]; + NSApplicationActivationPolicy activationPolicy = [app activationPolicy]; diff --git a/pkgs/development/python-modules/matplotlib/darwin-stdenv.patch b/pkgs/development/python-modules/matplotlib/darwin-stdenv.patch index ca399b4e6841..27ed8fc9f964 100644 --- a/pkgs/development/python-modules/matplotlib/darwin-stdenv.patch +++ b/pkgs/development/python-modules/matplotlib/darwin-stdenv.patch @@ -1,10 +1,12 @@ ---- a/src/_macosx.m 2015-10-30 00:46:20.000000000 +0200 -+++ b/src/_macosx.m 2015-11-01 14:52:25.000000000 +0200 -@@ -6264,6 +6264,7 @@ +diff -ruN matplotlib-3.0.0/src/_macosx.m matplotlib-3.0.0.patched/src/_macosx.m +--- matplotlib-3.0.0/src/_macosx.m 2018-09-16 00:35:21.000000000 +0200 ++++ matplotlib-3.0.0.patched/src/_macosx.m 2018-11-03 13:14:33.000000000 +0100 +@@ -2577,6 +2577,7 @@ static bool verify_framework(void) { + return true; /* nixpkgs darwin stdenv */ - #ifdef COMPILING_FOR_10_6 - NSRunningApplication* app = [NSRunningApplication currentApplication]; - NSApplicationActivationPolicy activationPolicy = [app activationPolicy]; + ProcessSerialNumber psn; + /* These methods are deprecated, but they don't require the app to + have started */ + diff --git a/pkgs/development/python-modules/matplotlib/default.nix b/pkgs/development/python-modules/matplotlib/default.nix index f9aa8cb2ebea..2cd7557bac7c 100644 --- a/pkgs/development/python-modules/matplotlib/default.nix +++ b/pkgs/development/python-modules/matplotlib/default.nix @@ -1,7 +1,7 @@ -{ stdenv, fetchPypi, python, buildPythonPackage, pycairo, backports_functools_lru_cache +{ stdenv, fetchPypi, python, buildPythonPackage, isPy3k, pycairo, backports_functools_lru_cache , which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver , freetype, libpng, pkgconfig, mock, pytz, pygobject3, functools32, subprocess32 -, enableGhostscript ? false, ghostscript ? null, gtk3 +, enableGhostscript ? true, ghostscript ? null, gtk3 , enableGtk2 ? false, pygtk ? null, gobjectIntrospection , enableGtk3 ? false, cairo , enableTk ? false, tcl ? null, tk ? null, tkinter ? null, libX11 ? null @@ -21,12 +21,14 @@ assert enableTk -> (tcl != null) assert enableQt -> pyqt4 != null; buildPythonPackage rec { - version = "2.2.3"; + version = "3.0.2"; pname = "matplotlib"; + disabled = !isPy3k; + src = fetchPypi { inherit pname version; - sha256 = "7355bf757ecacd5f0ac9dd9523c8e1a1103faadf8d33c22664178e17533f8ce5"; + sha256 = "c94b792af431f6adb6859eb218137acd9a35f4f7442cea57e4a59c54751c36af"; }; NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1"; @@ -44,8 +46,7 @@ buildPythonPackage rec { ++ stdenv.lib.optional enableGtk2 pygtk ++ stdenv.lib.optionals enableGtk3 [ cairo pycairo gtk3 gobjectIntrospection pygobject3 ] ++ stdenv.lib.optionals enableTk [ tcl tk tkinter libX11 ] - ++ stdenv.lib.optionals enableQt [ pyqt4 ] - ++ stdenv.lib.optionals (builtins.hasAttr "isPy2" python) [ functools32 subprocess32 ]; + ++ stdenv.lib.optionals enableQt [ pyqt4 ]; patches = [ ./basedirlist.patch ] ++ @@ -84,9 +85,8 @@ buildPythonPackage rec { meta = with stdenv.lib; { description = "Python plotting library, making publication quality plots"; - homepage = "http://matplotlib.sourceforge.net/"; + homepage = "https://matplotlib.org/"; maintainers = with maintainers; [ lovek323 ]; - platforms = platforms.unix; }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index f817cb3d0617..e4e561682bf0 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -2746,9 +2746,11 @@ in { mathics = callPackage ../development/python-modules/mathics { }; - matplotlib = callPackage ../development/python-modules/matplotlib { + matplotlib = let + path = if isPy3k then ../development/python-modules/matplotlib/default.nix else + ../development/python-modules/matplotlib/2.nix; + in callPackage path { stdenv = if stdenv.isDarwin then pkgs.clangStdenv else pkgs.stdenv; - enableGhostscript = true; inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa; }; |