1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 fetchpatch,
6 pytestCheckHook,
7 writeText,
8 autograd,
9 cma,
10 cython,
11 deprecated,
12 dill,
13 matplotlib,
14 nbformat,
15 notebook,
16 numba,
17 numpy,
18 pandas,
19 scipy,
20}:
21
22buildPythonPackage rec {
23 pname = "pymoo";
24 version = "0.6.0.1";
25 format = "setuptools";
26
27 src = fetchFromGitHub {
28 owner = "anyoptimization";
29 repo = "pymoo";
30 rev = version;
31 hash = "sha256-+qtW7hfSo266n1SRzAgHIu99W5Sl+NYbKOHXv/JI9IA=";
32 };
33
34 pymoo_data = fetchFromGitHub {
35 owner = "anyoptimization";
36 repo = "pymoo-data";
37 rev = "33f61a78182ceb211b95381dd6d3edee0d2fc0f3";
38 hash = "sha256-iGWPepZw3kJzw5HKV09CvemVvkvFQ38GVP+BAryBSs0=";
39 };
40
41 patches = [
42 # https://github.com/anyoptimization/pymoo/pull/407
43 (fetchpatch {
44 url = "https://github.com/anyoptimization/pymoo/commit/be57ece64275469daece1e8ef12b2b6ee05362c9.diff";
45 hash = "sha256-BLPrUqNbAsAecfYahESEJF6LD+kehUYmkTvl/nvyqII=";
46 })
47 ];
48
49 postPatch = ''
50 substituteInPlace setup.py \
51 --replace "cma==3.2.2" "cma" \
52 --replace "'alive-progress'," ""
53
54 substituteInPlace pymoo/util/display/display.py \
55 --replace "from pymoo.util.display.progress import ProgressBar" "" \
56 --replace "ProgressBar() if progress else None" \
57 "print('Missing alive_progress needed for progress=True!') if progress else None"
58 '';
59
60 nativeBuildInputs = [ cython ];
61 propagatedBuildInputs = [
62 autograd
63 cma
64 deprecated
65 dill
66 matplotlib
67 numpy
68 scipy
69 ];
70
71 doCheck = true;
72 preCheck = ''
73 substituteInPlace pymoo/config.py \
74 --replace "https://raw.githubusercontent.com/anyoptimization/pymoo-data/main/" \
75 "file://$pymoo_data/"
76 '';
77 nativeCheckInputs = [
78 pytestCheckHook
79 nbformat
80 notebook
81 numba
82 ];
83 # Select some lightweight tests
84 pytestFlagsArray = [ "-m 'not long'" ];
85 disabledTests = [
86 # ModuleNotFoundError: No module named 'pymoo.cython.non_dominated_sorting'
87 "test_fast_non_dominated_sorting"
88 "test_efficient_non_dominated_sort"
89 ];
90 # Avoid crashing sandboxed build on macOS
91 MATPLOTLIBRC = writeText "" ''
92 backend: Agg
93 '';
94
95 pythonImportsCheck = [ "pymoo" ];
96
97 meta = with lib; {
98 description = "Multi-objective Optimization in Python";
99 homepage = "https://pymoo.org/";
100 license = licenses.asl20;
101 maintainers = with maintainers; [ veprbl ];
102 };
103}