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