Merge branch 'develop' of https://github.com/explosion/spaCy into develop

This commit is contained in:
Matthew Honnibal 2017-08-09 16:23:19 -05:00
commit a59a1deac4
6 changed files with 11 additions and 5 deletions

1
.gitignore vendored
View File

@ -40,7 +40,6 @@ venv/
# Distribution / packaging # Distribution / packaging
env/ env/
bin/
build/ build/
develop-eggs/ develop-eggs/
dist/ dist/

View File

@ -1,3 +1,4 @@
recursive-include include *.h recursive-include include *.h
include LICENSE include LICENSE
include README.rst include README.rst
include bin/spacy

1
bin/spacy Normal file
View File

@ -0,0 +1 @@
python -m spacy "$@"

View File

@ -187,6 +187,7 @@ def setup_package():
url=about['__uri__'], url=about['__uri__'],
license=about['__license__'], license=about['__license__'],
ext_modules=ext_modules, ext_modules=ext_modules,
scripts=['bin/spacy'],
install_requires=[ install_requires=[
'numpy>=1.7', 'numpy>=1.7',
'murmurhash>=0.28,<0.29', 'murmurhash>=0.28,<0.29',

View File

@ -8,7 +8,7 @@ import subprocess
import sys import sys
from .link import link from .link import link
from ..util import prints from ..util import prints, get_package_path
from .. import about from .. import about
@ -32,7 +32,11 @@ def download(cmd, model, direct=False):
version = get_version(model_name, compatibility) version = get_version(model_name, compatibility)
download_model('{m}-{v}/{m}-{v}.tar.gz'.format(m=model_name, v=version)) download_model('{m}-{v}/{m}-{v}.tar.gz'.format(m=model_name, v=version))
try: try:
link(None, model_name, model, force=True) # Get package path here because link uses
# pip.get_installed_distributions() to check if model is a package,
# which fails if model was just installed via subprocess
package_path = get_package_path(model_name)
link(None, model_name, model, force=True, model_path=package_path)
except: except:
# Dirty, but since spacy.download and the auto-linking is mostly # Dirty, but since spacy.download and the auto-linking is mostly
# a convenience wrapper, it's best to show a success message and # a convenience wrapper, it's best to show a success message and

View File

@ -14,7 +14,7 @@ from .. import util
link_name=("name of shortuct link to create", "positional", None, str), link_name=("name of shortuct link to create", "positional", None, str),
force=("force overwriting of existing link", "flag", "f", bool) force=("force overwriting of existing link", "flag", "f", bool)
) )
def link(cmd, origin, link_name, force=False): def link(cmd, origin, link_name, force=False, model_path=None):
""" """
Create a symlink for models within the spacy/data directory. Accepts Create a symlink for models within the spacy/data directory. Accepts
either the name of a pip package, or the local path to the model data either the name of a pip package, or the local path to the model data
@ -23,7 +23,7 @@ def link(cmd, origin, link_name, force=False):
if util.is_package(origin): if util.is_package(origin):
model_path = util.get_package_path(origin) model_path = util.get_package_path(origin)
else: else:
model_path = Path(origin) model_path = Path(origin) if model_path is None else Path(model_path)
if not model_path.exists(): if not model_path.exists():
prints("The data should be located in %s" % path2str(model_path), prints("The data should be located in %s" % path2str(model_path),
title="Can't locate model data", exits=1) title="Can't locate model data", exits=1)