Only download model if not installed (see #1456)

Use #egg=model==version to allow pip to check for existing installations. The download is only started if no installation matching the package/version is found. Fixes a long-standing inconvenience.
This commit is contained in:
ines 2018-05-20 15:52:17 +02:00
parent 6e6f995a3c
commit 8bcf5e9a7e

View File

@ -24,14 +24,14 @@ def download(model, direct=False):
with version. with version.
""" """
if direct: if direct:
dl = download_model('{m}/{m}.tar.gz'.format(m=model)) dl = download_model('{m}/{m}.tar.gz#egg={m}'.format(m=model))
else: else:
shortcuts = get_json(about.__shortcuts__, "available shortcuts") shortcuts = get_json(about.__shortcuts__, "available shortcuts")
model_name = shortcuts.get(model, model) model_name = shortcuts.get(model, model)
compatibility = get_compatibility() compatibility = get_compatibility()
version = get_version(model_name, compatibility) version = get_version(model_name, compatibility)
dl = download_model('{m}-{v}/{m}-{v}.tar.gz'.format(m=model_name, dl = download_model('{m}-{v}/{m}-{v}.tar.gz#egg={m}=={v}'
v=version)) .format(m=model_name, v=version))
if dl != 0: # if download subprocess doesn't return 0, exit if dl != 0: # if download subprocess doesn't return 0, exit
sys.exit(dl) sys.exit(dl)
try: try: