Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ buildPythonPackage rec {
dataclasses
];

postPatch = ''
substituteInPlace setup.cfg \
--replace "transformers>=3.4.0,<4.18.0" "transformers>=3.4.0 # ,<4.18.0"
'';

# Test fails due to missing arguments for trfs2arrays().
doCheck = false;

Expand Down
73 changes: 58 additions & 15 deletions pkgs/development/python-modules/transformers/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{ buildPythonPackage
, lib
{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder
, cookiecutter
Expand All @@ -10,52 +10,95 @@
, requests
, numpy
, packaging
, tensorflow
, sagemaker
, ftfy
, protobuf
, scikit-learn
, pillow
, pyyaml
, sacremoses
, torch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: Function called without required argument "torch" at /home/jon/.cache/nixpkgs-review/pr-175383-1/nixpkgs/pkgs/development/python-modules/transformers/default.nix:20, did you mean "torcs", "morph" or "orc"?
(use '--show-trace' to show detailed location information)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into this. Thanks for checking.

, tokenizers
, tqdm
}:

buildPythonPackage rec {
pname = "transformers";
version = "4.19.2";
format = "setuptools";

disabled = pythonOlder "3.7";

src = fetchFromGitHub {
owner = "huggingface";
repo = pname;
rev = "refs/tags/v${version}";
sha256 = "sha256-9r/1vW7Rhv9+Swxdzu5PTnlQlT8ofJeZamHf5X4ql8w=";
hash = "sha256-9r/1vW7Rhv9+Swxdzu5PTnlQlT8ofJeZamHf5X4ql8w=";
};

nativeBuildInputs = [ packaging ];

propagatedBuildInputs = [
cookiecutter
filelock
huggingface-hub
numpy
protobuf
packaging
pyyaml
regex
requests
sacremoses
tokenizers
tqdm
] ++ lib.optionals (pythonOlder "3.8") [ importlib-metadata ];
] ++ lib.optionals (pythonOlder "3.8") [
importlib-metadata
];

passthru.optional-dependencies = {
ja = [
# fugashi
# ipadic
# unidic_lite
# unidic
];
sklearn = [
scikit-learn
];
tf = [
tensorflow
# onnxconverter-common
# tf2onnx
];
torch = [
torch
];
tokenizers = [
tokenizers
];
modelcreation = [
cookiecutter
];
sagemaker = [
sagemaker
];
ftfy = [ ftfy ];
onnx = [
# onnxconverter-common
# tf2onnx
];
vision = [
pillow
];
};


# Many tests require internet access.
doCheck = false;

postPatch = ''
sed -ri 's/tokenizers[=>]=[^"]+/tokenizers/g' setup.py src/transformers/dependency_versions_table.py
'';

pythonImportsCheck = [ "transformers" ];
pythonImportsCheck = [
"transformers"
];

meta = with lib; {
homepage = "https://github.com/huggingface/transformers";
description = "State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch";
description = "Natural Language Processing for TensorFlow 2.0 and PyTorch";
changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
license = licenses.asl20;
platforms = platforms.unix;
Expand Down