Require downloaded model in pkg_resources (#4090)

This commit is contained in:
Ines Montani 2019-08-07 13:18:11 +02:00 committed by Matthew Honnibal
parent 8b4a0fabbb
commit 6bec24cdd0

View File

@ -6,6 +6,7 @@ import requests
import os
import subprocess
import sys
import pkg_resources
from wasabi import Printer
from .link import link
@ -67,6 +68,16 @@ def download(model, direct=False, *pip_args):
"the model via its full package name: "
"nlp = spacy.load('{}')".format(model, model_name),
)
# If a model is downloaded and then loaded within the same process, our
# is_package check currently fails, because pkg_resources.working_set
# is not refreshed automatically (see #3923). We're trying to work
# around this here be requiring the package explicitly.
try:
pkg_resources.working_set.require(model_name)
except: # noqa: E722
# Maybe it's possible to remove this mostly worried about cross-
# platform and cross-Python copmpatibility here
pass
def get_json(url, desc):