spaCy/setup.py

80 lines
2.0 KiB
Python
Raw Normal View History

2014-07-05 22:49:34 +04:00
#!/usr/bin/env python
import Cython.Distutils
from Cython.Distutils import Extension
2014-07-05 22:49:34 +04:00
import distutils.core
import sys
import os
import os.path
from os import path
from glob import glob
2014-07-05 22:49:34 +04:00
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 = []
2014-08-20 19:03:19 +04:00
includes = ['.']
cython_includes = ['.']
2014-07-05 22:49:34 +04:00
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
2014-07-05 22:49:34 +04:00
exts = [
2014-09-02 01:41:59 +04:00
Extension("spacy.lang", ["spacy/lang.pyx"], language="c++", include_dirs=includes),
2014-08-25 18:42:22 +04:00
Extension("spacy.word", ["spacy/word.pyx"], language="c++",
include_dirs=includes),
2014-09-10 22:41:37 +04:00
Extension("spacy.lexeme", ["spacy/lexeme.pyx"], language="c++",
include_dirs=includes),
2014-08-22 06:23:24 +04:00
Extension("spacy.ptb3", ["spacy/ptb3.pyx"], language="c++", include_dirs=includes),
2014-08-25 18:42:22 +04:00
Extension("spacy.en", ["spacy/en.pyx"], language="c++",
include_dirs=includes),
2014-09-10 21:41:19 +04:00
Extension("spacy.tokens", ["spacy/tokens.pyx"], language="c++",
include_dirs=includes),
2014-08-25 18:42:22 +04:00
2014-07-05 22:49:34 +04:00
]
if sys.argv[1] == 'clean':
print >> sys.stderr, "cleaning .c, .c++ and .so files matching sources"
map(clean, exts)
distutils.core.setup(
2014-07-31 05:03:53 +04:00
name='spaCy',
2014-07-31 05:03:10 +04:00
packages=['spacy'],
2014-07-05 22:49:34 +04:00
author='Matthew Honnibal',
author_email='honnibal@gmail.com',
version='1.0',
cmdclass={'build_ext': Cython.Distutils.build_ext},
ext_modules=exts,
)