U C^ @sdZddlZddlZejddkZejddkZerDddlZefZne fZddl m Z iZ da eZdd Ze ed d Zd d ZddZe eddZGdddZGdddZGdddZddZdS)zThis module implements a post import hook mechanism styled after what is described in PEP-369. Note that it doesn't cope with modules being reloaded. N) synchronizedFcsfdd}|S)NcsFd\}}|d}t|tj|}|D]}t||}q.||S)N:.)split __import__sysmodulesgetattr)module module_namefunctionattrscallbackattrname=/tmp/pip-install-6_kvzl1k/thinc/thinc/extra/wrapt/importer.py import_hook(s   z4_create_import_hook_from_string..import_hookr)rrrrr_create_import_hook_from_string's rcCst|trt|}ts*datjdtt |d}|dkrrtj |d}|dk rfgt|<||q|gt|<n*|gkrtj |}||nt| |dSNTr) isinstance string_typesr_post_import_hooks_initr meta_pathinsertImportHookFinder_post_import_hooksgetr append)hookrhooksr rrrregister_post_import_hook4s       r%csfdd}|S)Ncs4tjtjj}jD]}t||}q||SN)r rr r rr )r rr entrypointrrrns     z8_create_import_hook_from_entrypoint..import_hookr)r(rrr'r#_create_import_hook_from_entrypointms r)cCsNz ddl}Wntk r"YdSX|j|dD]}t|}t||jq0dS)Nr)group) pkg_resources ImportErroriter_entry_pointsr)r%r)r*r+r(rrrrdiscover_post_import_hooksxs r.cCs:t|dd}t|d}|r6gt|<|D] }||q(dS)N__name__)r r r!)r rr$r#rrrnotify_module_loadeds   r0c@seZdZddZdS)_ImportHookLoadercCstj|}t||Sr&)r r r0selffullnamer rrr load_modules z_ImportHookLoader.load_moduleN)r/ __module__ __qualname__r5rrrrr1sr1c@seZdZddZddZdS)_ImportHookChainedLoadercCs ||_dSr&)loader)r3r9rrr__init__sz!_ImportHookChainedLoader.__init__cCs|j|}t||Sr&)r9r5r0r2rrrr5s z$_ImportHookChainedLoader.load_moduleN)r/r6r7r:r5rrrrr8sr8c@s&eZdZddZeedddZdS)rcCs i|_dSr&) in_progress)r3rrrr:szImportHookFinder.__init__Nc Cs|tkr dS||jkrdSd|j|<zltr|zddl}|j|j}Wn$ttfk rh| ||}YnX|rt |WSnt |t WSW5|j|=XdSr) r r;PY3importlib.utilutil find_specr9r,AttributeError find_loaderr8r r1)r3r4path importlibr9rrr find_modules"   zImportHookFinder.find_module)N)r/r6r7r:r_post_import_hooks_lockrDrrrrrsrcsfdd}|S)Ncst||Sr&)r%)r#rrrregisters zwhen_imported..registerr)rrFrrr when_importeds rG)__doc__r threading version_infoPY2r<rCstrr basestringZ decoratorsrr rRLockrErr%r)r.r0r1r8rrGrrrrs.    8   B