spaCy/build.py

72 lines
1.4 KiB
Python
Raw Normal View History

2015-12-16 20:11:54 +03:00
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
2015-12-18 14:26:18 +03:00
import shutil
2015-12-16 20:11:54 +03: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]
2015-12-18 19:47:06 +03:00
if install_mode == 'prepare':
x('python pip-clear.py')
2015-12-16 20:11:54 +03:00
2015-12-18 19:47:06 +03:00
pip_date = len(sys.argv) > 2 and sys.argv[2]
if pip_date:
x('python pip-date.py %s pip setuptools wheel six' % pip_date)
x('pip install -r requirements.txt')
x('pip list')
elif install_mode == 'pip':
if os.path.exists('dist'):
shutil.rmtree('dist')
2015-12-16 20:11:54 +03:00
x('python setup.py sdist')
2015-12-18 19:47:06 +03:00
x('python pip-clear.py')
2015-12-16 20:49:02 +03:00
filenames = os.listdir('dist')
assert len(filenames) == 1
2015-12-18 19:47:06 +03:00
x('pip list')
2015-12-16 20:49:02 +03:00
x('pip install dist/%s' % filenames[0])
2015-12-16 20:11:54 +03:00
2015-12-18 19:47:06 +03:00
2015-12-16 20:11:54 +03:00
elif install_mode == 'setup-install':
x('python setup.py install')
2015-12-18 19:47:06 +03:00
2015-12-16 20:11:54 +03:00
elif install_mode == 'setup-develop':
x('pip install -e .')
2015-12-18 19:47:06 +03:00
elif install_mode == 'test':
x('pip install pytest')
x('pip list')
if os.path.exists('tmp'):
shutil.rmtree('tmp')
os.mkdir('tmp')
2015-12-16 20:11:54 +03:00
2015-12-18 19:47:06 +03:00
try:
old = os.getcwd()
os.chdir('tmp')
2015-12-16 20:11:54 +03:00
2015-12-18 19:47:06 +03:00
x('python -m spacy.en.download')
x('python -m pytest ../spacy/ --models --vectors --slow')
2015-12-16 20:11:54 +03:00
2015-12-18 19:47:06 +03:00
finally:
os.chdir(old)