Skip to content

Commit 28a594a

Browse files
authored
python312Packages.transformers: fix darwin by skipping torch.distributed import (NixOS#362768)
2 parents c776d4b + d842a19 commit 28a594a

File tree

1 file changed

+10
-0
lines changed
  • pkgs/development/python-modules/transformers

1 file changed

+10
-0
lines changed

pkgs/development/python-modules/transformers/default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
lib,
3+
stdenv,
34
buildPythonPackage,
45
fetchFromGitHub,
56

@@ -68,6 +69,15 @@ buildPythonPackage rec {
6869
hash = "sha256-TQQ+w+EH/KWLE7iaaAHGxfE74hCiLXcqlIr1TIBFGvo=";
6970
};
7071

72+
# torch.distributed is not available on darwin
73+
# Fix submitted upstream in https://github.com/huggingface/transformers/pull/35133
74+
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
75+
substituteInPlace src/transformers/pytorch_utils.py \
76+
--replace-fail \
77+
'if is_torch_greater_or_equal("2.5"):' \
78+
'if False:'
79+
'';
80+
7181
build-system = [ setuptools ];
7282

7383
dependencies = [

0 commit comments

Comments
 (0)