diff --git a/spacy/download.py b/spacy/download.py index f7ece25e9..99280d7ed 100644 --- a/spacy/download.py +++ b/spacy/download.py @@ -5,7 +5,7 @@ import pip import plac import requests from os import path -from .link import link +from .link import link, link_package from . import about from . import util @@ -26,7 +26,7 @@ def download(model=None, direct=False): compatibility = get_compatibility() version = get_version(model_name, compatibility) download_model('{m}-{v}/{m}-{v}.tar.gz'.format(m=model_name, v=version)) - link(model_name, model, force=True) + link_package(model_name, model, force=True) def get_compatibility(): diff --git a/spacy/link.py b/spacy/link.py index fd81cac1a..abae83b46 100644 --- a/spacy/link.py +++ b/spacy/link.py @@ -18,17 +18,20 @@ def link(origin, link_name, force=False): """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 directory. Linking models allows loading them via spacy.load(link_name).""" - if is_package(origin): - package_path = site.getsitepackages()[0] - meta = get_meta(package_path, origin) - data_dir = origin + '-' + meta['version'] - model_path = os.path.join(package_path, origin, data_dir) - symlink(model_path, link_name, force) + link_package(origin, link_name) else: symlink(origin, link_name, force) +def link_package(origin, link_name, force=False): + package_path = site.getsitepackages()[0] + meta = get_meta(package_path, origin) + data_dir = origin + '-' + meta['version'] + model_path = os.path.join(package_path, origin, data_dir) + symlink(model_path, link_name, force) + + def symlink(model_path, link_name, force): if not os.path.isdir(model_path): util.sys_exit(