forked from explosion/spaCy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev_setup.py
139 lines (111 loc) · 4.5 KB
/
dev_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python
import subprocess
# This is what we're down to...
try:
import Cython
except ImportError:
subprocess.call(['pip install cython'], shell=True)
try:
import murmurhash
except ImportError:
subprocess.call(['pip install murmurhash'], shell=True)
try:
import cymem
except ImportError:
subprocess.call(['pip install cymem'], shell=True)
try:
import preshed
except ImportError:
subprocess.call(['pip install preshed'], shell=True)
try:
import thinc
except ImportError:
subprocess.call(['pip install thinc'], shell=True)
try:
import numpy
except ImportError:
subprocess.call(['pip install numpy'], shell=True)
import Cython.Distutils
from Cython.Distutils import Extension
import distutils.core
import sys
import os
import os.path
from os import path
from glob import glob
import numpy
def clean(ext):
for pyx in ext.sources:
if pyx.endswith('.pyx'):
c = pyx[:-4] + '.c'
cpp = pyx[:-4] + '.cpp'
so = pyx[:-4] + '.so'
html = pyx[:-4] + '.html'
if os.path.exists(so):
os.unlink(so)
if os.path.exists(c):
os.unlink(c)
elif os.path.exists(cpp):
os.unlink(cpp)
if os.path.exists(html):
os.unlink(html)
HERE = os.path.dirname(__file__)
virtual_env = os.environ.get('VIRTUAL_ENV', '')
compile_args = []
link_args = []
libs = []
includes = ['.', numpy.get_include()]
cython_includes = ['.']
if 'VIRTUAL_ENV' in os.environ:
includes += glob(path.join(os.environ['VIRTUAL_ENV'], 'include', 'site', '*'))
else:
# If you're not using virtualenv, set your include dir here.
pass
ext_args = {'language': "c++", "include_dirs": includes}
exts = [
Extension("spacy.typedefs", ["spacy/typedefs.pyx"], **ext_args),
Extension("spacy.strings", ["spacy/strings.pyx"], **ext_args),
Extension("spacy.lexeme", ["spacy/lexeme.pyx"], **ext_args),
Extension("spacy.vocab", ["spacy/vocab.pyx"], **ext_args),
Extension("spacy.tokens", ["spacy/tokens.pyx"], **ext_args),
Extension("spacy.morphology", ["spacy/morphology.pyx"], **ext_args),
Extension("spacy._ml", ["spacy/_ml.pyx"], **ext_args),
Extension("spacy.tokenizer", ["spacy/tokenizer.pyx"], **ext_args),
Extension("spacy.en.attrs", ["spacy/en/attrs.pyx"], **ext_args),
Extension("spacy.en.pos", ["spacy/en/pos.pyx"], **ext_args),
Extension("spacy.syntax.parser", ["spacy/syntax/parser.pyx"], **ext_args),
Extension("spacy.syntax._state", ["spacy/syntax/_state.pyx"], **ext_args),
Extension("spacy.syntax.arc_eager", ["spacy/syntax/arc_eager.pyx"], **ext_args),
Extension("spacy.syntax._parse_features", ["spacy/syntax/_parse_features.pyx"],
**ext_args)
#Extension("spacy.pos_feats", ["spacy/pos_feats.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner._state", ["spacy/ner/_state.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.bilou_moves", ["spacy/ner/bilou_moves.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.io_moves", ["spacy/ner/io_moves.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.greedy_parser", ["spacy/ner/greedy_parser.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.pystate", ["spacy/ner/pystate.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.context", ["spacy/ner/context.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.feats", ["spacy/ner/feats.pyx"], language="c++", include_dirs=includes),
#Extension("spacy.ner.annot", ["spacy/ner/annot.pyx"], language="c++", include_dirs=includes),
]
if sys.argv[1] == 'clean':
print >> sys.stderr, "cleaning .c, .c++ and .so files matching sources"
map(clean, exts)
distutils.core.setup(
name='spacy',
packages=['spacy', 'spacy.en', 'spacy.syntax'],
description="Industrial-strength NLP",
author='Matthew Honnibal',
author_email='[email protected]',
version='0.1',
url="http://honnibal.github.io/spaCy/",
package_data={"spacy": ["*.pxd"], "spacy.en": ["*.pxd", "data/pos/*",
"data/wordnet/*", "data/tokenizer/*",
"data/vocab/*"],
"spacy.syntax": ["*.pxd"]},
cmdclass={'build_ext': Cython.Distutils.build_ext},
ext_modules=exts,
license="Dual: Commercial or AGPL",
requires=['cython', 'murmurhash', 'cymem', 'preshed', 'thinc', "unidecode",
"ujson"]
)