Skip to content

Commit

Permalink
Merge pull request #1659 from l0b0/fix/matplotlib-3-9
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed May 25, 2024
2 parents 090792e + a7c192e commit 262b233
Show file tree
Hide file tree
Showing 6 changed files with 545 additions and 8 deletions.
9 changes: 8 additions & 1 deletion overrides/build-systems.json
Original file line number Diff line number Diff line change
Expand Up @@ -11486,7 +11486,14 @@
"matplotlib": [
"oldest-supported-numpy",
"setuptools",
"setuptools-scm"
{
"buildSystem": "setuptools-scm",
"from": "3.5.0"
},
{
"buildSystem": "meson-python",
"from": "3.9.0"
}
],
"matplotlib-inline": [
"setuptools"
Expand Down
25 changes: 18 additions & 7 deletions overrides/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ lib.composeManyExtensions [
inherit (pkgs) tk tcl wayland qhull;
inherit (pkgs.xorg) libX11;
inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa;
mpl39 = lib.versionAtLeast prev.matplotlib.version "3.9.0";
in
{
XDG_RUNTIME_DIR = "/tmp";
Expand All @@ -1558,7 +1559,7 @@ lib.composeManyExtensions [
final.pybind11
];

propagatedBuildInputs = (old.propagatedBuildInputs or [ ]) ++ [
propagatedBuildInputs = old.propagatedBuildInputs or [ ] ++ [
final.certifi
pkgs.libpng
pkgs.freetype
Expand All @@ -1569,10 +1570,17 @@ lib.composeManyExtensions [
++ lib.optionals enableQt [ final.pyqt5 ]
;

nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
dontUseMesonConfigure = mpl39;

nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [
pkg-config
] ++ lib.optionals (lib.versionAtLeast prev.matplotlib.version "3.5.0") [
final.setuptools-scm
];

mesonFlags = lib.optionals mpl39 [
"-Dsystem-freetype=true"
"-Dsystem-qhull=true"
# broken for linux in matplotlib 3.9.0
"-Db_lto=false"
];

# Clang doesn't understand -fno-strict-overflow, and matplotlib builds with -Werror
Expand All @@ -1599,14 +1607,17 @@ lib.composeManyExtensions [
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
'' +
# avoid matplotlib trying to download dependencies
''
+ lib.optionalString mpl39
''
patchShebangs .
''
# avoid matplotlib trying to download dependencies
+ ''
echo "[libs]
system_freetype=true
system_qhull=true" > mplsetup.cfg
'';

}
);

Expand Down
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ in
wheel-wheel = callTest ./wheel-wheel { };
fancycompleter-wheel = callTest ./fancycompleter-wheel { };
matplotlib-3-7 = callTest ./matplotlib-3-7 { };
matplotlib-3-9 = callTest ./matplotlib-3-9 { };
rfc3986-validator = callTest ./rfc3986-validator { };
virtualenv-pre-20-18 = callTest ./virtualenv-pre-20-18 { };
virtualenv-post-20-18 = callTest ./virtualenv-post-20-18 { };
Expand Down
10 changes: 10 additions & 0 deletions tests/matplotlib-3-9/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ poetry2nix, runCommand }:
let
env = poetry2nix.mkPoetryEnv {
projectDir = ./.;
};
in
runCommand "matplotlib-3-9-test" { } ''
${env}/bin/python -c 'import matplotlib'
touch $out
''
Loading

0 comments on commit 262b233

Please sign in to comment.