2021-04-10 11:08:13 +02:00
|
|
|
{ lib, stdenv, fetchPypi, writeText, python, buildPythonPackage, isPy3k, pycairo, backports_functools_lru_cache
|
2018-04-04 20:11:14 +02:00
|
|
|
, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver
|
2021-04-10 11:18:11 +02:00
|
|
|
, freetype, qhull, libpng, pkg-config, mock, pytz, pygobject3, gobject-introspection
|
2020-08-17 06:42:57 +02:00
|
|
|
, certifi, pillow
|
2021-04-11 07:39:38 +02:00
|
|
|
, enableGhostscript ? true, ghostscript, gtk3
|
2015-01-17 15:24:47 +01:00
|
|
|
, enableGtk3 ? false, cairo
|
2018-12-01 22:06:23 +01:00
|
|
|
# darwin has its own "MacOSX" backend
|
2021-04-11 07:39:38 +02:00
|
|
|
, enableTk ? !stdenv.isDarwin, tcl, tk, tkinter, libX11
|
|
|
|
, enableQt ? false, pyqt5
|
2017-02-13 15:03:59 +01:00
|
|
|
, Cocoa
|
2018-01-24 14:00:57 +01:00
|
|
|
, pythonOlder
|
2014-12-22 21:38:05 +01:00
|
|
|
}:
|
2014-12-21 11:02:35 +01:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2021-04-10 11:18:11 +02:00
|
|
|
version = "3.4.1";
|
2017-05-27 11:25:35 +02:00
|
|
|
pname = "matplotlib";
|
2014-12-21 11:02:35 +01:00
|
|
|
|
2018-11-03 13:40:48 +01:00
|
|
|
disabled = !isPy3k;
|
|
|
|
|
2018-06-23 15:27:58 +02:00
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2021-04-10 11:18:11 +02:00
|
|
|
sha256 = "84d4c4f650f356678a5d658a43ca21a41fca13f9b8b00169c0b76e6a6a948908";
|
2014-12-21 11:02:35 +01:00
|
|
|
};
|
2015-06-28 20:25:19 +02:00
|
|
|
|
2015-01-17 15:11:24 +01:00
|
|
|
XDG_RUNTIME_DIR = "/tmp";
|
2014-12-21 11:02:35 +01:00
|
|
|
|
2021-01-19 07:50:56 +01:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2019-01-18 01:20:41 +01:00
|
|
|
|
2020-04-21 07:56:13 +02:00
|
|
|
buildInputs = [ which sphinx ]
|
2021-01-24 01:29:22 +01:00
|
|
|
++ lib.optional enableGhostscript ghostscript
|
|
|
|
++ lib.optional stdenv.isDarwin [ Cocoa ];
|
2014-12-21 11:02:35 +01:00
|
|
|
|
|
|
|
propagatedBuildInputs =
|
2021-04-10 11:18:11 +02:00
|
|
|
[ cycler dateutil numpy pyparsing tornado freetype qhull
|
|
|
|
kiwisolver certifi libpng mock pytz pillow ]
|
2021-01-24 01:29:22 +01:00
|
|
|
++ lib.optionals enableGtk3 [ cairo pycairo gtk3 gobject-introspection pygobject3 ]
|
|
|
|
++ lib.optionals enableTk [ tcl tk tkinter libX11 ]
|
|
|
|
++ lib.optionals enableQt [ pyqt5 ];
|
2014-12-21 11:02:35 +01:00
|
|
|
|
2021-04-10 11:08:13 +02:00
|
|
|
passthru.config = {
|
|
|
|
directories = { basedirlist = "."; };
|
|
|
|
libs = {
|
|
|
|
system_freetype = true;
|
2021-04-10 11:18:11 +02:00
|
|
|
system_qhull = true;
|
2021-04-10 11:08:13 +02:00
|
|
|
} // lib.optionalAttrs stdenv.isDarwin {
|
|
|
|
# LTO not working in darwin stdenv, see #19312
|
|
|
|
enable_lto = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
setup_cfg = writeText "setup.cfg" (lib.generators.toINI {} passthru.config);
|
2020-04-21 07:56:13 +02:00
|
|
|
preBuild = ''
|
|
|
|
cp "$setup_cfg" ./setup.cfg
|
|
|
|
'';
|
2015-06-28 20:25:19 +02:00
|
|
|
|
2016-06-05 13:09:55 +02:00
|
|
|
# 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
|
2021-01-24 01:29:22 +01:00
|
|
|
tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
|
2016-06-05 13:09:55 +02:00
|
|
|
in
|
2021-01-24 01:29:22 +01:00
|
|
|
lib.optionalString enableTk
|
2016-06-05 13:09:55 +02:00
|
|
|
"sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py";
|
2015-06-28 20:25:19 +02:00
|
|
|
|
2020-04-21 07:56:13 +02:00
|
|
|
# Matplotlib needs to be built against a specific version of freetype in
|
|
|
|
# order for all of the tests to pass.
|
2016-02-17 21:02:15 +01:00
|
|
|
doCheck = false;
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2016-06-20 12:53:46 +02:00
|
|
|
description = "Python plotting library, making publication quality plots";
|
2018-11-03 13:40:48 +01:00
|
|
|
homepage = "https://matplotlib.org/";
|
2020-04-21 07:56:13 +02:00
|
|
|
maintainers = with maintainers; [ lovek323 veprbl ];
|
2014-12-21 11:02:35 +01:00
|
|
|
};
|
2016-02-17 21:02:15 +01:00
|
|
|
|
2014-12-21 11:02:35 +01:00
|
|
|
}
|