Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at master 3.0 kB view raw
1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 6 # build-system 7 cython, 8 setuptools, 9 10 # dependencies 11 autograd, 12 cma, 13 deprecated, 14 dill, 15 matplotlib, 16 numpy, 17 scipy, 18 19 # tests 20 pytestCheckHook, 21 nbformat, 22 notebook, 23 numba, 24 pythonAtLeast, 25 writeText, 26}: 27 28let 29 pymoo_data = fetchFromGitHub { 30 owner = "anyoptimization"; 31 repo = "pymoo-data"; 32 tag = "33f61a78182ceb211b95381dd6d3edee0d2fc0f3"; 33 hash = "sha256-iGWPepZw3kJzw5HKV09CvemVvkvFQ38GVP+BAryBSs0="; 34 }; 35in 36buildPythonPackage rec { 37 pname = "pymoo"; 38 version = "0.6.1.5"; 39 pyproject = true; 40 41 src = fetchFromGitHub { 42 owner = "anyoptimization"; 43 repo = "pymoo"; 44 tag = version; 45 hash = "sha256-IRNYluK6fO1cQq0u9dIJYnI5HWqtTPLXARXNoHa4F0I="; 46 }; 47 48 postPatch = '' 49 substituteInPlace pymoo/util/display/display.py \ 50 --replace-fail "from pymoo.util.display.progress import ProgressBar" "" \ 51 --replace-fail \ 52 "ProgressBar() if progress else None" \ 53 "print('Missing alive_progress needed for progress=True!') if progress else None" 54 55 substituteInPlace pymoo/config.py \ 56 --replace-fail \ 57 "https://raw.githubusercontent.com/anyoptimization/pymoo-data/main/" \ 58 "file://${pymoo_data}/" 59 ''; 60 61 pythonRelaxDeps = [ "cma" ]; 62 pythonRemoveDeps = [ "alive-progress" ]; 63 64 build-system = [ 65 setuptools 66 cython 67 ]; 68 69 dependencies = [ 70 autograd 71 cma 72 deprecated 73 dill 74 matplotlib 75 numpy 76 scipy 77 ]; 78 79 # Some tests require a grad backend to be configured, this is a hacky way to do so. 80 # The choice must be either "jax.numpy" or "autograd.numpy" 81 preCheck = '' 82 echo 'from pymoo.gradient import activate; activate("autograd.numpy")' >> tests/conftest.py 83 ''; 84 nativeCheckInputs = [ 85 pytestCheckHook 86 nbformat 87 notebook 88 numba 89 ]; 90 # Select some lightweight tests 91 disabledTestMarks = [ "long" ]; 92 disabledTests = [ 93 # ModuleNotFoundError: No module named 'pymoo.cython.non_dominated_sorting' 94 "test_fast_non_dominated_sorting" 95 "test_efficient_non_dominated_sort" 96 "test_dominance_degree_non_dominated_sort" 97 98 # sensitive to float precision 99 "test_cd_and_pcd" 100 101 # AssertionError: 102 # Not equal to tolerance rtol=0, atol=0.0001 103 # Mismatched elements: 1200 / 1200 (100%) 104 "test_pf" 105 106 # TypeError: 'NoneType' object is not subscriptable 107 "test_dascomp" 108 "test_mw" 109 ] 110 ++ lib.optionals (pythonAtLeast "3.13") [ 111 # AttributeError: 'ZDT3' object has no attribute 'elementwise' 112 "test_kktpm_correctness" 113 ]; 114 disabledTestPaths = [ 115 # sensitive to float precision 116 "tests/algorithms/test_no_modfication.py" 117 ]; 118 # Avoid crashing sandboxed build on macOS 119 MATPLOTLIBRC = writeText "" '' 120 backend: Agg 121 ''; 122 123 pythonImportsCheck = [ "pymoo" ]; 124 125 meta = { 126 description = "Multi-objective Optimization in Python"; 127 homepage = "https://pymoo.org/"; 128 license = lib.licenses.asl20; 129 maintainers = with lib.maintainers; [ veprbl ]; 130 }; 131}