spaCy/build.py

60 lines
1.2 KiB
Python
Raw Normal View History

2015-12-16 17:11:54 +00:00
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
2015-12-18 11:26:18 +00:00
import shutil
2015-12-16 17:11:54 +00:00
from subprocess import call
def x(cmd):
print('$ '+cmd)
res = call(cmd, shell=True)
if res != 0:
sys.exit(res)
if len(sys.argv) < 2:
print('usage: %s <install-mode> [<pip-date>]')
sys.exit(1)
install_mode = sys.argv[1]
pip_date = len(sys.argv) > 2 and sys.argv[2]
x('pip install -U pip')
if pip_date:
x('python pip-date.py %s pip setuptools wheel six' % pip_date)
x('pip install -r requirements.txt')
if install_mode == 'pip':
2015-12-16 17:49:02 +00:00
for filename in os.listdir('dist'):
os.unlink(os.path.join('dist', filename))
2015-12-16 17:11:54 +00:00
x('python setup.py sdist')
2015-12-16 17:49:02 +00:00
filenames = os.listdir('dist')
assert len(filenames) == 1
x('pip install dist/%s' % filenames[0])
2015-12-16 17:11:54 +00:00
elif install_mode == 'setup-install':
x('python setup.py install')
elif install_mode == 'setup-develop':
x('pip install -e .')
x('pip install pytest')
x('pip list')
2015-12-18 11:26:18 +00:00
if os.path.exists('tmp'):
shutil.rmtree('tmp')
os.mkdir('tmp')
2015-12-16 17:11:54 +00:00
try:
old = os.getcwd()
os.chdir('tmp')
x('python -m spacy.en.download')
2015-12-16 18:13:36 +00:00
x('python -m pytest ../spacy/ --models --vectors --slow')
2015-12-16 17:11:54 +00:00
finally:
os.chdir(old)