1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 cymem,
9 cython,
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.7";
51 pyproject = true;
52
53 src = fetchFromGitHub {
54 owner = "explosion";
55 repo = "spaCy";
56 tag = "release-v${version}";
57 hash = "sha256-mRra5/4W3DFVI/KbReTg2Ey9mOC6eQQ31/QDt7Pw0fU=";
58 };
59
60 build-system = [
61 cymem
62 cython
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 disabledTestMarks = [ "slow" ];
110
111 disabledTests = [
112 # touches network
113 "test_download_compatibility"
114 "test_validate_compatibility_table"
115 "test_project_assets"
116 "test_find_available_port"
117
118 # Tests for presence of outdated (and thus missing) spacy models
119 # https://github.com/explosion/spaCy/issues/13856
120 "test_registry_entries"
121 ];
122
123 pythonImportsCheck = [ "spacy" ];
124
125 passthru = {
126 updateScript = writeScript "update-spacy" ''
127 #!${stdenv.shell}
128 set -eou pipefail
129 PATH=${
130 lib.makeBinPath [
131 git
132 nix
133 nix-update
134 ]
135 }
136
137 nix-update python3Packages.spacy --version-regex 'release-v([0-9.]+)'
138
139 # update spacy models as well
140 echo | nix-shell maintainers/scripts/update.nix --argstr package python3Packages.spacy-models.en_core_web_sm
141 '';
142 tests.annotation = callPackage ./annotation-test { };
143 };
144
145 __darwinAllowLocalNetworking = true; # needed for test_find_available_port
146
147 meta = {
148 description = "Industrial-strength Natural Language Processing (NLP)";
149 homepage = "https://github.com/explosion/spaCy";
150 changelog = "https://github.com/explosion/spaCy/releases/tag/release-v${version}";
151 license = lib.licenses.mit;
152 maintainers = with lib.maintainers; [ sarahec ];
153 mainProgram = "spacy";
154 };
155}