pythonPackages.matplotlib: fix headless detection
The default backend is chosen based on the content of the $DISPLAY variable *and* a successfull call to libX11, loaded via dlopen(). The test fails because dlopen looks in /usr/lib and /lib, so matplotlib falls back to a headless backend. To reproduce try running: $ nix-shell -I nixpkgs=$PWD -p \ 'python3.withPackages (p: [ p.matplotlib ])' --run python >>> import matplotlib.pyplot as plt >>> assert plt.get_backend() == "TkAgg"
This commit is contained in:
parent
7e54c9b956
commit
7e2ec8f8a1
|
@ -5,12 +5,18 @@
|
||||||
, enableGhostscript ? true, ghostscript, gtk3
|
, enableGhostscript ? true, ghostscript, gtk3
|
||||||
, enableGtk3 ? false, cairo
|
, enableGtk3 ? false, cairo
|
||||||
# darwin has its own "MacOSX" backend
|
# darwin has its own "MacOSX" backend
|
||||||
, enableTk ? !stdenv.isDarwin, tcl, tk, tkinter, libX11
|
, enableTk ? !stdenv.isDarwin, tcl, tk, tkinter
|
||||||
, enableQt ? false, pyqt5
|
, enableQt ? false, pyqt5
|
||||||
|
# required for headless detection
|
||||||
|
, libX11, wayland
|
||||||
, Cocoa
|
, Cocoa
|
||||||
, pythonOlder
|
, pythonOlder
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
interactive = enableTk || enableGtk3 || enableQt;
|
||||||
|
in
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
version = "3.4.1";
|
version = "3.4.1";
|
||||||
pname = "matplotlib";
|
pname = "matplotlib";
|
||||||
|
@ -62,8 +68,14 @@ buildPythonPackage rec {
|
||||||
let
|
let
|
||||||
tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
|
tcl_tk_cache = ''"${tk}/lib", "${tcl}/lib", "${lib.strings.substring 0 3 tk.version}"'';
|
||||||
in
|
in
|
||||||
lib.optionalString enableTk
|
lib.optionalString enableTk ''
|
||||||
"sed -i '/self.tcl_tk_cache = None/s|None|${tcl_tk_cache}|' setupext.py";
|
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
|
# Matplotlib needs to be built against a specific version of freetype in
|
||||||
# order for all of the tests to pass.
|
# order for all of the tests to pass.
|
||||||
|
|
Loading…
Reference in a new issue