diff --git a/pkgs/development/python-modules/mmcv/default.nix b/pkgs/development/python-modules/mmcv/default.nix index ba3a72976f58..c86ea25b50c0 100644 --- a/pkgs/development/python-modules/mmcv/default.nix +++ b/pkgs/development/python-modules/mmcv/default.nix @@ -2,82 +2,56 @@ lib, buildPythonPackage, fetchFromGitHub, - pytestCheckHook, - pythonOlder, - torch, - torchvision, - opencv4, - yapf, - packaging, - pillow, - addict, + + # nativeBuildInputs ninja, which, + + # buildInputs pybind11, + torch, + + # dependencies + addict, + mmengine, + numpy, + packaging, + pillow, + pyyaml, + yapf, + + # tests + lmdb, onnx, onnxruntime, - scipy, + pytestCheckHook, pyturbojpeg, + scipy, tifffile, - lmdb, - mmengine, + torchvision, }: let inherit (torch) cudaCapabilities cudaPackages cudaSupport; inherit (cudaPackages) backendStdenv; - in buildPythonPackage rec { pname = "mmcv"; version = "2.2.0"; - format = "setuptools"; - - disabled = pythonOlder "3.7"; + pyproject = true; src = fetchFromGitHub { owner = "open-mmlab"; repo = "mmcv"; - rev = "refs/tags/v${version}"; + tag = "v${version}"; hash = "sha256-NNF9sLJWV1q6uBE73LUW4UWwYm4TBMTBJjJkFArBmsc="; }; - env.CUDA_HOME = lib.optionalString cudaSupport (lib.getDev cudaPackages.cuda_nvcc); - - preConfigure = - '' - export MMCV_WITH_OPS=1 - '' - + lib.optionalString cudaSupport '' - export CC=${backendStdenv.cc}/bin/cc - export CXX=${backendStdenv.cc}/bin/c++ - export TORCH_CUDA_ARCH_LIST="${lib.concatStringsSep ";" cudaCapabilities}" - export FORCE_CUDA=1 - ''; - postPatch = '' - substituteInPlace setup.py --replace-fail "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES" + substituteInPlace setup.py \ + --replace-fail "cpu_use = 4" "cpu_use = $NIX_BUILD_CORES" ''; - preCheck = '' - # remove the conflicting source directory - rm -rf mmcv - ''; - - # test_cnn test_ops really requires gpus to be useful. - # some of the tests take exceedingly long time. - # the rest of the tests are disabled due to sandbox env. - disabledTests = [ - "test_cnn" - "test_ops" - "test_fileclient" - "test_load_model_zoo" - "test_processing" - "test_checkpoint" - "test_hub" - "test_reader" - ]; - nativeBuildInputs = [ ninja which @@ -99,34 +73,69 @@ buildPythonPackage rec { ] ); - nativeCheckInputs = [ - pytestCheckHook - torchvision - lmdb - onnx - onnxruntime - scipy - pyturbojpeg - tifffile - ]; - - propagatedBuildInputs = [ + dependencies = [ + addict mmengine - torch - opencv4 - yapf + numpy packaging pillow - addict + pyyaml + yapf + + # opencv4 + # torch ]; + env.CUDA_HOME = lib.optionalString cudaSupport (lib.getDev cudaPackages.cuda_nvcc); + + preConfigure = + '' + export MMCV_WITH_OPS=1 + '' + + lib.optionalString cudaSupport '' + export CC=${lib.getExe' backendStdenv.cc "cc"} + export CXX=${lib.getExe' backendStdenv.cc "c++"} + export TORCH_CUDA_ARCH_LIST="${lib.concatStringsSep ";" cudaCapabilities}" + export FORCE_CUDA=1 + ''; + pythonImportsCheck = [ "mmcv" ]; - meta = with lib; { + nativeCheckInputs = [ + lmdb + onnx + onnxruntime + pytestCheckHook + pyturbojpeg + scipy + tifffile + torchvision + ]; + + # remove the conflicting source directory + preCheck = '' + rm -rf mmcv + ''; + + # test_cnn test_ops really requires gpus to be useful. + # some of the tests take exceedingly long time. + # the rest of the tests are disabled due to sandbox env. + disabledTests = [ + "test_cnn" + "test_ops" + "test_fileclient" + "test_load_model_zoo" + "test_processing" + "test_checkpoint" + "test_hub" + "test_reader" + ]; + + meta = { description = "Foundational Library for Computer Vision Research"; homepage = "https://github.com/open-mmlab/mmcv"; changelog = "https://github.com/open-mmlab/mmcv/releases/tag/v${version}"; - license = with licenses; [ asl20 ]; - maintainers = with maintainers; [ rxiao ]; + license = with lib.licenses; [ asl20 ]; + maintainers = with lib.maintainers; [ rxiao ]; }; }