1{ buildPythonPackage
2, lib
3, fetchFromGitHub
4, pythonOlder
5, cookiecutter
6, filelock
7, huggingface-hub
8, importlib-metadata
9, regex
10, requests
11, numpy
12, packaging
13, protobuf
14, pyyaml
15, sacremoses
16, tokenizers
17, tqdm
18}:
19
20buildPythonPackage rec {
21 pname = "transformers";
22 version = "4.12.2";
23
24 src = fetchFromGitHub {
25 owner = "huggingface";
26 repo = pname;
27 rev = "v${version}";
28 sha256 = "sha256-SndnMiXWiDW+E1G+WaUTVv3lySavJWF0nFDZLOxzObc=";
29 };
30
31 nativeBuildInputs = [ packaging ];
32
33 propagatedBuildInputs = [
34 cookiecutter
35 filelock
36 huggingface-hub
37 numpy
38 protobuf
39 pyyaml
40 regex
41 requests
42 sacremoses
43 tokenizers
44 tqdm
45 ] ++ lib.optionals (pythonOlder "3.8") [ importlib-metadata ];
46
47 # Many tests require internet access.
48 doCheck = false;
49
50 postPatch = ''
51 sed -ri 's/tokenizers[=>]=[^"]+/tokenizers/g' setup.py src/transformers/dependency_versions_table.py
52 '';
53
54 pythonImportsCheck = [ "transformers" ];
55
56 meta = with lib; {
57 homepage = "https://github.com/huggingface/transformers";
58 description = "State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch";
59 changelog = "https://github.com/huggingface/transformers/releases/tag/v${version}";
60 license = licenses.asl20;
61 platforms = platforms.unix;
62 maintainers = with maintainers; [ pashashocky ];
63 };
64}