From 519a42334fca2c8d3b0caef8669b2c0910e6b8d8 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Sun, 19 Jan 2025 12:39:01 -0500 Subject: [PATCH] python3Packages.transformers: don't import torch.distributed on darwin This patch is in the same spirit as d842a192cbe0ae0d216c089412027b2698038263 where import for torch.distributed was patched out for darwin. This other instance of the incorrect import was spotted while packaging lm-eval through the latter test suite. --- .../python-modules/transformers/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/development/python-modules/transformers/default.nix b/pkgs/development/python-modules/transformers/default.nix index edfd88f95388..d8874424cb4d 100644 --- a/pkgs/development/python-modules/transformers/default.nix +++ b/pkgs/development/python-modules/transformers/default.nix @@ -2,6 +2,7 @@ lib, buildPythonPackage, fetchFromGitHub, + fetchpatch, # build-system setuptools, @@ -68,6 +69,15 @@ buildPythonPackage rec { hash = "sha256-jh2bMmvTC0G0kLJl7xXpsvXvBmlbZEDA88AfosoE9sA="; }; + patches = [ + # Remove on the next major version bump + (fetchpatch { + url = "https://github.com/huggingface/transformers/commit/db864b5526d56fd99143619abff969bfcb5596d5.patch?full_index=1"; + name = "dont-import-torch-distributed-if-not-available.patch"; + hash = "sha256-XOraJmSt9Rp/oNiil6vDUBqZhd8MDbA0nz1Tx16Mk14="; + }) + ]; + build-system = [ setuptools ]; dependencies = [