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