about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/fairscale/default.nix
blob: 42a7da74f9bcf9de5c9d06ca5d9f8d48e77ea9cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, setuptools
# build inputs
, torch
, numpy
, ninja
# check inputs
, pytestCheckHook
, parameterized
, pytest-cov
, pytest-timeout
, remote-pdb
}:
let
  pname = "fairscale";
  version = "0.4.13";
in
buildPythonPackage {
  inherit pname version;
  format = "pyproject";

  disabled = pythonOlder "3.10";

  src = fetchFromGitHub {
    owner = "facebookresearch";
    repo = "fairscale";
    rev = "refs/tags/v${version}";
    hash = "sha256-L2Rl/qL6l0OLAofygzJBGQdp/2ZrgDFarwZRjyAR3dw=";
  };

  # setup.py depends on ninja python dependency, but we have the binary in nixpkgs
  postPatch = ''
    substituteInPlace setup.py \
      --replace 'setup_requires=["ninja"]' 'setup_requires=[]'
  '';

  nativeBuildInputs = [
    ninja
    setuptools
  ];

  propagatedBuildInputs = [
    torch
    numpy
  ];

  nativeCheckInputs = [
    pytestCheckHook
    parameterized
    pytest-cov
    pytest-timeout
    remote-pdb
  ];

  # Some tests try to build distributed models, which doesn't work in the sandbox.
  doCheck = false;

  pythonImportsCheck = [
    "fairscale"
  ];

  meta = with lib; {
    description = "PyTorch extensions for high performance and large scale training";
    homepage = "https://github.com/facebookresearch/fairscale";
    changelog = "https://github.com/facebookresearch/fairscale/releases/tag/v${version}";
    license = with licenses; [ mit asl20 bsd3 ];
    maintainers = with maintainers; [ happysalada ];
  };
}