mirror of https://github.com/explosion/spaCy.git
Fix auto-linking in download command
This commit is contained in:
parent
9925334fa0
commit
ac4b88cce9
|
@ -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():
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue