U eE@sddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z Gdd d eZ dd d Zdd d ZddZGdddZddZddZGddde Zd dd gZdS)) annotationsN)IS_WIN)Discover) PythonInfo) PythonSpeccsDeZdZddfdd ZeddZddZd dd d ZZS) BuiltinNonereturncs6t||jr|jntjg|_|j|_|j|_dSN)super__init__pythonsys executable python_specapp_datatry_first_with)selfoptions __class__J/opt/hc_python/lib/python3.8/site-packages/virtualenv/discovery/builtin.pyrs zBuiltin.__init__c Cs6|jddddtdgdd|jdd d tdgd ddS) Nz-pz--pythonrpyappendzinterpreter based on what to create environment (path/identifier) - by default use the interpreter where the tool is installed - first found wins)destmetavartypeactiondefaulthelpz--try-first-withrpy_exez:try first these interpreters before starting the discovery) add_argumentstr)clsparserrrradd_parser_argumentss& zBuiltin.add_parser_argumentscCs4|jD](}t||j|j|j}|dk r|SqdSr )rget_interpreterrrZ_env)rrresultrrrrun,s   z Builtin.runr%cCs0t|jdkr|jdn|j}|jjd|S)Nrrz discover of python_spec=)lenrr__name__)rspecrrr__repr__3szBuiltin.__repr__) r- __module__ __qualname__r classmethodr(r+r/ __classcell__rrrrrs  rcCst|}td|t}|dkr*tjn|}t||||D]R\}}|j|f}||krXqt |dfVt r ddl m }||||D]}|dfVqt |}t} t|D]\} }t|} tt| | |t|D]d\} } t| | }|dk rLtj|}|| krL| |tj||d|d}|dk rL|| fVqLq"dS)N)r=Tr)r9F)Zraise_on_errorr=)r7r8pathabspathlstatOSErrorrZfrom_exeZis_absZcurrent_systemrwindowsr9 get_pathsr6 enumerater%r4r: LazyPathDumppossible_specs check_pathr;PathPythonInfo)r.rrr=r#r?r9r>pathsZ tested_exesposZpath_str candidatematchfoundexerrrr9IsH            r9c Cs`|dd}|dkrBztd}Wnttfk r@tj}YnX|sJgSdd|tjDS)NPATHCS_PATHcSsg|]}tj|r|qSr)r7r?exists).0prrr s zget_paths..)getr7confstrAttributeError ValueErrordefpathsplitpathsep)r=r?rrrrD{s  rDc@s(eZdZddddZddddZdS) rFr r cCs||_||_||_dSr )rKr?r=)rrKr?r=rrrrszLazyPathDump.__init__r%c Csd|jd|j}|jdr|d7}t|jD]\}z2tj|j|}tj|sdt|tj shWq4Wnt k r~YnX|d7}||7}q4|S)Nzdiscover PATH[z]=Z_VIRTUALENV_DEBUGz with => ) rKr?r=rVr7listdirjoinisdiraccessX_OKrB)rcontent file_name file_pathrrrr/s  zLazyPathDump.__repr__N)r-r0r1rr/rrrrrFsrFcCs\tj|\}}tjdkr*|dkr*|d}tj|r:|Stj||}tj|rX|SdS)Nwin32z.exe)r7r?splitextrplatformisfiler_)rLr?_extrrrrHs  rHccs|jdfV|EdHdS)NF)Zstr_specZgenerate_names)r.rrrrGs rGc@seZdZdZdS)rIzpython info from path.N)r-r0r1__doc__rrrrrIsrI)NN)N) __future__rr4r7rZvirtualenv.inforZdiscoverrZpy_inforZpy_specrrr)r9rDrFrHrGrI__all__rrrrs&     *  2