Merge pull request #124439 from rnhmjoj/mpl

pythonPackages.matplotlib: fix headless detection
This commit is contained in:
Dmitry Kalinkin 2021-05-26 04:59:42 -04:00 committed by GitHub
commit 66e7fcf53f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,21 @@
{ lib, stdenv, fetchPypi, writeText, python, buildPythonPackage, isPy3k, pycairo, backports_functools_lru_cache
, which, cycler, dateutil, nose, numpy, pyparsing, sphinx, tornado, kiwisolver
{ lib, stdenv, fetchPypi, writeText, buildPythonPackage, isPy3k, pycairo
, which, cycler, dateutil, numpy, pyparsing, sphinx, tornado, kiwisolver
, freetype, qhull, libpng, pkg-config, mock, pytz, pygobject3, gobject-introspection
, certifi, pillow
, enableGhostscript ? true, ghostscript, gtk3
, enableGtk3 ? false, cairo
# darwin has its own "MacOSX" backend
, enableTk ? !stdenv.isDarwin, tcl, tk, tkinter, libX11
, enableTk ? !stdenv.isDarwin, tcl, tk, tkinter
, enableQt ? false, pyqt5
# required for headless detection
, libX11, wayland
, Cocoa
, pythonOlder
}:
let
interactive = enableTk || enableGtk3 || enableQt;
in
buildPythonPackage rec {
version = "3.4.1";
pname = "matplotlib";
@ -62,8 +67,14 @@ buildPythonPackage rec {
let
tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
in
lib.optionalString enableTk
"sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py";
lib.optionalString enableTk ''
sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py
'' + lib.optionalString (stdenv.isLinux && interactive) ''
# fix paths to libraries in dlopen calls (headless detection)
substituteInPlace src/_c_internal_utils.c \
--replace libX11.so.6 ${libX11}/lib/libX11.so.6 \
--replace libwayland-client.so.0 ${wayland}/lib/libwayland-client.so.0
'';
# Matplotlib needs to be built against a specific version of freetype in
# order for all of the tests to pass.
@ -72,6 +83,7 @@ buildPythonPackage rec {
meta = with lib; {
description = "Python plotting library, making publication quality plots";
homepage = "https://matplotlib.org/";
license = with licenses; [ psfl bsd0 ];
maintainers = with maintainers; [ lovek323 veprbl ];
};