U C^Y@sddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z ejd d defd d d efdddddZddZddZddZddZdddZdS))unicode_literalsN)msg)link)get_package_path)aboutz$Model to download (shortcut or name) positionalz'Force direct download of name + versionflagdzCAdditional arguments to be passed to `pip install` on model install)modeldirectpip_argsFc Gstds"d|kr"td|d}d}|rd|d}d|dd }|d }t|j||d |}nttj d }| ||}t } t || }t|j||d |}|d krt |td d|||kr zt|} t||d| dWn tdd||YnXt|dS)z Download compatible model from default download path using pip. Model can be shortcut, model name or, if --direct flag is set, full model name with version. For direct downloads, the compatibility check will be skipped. spacy --no-depsaaSkipping model package dependencies and setting `--no-deps`. You don't seem to have the spaCy package itself installed (maybe because you've built from source?), so installing the model dependencies would cause spaCy to be downloaded, which probably isn't what you want. If the model package has other dependencies, you'll have to install them manually.)rz#{m}-{v}/{m}-{v}.tar.gz#egg={m}=={v}-N)mvzavailable shortcutsrz$Download and installation successfulz/You can now load the model via spacy.load('{}')T)forceZ model_pathz&Download successful but linking failedzCreating a shortcut link for '{}' didn't work (maybe you don't have admin permissions?), but you can still load the model via its full package name: nlp = spacy.load('{}'))require_packagerwarnsplitjoindownload_modelformatget_jsonrZ __shortcuts__getget_compatibility get_versionsysexitZgoodrr) r r rZdl_tpl componentsZ model_nameversiondlZ shortcutsZ compatibility package_pathr'5/tmp/pip-install-6_kvzl1k/spacy/spacy/cli/download.pydownloadsF        r)cCs.zddl}|j|WdSYdSXdS)NrTF) pkg_resources working_setrequire)namer*r'r'r(rTs  rcCs>t|}|jdkr6tjd|jd|tjdd|S)NzServer error ({})zCouldn't fetch {}. Please find a model for your spaCy installation (v{}), and download it manually. For more details, see the documentation: https://spacy.io/usage/modelsrZexits) requestsr status_coderfailrr __version__json)urldescrr'r'r(r^s   rcCsNtj}|ddd}ttjd}|d}||krFtjd|dd||S)N.devrrzcompatibility tablerz+No compatible models found for v{} of spaCyr/)rr3rsplitrZ__compatibility__rr2r)r$Z comp_tablecompr'r'r(rls rcCs<|ddd}||kr0tjd|tjdd||dS)Nr8rrz/No compatible model found for '{}' (spaCy v{}).r/)r9rr2rrr3)r r:r'r'r(r vsr cCsNtjd|}dg}|r"||tjdddg||g}tj|tj dS)N/z--no-cache-dirz-mpipinstall)env) rZ__download_url__extendr! executable subprocesscallosenvironcopy)filenameZ user_pip_args download_urlrcmdr'r'r(rs  r)F)N) __future__rZplacr0rCrAr!Zwasabirrutilrrr annotationsstrboolr)rrrr rr'r'r'r(s(        ?