1{
2 lib,
3 stdenv,
4 Accelerate,
5 blis,
6 buildPythonPackage,
7 catalogue,
8 confection,
9 CoreFoundation,
10 CoreGraphics,
11 CoreVideo,
12 cymem,
13 cython_0,
14 fetchPypi,
15 hypothesis,
16 mock,
17 murmurhash,
18 numpy,
19 plac,
20 preshed,
21 pydantic,
22 pytestCheckHook,
23 python,
24 pythonOlder,
25 setuptools,
26 srsly,
27 tqdm,
28 typing-extensions,
29 wasabi,
30}:
31
32buildPythonPackage rec {
33 pname = "thinc";
34 version = "8.2.3";
35 format = "setuptools";
36
37 disabled = pythonOlder "3.7";
38
39 src = fetchPypi {
40 inherit pname version;
41 hash = "sha256-9a/FIikSqAvai9zslYNiorpTjXAn3I22FUhF0oWdynY=";
42 };
43
44 postPatch = ''
45 substituteInPlace setup.cfg \
46 --replace "preshed>=3.0.2,<3.1.0" "preshed"
47 '';
48
49 nativeBuildInputs = [ setuptools ];
50
51 buildInputs =
52 [ cython_0 ]
53 ++ lib.optionals stdenv.isDarwin [
54 Accelerate
55 CoreFoundation
56 CoreGraphics
57 CoreVideo
58 ];
59
60 propagatedBuildInputs = [
61 blis
62 catalogue
63 confection
64 cymem
65 murmurhash
66 numpy
67 plac
68 preshed
69 pydantic
70 srsly
71 tqdm
72 wasabi
73 ] ++ lib.optionals (pythonOlder "3.8") [ typing-extensions ];
74
75 nativeCheckInputs = [
76 hypothesis
77 mock
78 pytestCheckHook
79 ];
80
81 # Add native extensions.
82 preCheck = ''
83 export PYTHONPATH=$out/${python.sitePackages}:$PYTHONPATH
84
85 # avoid local paths, relative imports wont resolve correctly
86 mv thinc/tests tests
87 rm -r thinc
88 '';
89
90 pythonImportsCheck = [ "thinc" ];
91
92 meta = with lib; {
93 description = "Library for NLP machine learning";
94 homepage = "https://github.com/explosion/thinc";
95 changelog = "https://github.com/explosion/thinc/releases/tag/v${version}";
96 license = licenses.mit;
97 maintainers = with maintainers; [ aborsu ];
98 };
99}