1{
2 buildPythonPackage,
3 fetchFromGitHub,
4 fetchpatch,
5 lib,
6 numpy,
7 onnx,
8 packaging,
9 pytestCheckHook,
10 pythonAtLeast,
11 setuptools,
12 stdenv,
13 torch,
14 torchvision,
15 typing-extensions,
16}:
17
18buildPythonPackage rec {
19 pname = "pytorch-pfn-extras";
20 version = "0.7.6";
21 pyproject = true;
22
23 src = fetchFromGitHub {
24 owner = "pfnet";
25 repo = "pytorch-pfn-extras";
26 rev = "refs/tags/v${version}";
27 hash = "sha256-vSon/0GxQfaRtSPsQbYAvE3s/F0HEN59VpzE3w1PnVE=";
28 };
29
30 patches = [
31 (fetchpatch {
32 name = "relax-setuptools.patch";
33 url = "https://github.com/pfnet/pytorch-pfn-extras/commit/96abe38c4baa6a144d604bdd4744c55627e55440.patch";
34 hash = "sha256-85UDGcgJyQS5gINbgpNM58b3XJGvf+ArtGhwJ5EXdhk=";
35 })
36 ];
37
38 build-system = [ setuptools ];
39
40 dependencies = [
41 numpy
42 packaging
43 torch
44 typing-extensions
45 ];
46
47 nativeCheckInputs = [
48 onnx
49 pytestCheckHook
50 torchvision
51 ];
52
53 pytestFlagsArray = [
54 # Requires CUDA access which is not possible in the nix environment.
55 "-m 'not gpu and not mpi'"
56 "-Wignore::DeprecationWarning"
57 ];
58
59 pythonImportsCheck = [ "pytorch_pfn_extras" ];
60
61 disabledTestPaths =
62 [
63 # Requires optuna which is currently (2022-02-16) marked as broken.
64 "tests/pytorch_pfn_extras_tests/test_config_types.py"
65
66 # requires onnxruntime which was removed because of poor maintainability
67 # See https://github.com/NixOS/nixpkgs/pull/105951 https://github.com/NixOS/nixpkgs/pull/155058
68 "tests/pytorch_pfn_extras_tests/onnx_tests/test_annotate.py"
69 "tests/pytorch_pfn_extras_tests/onnx_tests/test_as_output.py"
70 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export.py"
71 "tests/pytorch_pfn_extras_tests/onnx_tests/test_export_testcase.py"
72 "tests/pytorch_pfn_extras_tests/onnx_tests/test_lax.py"
73 "tests/pytorch_pfn_extras_tests/onnx_tests/test_load_model.py"
74 "tests/pytorch_pfn_extras_tests/onnx_tests/test_torchvision.py"
75 "tests/pytorch_pfn_extras_tests/onnx_tests/utils.py"
76
77 # RuntimeError: No Op registered for Gradient with domain_version of 9
78 "tests/pytorch_pfn_extras_tests/onnx_tests/test_grad.py"
79 ]
80 ++ lib.optionals (pythonAtLeast "3.12") [
81 # RuntimeError: Dynamo is not supported on Python 3.12+
82 "tests/pytorch_pfn_extras_tests/dynamo_tests/test_compile.py"
83 "tests/pytorch_pfn_extras_tests/test_ops/test_register.py"
84 ]
85 ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
86 # torch.distributed is not available on darwin
87 "tests/pytorch_pfn_extras_tests/training_tests/extensions_tests/test_sharded_snapshot.py"
88 ]
89 ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64) [
90 # RuntimeError: internal error
91 # convolution (e.g. F.conv3d) causes runtime error
92 "tests/pytorch_pfn_extras_tests/nn_tests/modules_tests/test_lazy_conv.py"
93 ];
94
95 meta = with lib; {
96 description = "Supplementary components to accelerate research and development in PyTorch";
97 homepage = "https://github.com/pfnet/pytorch-pfn-extras";
98 license = licenses.mit;
99 maintainers = with maintainers; [ samuela ];
100 };
101}