U á€C^Yã@s¼ddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z ejd d defd d d efdd�ddd„ƒZdd„Zdd„Zdd„Zdd„Zddd„ZdS)é)Úunicode_literalsN)Úmsgé)Úlinké)Úget_package_path)Úaboutz$Model to download (shortcut or name)Ú positionalz'Force direct download of name + versionÚflagÚdzCAdditional arguments to be passed to `pip install` on model install)ÚmodelÚdirectÚpip_argsFc Gstdƒs"d|kr"t d¡|d}d}|rd| d¡}d |dd …¡}|d }t|j||d �|ƒ}n°ttj d ƒ}|  ||¡}t ƒ} t || ƒ}t|j||d �|ƒ}|d kr²t  |¡t d d |¡¡||k�r zt|ƒ} t||d| d�Wn t dd ||¡¡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éÿÿÿÿ)ÚmÚvzavailable shortcutsrz$Download and installation successfulz/You can now load the model via spacy.load('{}')T)ÚforceZ model_pathz&Download successful but linking failedz«Creating 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_packagerÚwarnÚsplitÚjoinÚdownload_modelÚformatÚget_jsonrZ __shortcuts__ÚgetÚget_compatibilityÚ get_versionÚsysÚexitZgoodrr) r r rZdl_tplÚ componentsZ model_nameÚversionÚdlZ shortcutsZ compatibilityÚ package_path©r'ú5/tmp/pip-install-6_kvzl1k/spacy/spacy/cli/download.pyÚdownloadsF ÿ     þ ýþ r)cCs.zddl}|j |¡WdSYdSXdS)NrTF)Ú pkg_resourcesÚ working_setÚrequire)Únamer*r'r'r(rTs  rcCs>t |¡}|jdkr6tjd |j¡d |tj¡dd�| ¡S)NéÈzServer error ({})zªCouldn'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/modelsr©Zexits) ÚrequestsrÚ status_coderÚfailrrÚ __version__Újson)ÚurlÚdescÚrr'r'r(r^s   ýúrcCsNtj}| dd¡d}ttjdƒ}|d}||krFtjd |¡dd�||S)Nú.devrrzcompatibility tablerz+No compatible models found for v{} of spaCyr/)rr3ÚrsplitrZ__compatibility__rr2r)r$Z comp_tableÚcompr'r'r(rls rcCs<| dd¡d}||kr0tjd |tj¡dd�||dS)Nr8rrz/No compatible model found for '{}' (spaCy v{}).r/)r9rr2rrr3)r r:r'r'r(r vsÿýr cCsNtjd|}dg}|r"| |¡tjdddg||g}tj|tj  ¡d�S)Nú/z--no-cache-dirz-mÚpipÚinstall)Úenv) rZ__download_url__Úextendr!Ú executableÚ subprocessÚcallÚosÚenvironÚcopy)ÚfilenameZ user_pip_argsÚ download_urlrÚcmdr'r'r(r�s  r)F)N)Ú __future__rZplacr0rCrAr!ZwasabirrÚutilrrrÚ annotationsÚstrÚboolr)rrrr rr'r'r'r(Ús(       ý ?