1{ 2 lib, 3 buildPythonPackage, 4 fetchFromGitHub, 5 fetchpatch, 6 7 # build-system 8 setuptools, 9 10 # dependencies 11 addict, 12 matplotlib, 13 numpy, 14 opencv4, 15 pyyaml, 16 rich, 17 termcolor, 18 yapf, 19 20 # tests 21 bitsandbytes, 22 coverage, 23 dvclive, 24 lion-pytorch, 25 lmdb, 26 mlflow, 27 parameterized, 28 pytestCheckHook, 29 transformers, 30 writableTmpDirAsHomeHook, 31}: 32 33buildPythonPackage rec { 34 pname = "mmengine"; 35 version = "0.10.7"; 36 pyproject = true; 37 38 src = fetchFromGitHub { 39 owner = "open-mmlab"; 40 repo = "mmengine"; 41 tag = "v${version}"; 42 hash = "sha256-hQnwenuxHQwl+DwQXbIfsKlJkmcRvcHV1roK7q2X1KA="; 43 }; 44 45 patches = [ 46 # Explicitly disable weights_only in torch.load calls 47 # https://github.com/open-mmlab/mmengine/pull/1650 48 (fetchpatch { 49 name = "torch-2.6.0-compat.patch"; 50 url = "https://github.com/open-mmlab/mmengine/pull/1650/commits/c21b8431b2c625560a3866c65328cff0380ba1f8.patch"; 51 hash = "sha256-SLr030IdYD9wM/jPJuZd+Dr1jjFx/5/YkJj/IwhnNQg="; 52 }) 53 ]; 54 55 build-system = [ setuptools ]; 56 57 dependencies = [ 58 addict 59 matplotlib 60 numpy 61 opencv4 62 pyyaml 63 rich 64 termcolor 65 yapf 66 ]; 67 68 pythonImportsCheck = [ "mmengine" ]; 69 70 nativeCheckInputs = [ 71 bitsandbytes 72 coverage 73 dvclive 74 lion-pytorch 75 lmdb 76 mlflow 77 parameterized 78 pytestCheckHook 79 transformers 80 writableTmpDirAsHomeHook 81 ]; 82 83 preCheck = 84 # Otherwise, the backprop hangs forever. More precisely, this exact line: 85 # https://github.com/open-mmlab/mmengine/blob/02f80e8bdd38f6713e04a872304861b02157905a/tests/test_runner/test_activation_checkpointing.py#L46 86 # Solution suggested in https://github.com/pytorch/pytorch/issues/91547#issuecomment-1370011188 87 '' 88 export MKL_NUM_THREADS=1 89 ''; 90 91 pytestFlagsArray = [ 92 # Require unpackaged aim 93 "--deselect tests/test_visualizer/test_vis_backend.py::TestAimVisBackend" 94 95 # Cannot find SSL certificate 96 # _pygit2.GitError: OpenSSL error: failed to load certificates: error:00000000:lib(0)::reason(0) 97 "--deselect tests/test_visualizer/test_vis_backend.py::TestDVCLiveVisBackend" 98 99 # AttributeError: type object 'MagicMock' has no attribute ... 100 "--deselect tests/test_fileio/test_backends/test_petrel_backend.py::TestPetrelBackend" 101 ]; 102 103 disabledTests = [ 104 # Require network access 105 "test_fileclient" 106 "test_http_backend" 107 "test_misc" 108 109 # RuntimeError 110 "test_dump" 111 "test_deepcopy" 112 "test_copy" 113 "test_lazy_import" 114 115 # AssertionError: os is not <module 'os' (frozen)> 116 "test_lazy_module" 117 ]; 118 119 meta = { 120 description = "Library for training deep learning models based on PyTorch"; 121 homepage = "https://github.com/open-mmlab/mmengine"; 122 changelog = "https://github.com/open-mmlab/mmengine/releases/tag/v${version}"; 123 license = with lib.licenses; [ asl20 ]; 124 maintainers = with lib.maintainers; [ rxiao ]; 125 }; 126}