3 Pf.@sddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ej de dy ddl Z Wne k r~YnNXejdkree dddkrydd lmZWne efk rYn Xejdd lmZmZmZdd lmZmZdd lmZmZdd lmZmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'ddl%m(Z(ddl m)Z)ddl*Z+e+j,Z,dZ-ej.e/Z0ej de)dddZ1ddZ2ddZ3ddZ4d ddZ5Gddde6Z7e/dkrej8e5dS)!)absolute_importN)DependencyWarningignore)categorydarwinZOPENSSL_VERSION_NUMBERi)securetransport)InstallationError CommandErrorPipError)get_installed_distributionsget_prog) deprecationdist_is_editable)git mercurial subversionbazaar)ConfigOptionParserUpdatingDefaultsHelpFormatter) get_summariesget_similar_commands) commands_dict)InsecureRequestWarningz9.0.3c sZdtjkrdStjdjdd}ttjd}y||dWntk rZdYnXddtDg}yfd d|Dd }Wntk rd}YnXt}|r|d krtjd|d koԈj d  rJg}j }xUsz autocomplete..csg|]}|kr|qSrr)rw) subcommandsrrrYsrhelpZ uninstall-T)Z local_onlycSs&g|]}|jtjkr|j|jfqSr)r"optparse SUPPRESS_HELPget_opt_stringnargs)roptrrrrqscSsg|]}|jddqS)=r)split)rxrrrrvscs g|]\}}|kr||fqSrr)rr+v) prev_optsrrrwscs"g|]\}}|jr||fqSr) startswith)rkr,)currentrrrysr)z--cSsg|] }|jqSr) option_list)rirrrrscss|]}|D] }|Vq qdS)Nr)ritorrr szautocomplete..cSs g|]}|jtjkr|jqSr)r"r$r%r&)rr2rrrrs csg|]}|jr|qSr)r.)rr+)r0rrrs)osenvironr*int IndexErrorrcreate_main_parsersysexitr.lowerr keyappendprintrparserZoption_list_allZ option_groupsr1join) ZcwordsZcwordZoptionsZsubcommand_namerBZ installedZlcdistZ subcommandZoptionZ opt_labelZoptsr)r0r-r!r autocompleteEs\          rEcCsddtdtd}tf|}|jtjjtjjtjjt}dt |t j ddf|_ t j t j|}|j|d|_t}dgd d |D}d j||_|S) Nz %prog [options]Fglobal)ZusageZadd_help_optionZ formatternameprogzpip %s from %s (python %s)TrcSsg|]\}}d||fqS)z%-27s %sr)rr2jrrrrsz&create_main_parser.. )rr rZdisable_interspersed_argsr7pathdirnameabspath__file__ __version__r<version cmdoptionsZmake_option_groupZ general_groupZadd_option_groupmainrrC description)Z parser_kwrBZ pip_pkg_dirZgen_optsZcommand_summariesrTrrrr;s"    r;cCst}|j|\}}|jr>tjj|jtjjtjtj| s\|ddkrlt |dkrl|j tj|d}|t krt |}d|g}|r|j d|tdj||dd}|j|||fS)Nrr"rzunknown command "%s"zmaybe you meant "%s"z - )r; parse_argsrQr<stdoutwriter7linesepr=lenZ print_helprrr@r rCremove)argsrBZgeneral_optionsZ args_elsecmd_nameZguessmsgcmd_argsrrr parseoptss&    r_cCsd}d|krd}|S)NFz --isolatedTr)r[isolatedrrrcheck_isolatedsracCs|dkrtjdd}tjtyt|\}}WnJtk r~}z.tjjd|tjjt j tj dWYdd}~XnXyt j t jdWn0t jk r}ztjd|WYdd}~XnXt|t|d}|j|S)Nrz ERROR: %srz%Ignoring error %s when setting locale)r`)r<argvr Zinstall_warning_loggerrEr_r stderrrWr7rXr=locale setlocaleLC_ALLErrorloggerdebugrrarS)r[r\r^exceZcommandrrrrSs rSc@sLeZdZffddZejdZejdZeddZ e ddZ d d Z d S) FrozenRequirementcCs||_||_||_||_dS)N)rGreqeditablecomments)selfrGrmrnrorrr__init__szFrozenRequirement.__init__z-r(\d+)$z-(20\d\d\d\d\d\d)$cCstjjtjj|j}g}ddlm}m}t|r|j |rd}y|||}Wn2t k r} zt j d| d}WYdd} ~ XnX|dkrt j d||j d|j}d}nd}|j}|j} t| dkr| dddkstd | |f| dd} |jj| } |jj| } | s| r|jd }|r:|j||}|sXt j d ||j dnF|j d|| rx| jd}nd| jd}d}d|||j|f}||j|||S)Nr)vcsget_src_requirementTzYError when trying to get requirement for VCS system %s, falling back to uneditable formatz-Could not determine repository location of %sz-## !! Could not determine repository locationFr=====z5Expected 1 spec with == or ===; specs = %r; dist = %rZsvnz(Warning: cannot find svn location for %szF## FIXME: could not find svn URL in dependency_links for this package:z3# Installing as editable to satisfy requirement %s:z{%s}z %s@%s#egg=%s)rtru)r7rLnormcaserNlocationpip.vcsrrrsrZget_backend_namerrhZwarningr@Zas_requirementspecsrYAssertionError_rev_research_date_reZ get_backendZ get_locationgroupegg_nameZ project_name)clsrDZdependency_linksrwrorrrsrnrmrjryrQZ ver_matchZ date_matchZ svn_backendZ svn_locationZrevrrr from_distsf       zFrozenRequirement.from_distcCs,|j}tjd|}|r(|d|j}|S)Nz -py\d\.\d$)rrer|start)rDrGmatchrrrrIs  zFrozenRequirement.egg_namecCs2|j}|jrd|}djt|jt|gdS)Nz-e %srK)rmrnrClistrostr)rprmrrr__str__QszFrozenRequirement.__str__N) __name__ __module__ __qualname__rqrcompiler{r} classmethodr staticmethodrrrrrrrls     A rl__main__)N)9Z __future__rrdZloggingr7r$warningsr<rZpip._vendor.urllib3.exceptionsrfilterwarningsZssl ImportErrorplatformgetattrZpip._vendor.urllib3.contribrOSErrorZinject_into_urllib3Zpip.exceptionsrr r Z pip.utilsr r r rrxrrrrZpip.baseparserrrZ pip.commandsrrrrZpip.cmdoptionsZpiprRrPZ getLoggerrrhrEr;r_rarSobjectrlr=rrrrsR       I* [