Unverified Commit 3853200e authored by natsukium's avatar natsukium
Browse files

python311Packages.pytorch-pfn-extras: fix build

parent 9e663ea9
Loading
Loading
Loading
Loading
+34 −26
Original line number Diff line number Diff line
{ buildPythonPackage
, fetchFromGitHub
, fetchpatch
, lib
, setuptools
, numpy
, onnx
, packaging
, pytestCheckHook
, pythonAtLeast
, setuptools
, stdenv
, torch
, torchvision
, typing-extensions
, pythonAtLeast
}:

buildPythonPackage rec {
@@ -24,18 +26,27 @@ buildPythonPackage rec {
    hash = "sha256-vSon/0GxQfaRtSPsQbYAvE3s/F0HEN59VpzE3w1PnVE=";
  };

  nativeBuildInputs = [
  patches = [
    (fetchpatch {
      name = "relax-setuptools.patch";
      url = "https://github.com/pfnet/pytorch-pfn-extras/commit/96abe38c4baa6a144d604bdd4744c55627e55440.patch";
      hash = "sha256-85UDGcgJyQS5gINbgpNM58b3XJGvf+ArtGhwJ5EXdhk=";
    })
  ];

  build-system = [
    setuptools
  ];

  propagatedBuildInputs = [ numpy packaging torch typing-extensions ];
  dependencies = [ numpy packaging torch typing-extensions ];

  nativeCheckInputs = [ onnx pytestCheckHook torchvision ];

  # ignore all pytest warnings
  preCheck = ''
    rm pytest.ini
  '';
  pytestFlagsArray = [
    # Requires CUDA access which is not possible in the nix environment.
    "-m 'not gpu and not mpi'"
    "-Wignore::DeprecationWarning"
  ];

  pythonImportsCheck = [ "pytorch_pfn_extras" ];

@@ -45,31 +56,28 @@ buildPythonPackage rec {

    # requires onnxruntime which was removed because of poor maintainability
    # See https://github.com/NixOS/nixpkgs/pull/105951 https://github.com/NixOS/nixpkgs/pull/155058
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_annotate.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_as_output.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_export.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_export_testcase.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_lax.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_load_model.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_torchvision.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/utils.py"
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_lax.py"

    # RuntimeError: No Op registered for Gradient with domain_version of 9
    "tests/pytorch_pfn_extras_tests/onnx_tests/test_grad.py"

    # Requires CUDA access which is not possible in the nix environment.
    "tests/pytorch_pfn_extras_tests/cuda_tests/test_allocator.py"
    "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_batchnorm.py"
    "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_conv.py"
    "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_linear.py"
    "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy.py"
    "tests/pytorch_pfn_extras_tests/profiler_tests/test_record.py"
    "tests/pytorch_pfn_extras_tests/runtime_tests/test_to.py"
    "tests/pytorch_pfn_extras_tests/handler_tests/test_handler.py"
    "tests/pytorch_pfn_extras_tests/test_reporter.py"
    "tests/pytorch_pfn_extras_tests/training_tests/test_trainer.py"
    "tests/pytorch_pfn_extras_tests/utils_tests/test_checkpoint.py"
    "tests/pytorch_pfn_extras_tests/utils_tests/test_comparer.py"
    "tests/pytorch_pfn_extras_tests/utils_tests/test_new_comparer.py"
  ] ++ lib.optionals (pythonAtLeast "3.11") [
    # Remove this when https://github.com/NixOS/nixpkgs/pull/259068 is merged
  ] ++ lib.optionals (pythonAtLeast "3.12") [
    # RuntimeError: Dynamo is not supported on Python 3.12+
    "tests/pytorch_pfn_extras_tests/dynamo_tests/test_compile.py"
    "tests/pytorch_pfn_extras_tests/test_ops/test_register.py"
  ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
    # torch.distributed is not available on darwin
    "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_sharded_snapshot.py"
  ] ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
    # RuntimeError: internal error
    # convolution (e.g. F.conv3d) causes runtime error
    "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_conv.py"
  ];

  meta = with lib; {