From 534f3e79a2ecdc6497f908b65111c03e3745ec97 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 17 Jan 2026 10:22:35 +0000 Subject: [PATCH 1/5] python3Packages.niaarm: fix matplotlib tests on darwin --- pkgs/development/python-modules/niaarm/default.nix | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/development/python-modules/niaarm/default.nix b/pkgs/development/python-modules/niaarm/default.nix index a324761df895..15078af0a068 100644 --- a/pkgs/development/python-modules/niaarm/default.nix +++ b/pkgs/development/python-modules/niaarm/default.nix @@ -52,15 +52,14 @@ buildPythonPackage rec { ] ++ lib.optionals (pythonOlder "3.11") [ tomli ]; + env = lib.optionalAttrs stdenv.hostPlatform.isDarwin { + # Prevents 'Fatal Python error: Aborted' on darwin during checkPhase + MPLBACKEND = "Agg"; + }; + disabledTests = [ # Test requires extra nltk data dependency "test_text_mining" - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - "test_hill_slopes" - "test_two_key_plot" ]; nativeCheckInputs = [ pytestCheckHook ]; From 84cc19a115f555822da15720cb46622f4174d369 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 17 Jan 2026 10:28:39 +0000 Subject: [PATCH 2/5] python3Packages.pymatgen: fix matplotlib tests on darwin --- .../python-modules/pymatgen/default.nix | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/pkgs/development/python-modules/pymatgen/default.nix b/pkgs/development/python-modules/pymatgen/default.nix index 38f1a7e95e3c..c3a42c082a73 100644 --- a/pkgs/development/python-modules/pymatgen/default.nix +++ b/pkgs/development/python-modules/pymatgen/default.nix @@ -133,6 +133,10 @@ buildPythonPackage rec { # ensure tests can find these '' export PMG_TEST_FILES_DIR="$(realpath ./tests/files)" + '' + # Prevents 'Fatal Python error: Aborted' on darwin during checkPhase + + lib.optionalString stdenv.hostPlatform.isDarwin '' + export MPLBACKEND="Agg" ''; disabledTests = [ @@ -147,25 +151,6 @@ buildPythonPackage rec { "test_mean_field" ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - # https://github.com/materialsproject/pymatgen/issues/4452 - "test_angle" - "test_as_dict_from_dict" - "test_attributes" - "test_basic" - "test_core_state_eigen" - "test_eos_func" - "test_get_info_cohps_to_neighbors" - "test_get_plot" - "test_get_point_group_operations" - "test_matplotlib_plots" - "test_ph_plot_w_gruneisen" - "test_plot" - "test_proj_bandstructure_plot" - "test_structure" - "test_structure_environments" - # attempt to insert nil object from objects[1] "test_timer_10_2_7" "test_timer" From d5b887231b63bcfd6ca787eed765178fa3796b29 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 17 Jan 2026 10:28:53 +0000 Subject: [PATCH 3/5] python3Packages.nifty8: fix matplotlib tests on darwin --- .../python-modules/nifty8/default.nix | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/pkgs/development/python-modules/nifty8/default.nix b/pkgs/development/python-modules/nifty8/default.nix index 687306ee4658..46c05bb3f2f4 100644 --- a/pkgs/development/python-modules/nifty8/default.nix +++ b/pkgs/development/python-modules/nifty8/default.nix @@ -70,22 +70,16 @@ buildPythonPackage rec { openssh ]; - disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - "test_optimize_kl_domain_expansion" - "test_plot_priorsamples" + # Prevents 'Fatal Python error: Aborted' on darwin during checkPhase + preCheck = lib.optionalString stdenv.hostPlatform.isDarwin '' + export MPLBACKEND="Agg" + ''; + disabledTests = lib.optionals stdenv.hostPlatform.isDarwin [ # [XPASS(strict)] np.vdot inaccurate for single precision "test_vdot" ]; - disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - "test/test_plot.py" - ]; - __darwinAllowLocalNetworking = true; postCheck = lib.optionalString From 34b4be9702d688b8c3297ac755f0958cd093dda0 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 17 Jan 2026 10:38:12 +0000 Subject: [PATCH 4/5] python3Packages.optuna: fix matplotlib tests on darwin --- .../python-modules/optuna/default.nix | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/pkgs/development/python-modules/optuna/default.nix b/pkgs/development/python-modules/optuna/default.nix index ee240ced4d4d..48c9a87e0a8b 100644 --- a/pkgs/development/python-modules/optuna/default.nix +++ b/pkgs/development/python-modules/optuna/default.nix @@ -84,10 +84,15 @@ buildPythonPackage rec { ]; }; - # grpc tests are racy - preCheck = '' - sed -i '/"grpc",/d' optuna/testing/storages.py - ''; + preCheck = + # grpc tests are racy + '' + sed -i '/"grpc",/d' optuna/testing/storages.py + '' + # Prevents 'Fatal Python error: Aborted' on darwin during checkPhase + + lib.optionalString stdenv.hostPlatform.isDarwin '' + export MPLBACKEND="Agg" + ''; nativeCheckInputs = [ addBinToPathHook @@ -117,24 +122,6 @@ buildPythonPackage rec { "test_plot_intermediate_values" "test_plot_rank" "test_plot_terminator_improvement" - - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - "test_edf_plot_no_trials" - "test_get_timeline_plot" - "test_plot_contour" - "test_plot_contour_customized_target_name" - "test_plot_edf_with_multiple_studies" - "test_plot_edf_with_target" - "test_plot_parallel_coordinate" - "test_plot_parallel_coordinate_customized_target_name" - "test_plot_param_importances" - "test_plot_param_importances_customized_target_name" - "test_plot_param_importances_multiobjective_all_objectives_displayed" - "test_plot_slice" - "test_plot_slice_customized_target_name" - "test_target_is_none_and_study_is_multi_obj" - "test_visualizations_with_single_objectives" ]; disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [ From 1fcce504d8e781988a2944a02df9a298e3651cce Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sat, 17 Jan 2026 10:38:20 +0000 Subject: [PATCH 5/5] python3Packages.dscribe: fix matplotlib tests on darwin --- .../python-modules/dscribe/default.nix | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/development/python-modules/dscribe/default.nix b/pkgs/development/python-modules/dscribe/default.nix index 51d7a9498506..28598f530629 100644 --- a/pkgs/development/python-modules/dscribe/default.nix +++ b/pkgs/development/python-modules/dscribe/default.nix @@ -53,10 +53,15 @@ buildPythonPackage rec { "dscribe.ext" ]; - # Prevents python from loading dscribe from the current working directory instead of using $out - preCheck = '' - rm -rf dscribe - ''; + preCheck = + # Prevents python from loading dscribe from the current working directory instead of using $out + '' + rm -rf dscribe + '' + # Prevents 'Fatal Python error: Aborted' on darwin during checkPhase + + lib.optionalString stdenv.hostPlatform.isDarwin '' + export MPLBACKEND="Agg" + ''; nativeCheckInputs = [ pytestCheckHook @@ -72,12 +77,7 @@ buildPythonPackage rec { [ # AssertionError on a numerical test "test_cell_list" - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - # Fatal Python error: Aborted - # matplotlib/backend_bases.py", line 2654 in create_with_canvas - "test_examples" - ]; + ]; # Broken due to use of missing _get_constraints attr in ase >= 3.26.0 # https://github.com/SINGROUP/dscribe/issues/160