Skip to content

Commit

Permalink
Merge pull request #124488 from rnhmjoj/mpl-21.05
Browse files Browse the repository at this point in the history
[21.05] pythonPackages.matplotlib: fix headless detection
  • Loading branch information
rnhmjoj authored May 26, 2021
2 parents 97fc742 + 6aa537a commit 677fab1
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions pkgs/development/python-modules/matplotlib/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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.
Expand All @@ -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 ];
};

Expand Down

0 comments on commit 677fab1

Please sign in to comment.