1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 cymem,
9 cython_0,
10 murmurhash,
11 numpy,
12 preshed,
13 thinc,
14
15 # dependencies
16 catalogue,
17 jinja2,
18 langcodes,
19 packaging,
20 pydantic,
21 requests,
22 setuptools,
23 spacy-legacy,
24 spacy-loggers,
25 srsly,
26 tqdm,
27 typer,
28 wasabi,
29 weasel,
30
31 # optional-dependencies
32 spacy-transformers,
33 spacy-lookups-data,
34
35 # tests
36 pytestCheckHook,
37 hypothesis,
38 mock,
39
40 # passthru
41 writeScript,
42 git,
43 nix,
44 nix-update,
45 callPackage,
46}:
47
48buildPythonPackage rec {
49 pname = "spacy";
50 version = "3.8.5";
51 pyproject = true;
52
53 src = fetchFromGitHub {
54 owner = "explosion";
55 repo = "spaCy";
56 tag = "release-v${version}";
57 hash = "sha256-rgMstGSscUBACA5+veXD9H/lHuvWKs7hJ6hz6aKOB/0=";
58 };
59
60 build-system = [
61 cymem
62 cython_0
63 murmurhash
64 numpy
65 preshed
66 thinc
67 ];
68
69 pythonRelaxDeps = [ "thinc" ];
70
71 dependencies = [
72 catalogue
73 cymem
74 jinja2
75 langcodes
76 murmurhash
77 numpy
78 packaging
79 preshed
80 pydantic
81 requests
82 setuptools
83 spacy-legacy
84 spacy-loggers
85 srsly
86 thinc
87 tqdm
88 typer
89 wasabi
90 weasel
91 ];
92
93 optional-dependencies = {
94 transformers = [ spacy-transformers ];
95 lookups = [ spacy-lookups-data ];
96 };
97
98 nativeCheckInputs = [
99 pytestCheckHook
100 hypothesis
101 mock
102 ];
103
104 # Fixes ModuleNotFoundError when running tests on Cythonized code. See #255262
105 preCheck = ''
106 cd $out
107 '';
108
109 pytestFlagsArray = [ "-m 'slow'" ];
110
111 disabledTests = [
112 # touches network
113 "test_download_compatibility"
114 "test_validate_compatibility_table"
115 "test_project_assets"
116 ];
117
118 pythonImportsCheck = [ "spacy" ];
119
120 passthru = {
121 updateScript = writeScript "update-spacy" ''
122 #!${stdenv.shell}
123 set -eou pipefail
124 PATH=${
125 lib.makeBinPath [
126 git
127 nix
128 nix-update
129 ]
130 }
131
132 nix-update python3Packages.spacy
133
134 # update spacy models as well
135 echo | nix-shell maintainers/scripts/update.nix --argstr package python3Packages.spacy-models.en_core_web_sm
136 '';
137 tests.annotation = callPackage ./annotation-test { };
138 };
139
140 meta = {
141 description = "Industrial-strength Natural Language Processing (NLP)";
142 homepage = "https://github.com/explosion/spaCy";
143 changelog = "https://github.com/explosion/spaCy/releases/tag/release-v${version}";
144 license = lib.licenses.mit;
145 maintainers = [ ];
146 mainProgram = "spacy";
147 };
148}