python312Packages.transformers: fix darwin by skipping torch.distributed import (#362768)

This commit is contained in:
Yt
2024-12-07 12:50:10 -05:00
committed by GitHub
@@ -1,5 +1,6 @@
{
lib,
stdenv,
buildPythonPackage,
fetchFromGitHub,
@@ -68,6 +69,15 @@ buildPythonPackage rec {
hash = "sha256-TQQ+w+EH/KWLE7iaaAHGxfE74hCiLXcqlIr1TIBFGvo=";
};
# torch.distributed is not available on darwin
# Fix submitted upstream in https://github.com/huggingface/transformers/pull/35133
postPatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
substituteInPlace src/transformers/pytorch_utils.py \
--replace-fail \
'if is_torch_greater_or_equal("2.5"):' \
'if False:'
'';
build-system = [ setuptools ];
dependencies = [