at master 3.1 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/algorithms/soo/nonconvex/es.py \ 56 --replace-fail "np.math.ceil" "np.ceil" 57 substituteInPlace pymoo/util/mnn.py \ 58 --replace-fail "np.product" "np.prod" 59 60 substituteInPlace pymoo/config.py \ 61 --replace-fail \ 62 "https://raw.githubusercontent.com/anyoptimization/pymoo-data/main/" \ 63 "file://${pymoo_data}/" 64 ''; 65 66 pythonRelaxDeps = [ "cma" ]; 67 pythonRemoveDeps = [ "alive-progress" ]; 68 69 build-system = [ 70 setuptools 71 cython 72 ]; 73 74 dependencies = [ 75 autograd 76 cma 77 deprecated 78 dill 79 matplotlib 80 numpy 81 scipy 82 ]; 83 84 preCheck = '' 85 # Some tests require a grad backend to be configured, this is a hacky way to do so. 86 # The choice must be either "jax.numpy" or "autograd.numpy" 87 echo 'from pymoo.gradient import activate; activate("autograd.numpy")' >> tests/conftest.py 88 ''; 89 nativeCheckInputs = [ 90 pytestCheckHook 91 nbformat 92 notebook 93 numba 94 ]; 95 # Select some lightweight tests 96 disabledTestMarks = [ "long" ]; 97 disabledTests = [ 98 # ModuleNotFoundError: No module named 'pymoo.cython.non_dominated_sorting' 99 "test_fast_non_dominated_sorting" 100 "test_efficient_non_dominated_sort" 101 "test_dominance_degree_non_dominated_sort" 102 103 # sensitive to float precision 104 "test_cd_and_pcd" 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}