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 preshed,
20 pydantic,
21 pytestCheckHook,
22 pythonOlder,
23 setuptools,
24 srsly,
25 typing-extensions,
26 wasabi,
27}:
28
29buildPythonPackage rec {
30 pname = "thinc";
31 version = "8.3.0";
32 pyproject = true;
33
34 disabled = pythonOlder "3.7";
35
36 src = fetchPypi {
37 inherit pname version;
38 hash = "sha256-6zvtVPXADsmt2qogjFHM+gWUg9cxQM1RWqMzc3Fcblk=";
39 };
40
41 postPatch = ''
42 # As per https://github.com/explosion/thinc/releases/tag/release-v8.3.0 no
43 # code changes were required for NumPy 2.0. Thus Thinc should be compatible
44 # with NumPy 1.0 and 2.0.
45 substituteInPlace pyproject.toml setup.cfg \
46 --replace-fail "numpy>=2.0.0,<2.1.0" numpy
47 substituteInPlace setup.cfg \
48 --replace-fail "numpy>=2.0.1,<2.1.0" numpy
49 '';
50
51 build-system = [
52 blis
53 cymem
54 cython_0
55 murmurhash
56 numpy
57 preshed
58 setuptools
59 ];
60
61 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [
62 Accelerate
63 CoreFoundation
64 CoreGraphics
65 CoreVideo
66 ];
67
68 dependencies = [
69 blis
70 catalogue
71 confection
72 cymem
73 murmurhash
74 numpy
75 preshed
76 pydantic
77 srsly
78 wasabi
79 ] ++ lib.optionals (pythonOlder "3.8") [ typing-extensions ];
80
81 nativeCheckInputs = [
82 hypothesis
83 mock
84 pytestCheckHook
85 ];
86
87 preCheck = ''
88 # avoid local paths, relative imports wont resolve correctly
89 mv thinc/tests tests
90 rm -r thinc
91 '';
92
93 pythonImportsCheck = [ "thinc" ];
94
95 meta = with lib; {
96 description = "Library for NLP machine learning";
97 homepage = "https://github.com/explosion/thinc";
98 changelog = "https://github.com/explosion/thinc/releases/tag/v${version}";
99 license = licenses.mit;
100 maintainers = with maintainers; [ aborsu ];
101 };
102}