3 fP@sddlZddlZddlZddlZddlZddlZddgZdjej dZ ddZ e dZ e dZ de fde fgZdd d Zd dZd d ZdddddddddZdddddddddZddddZdddZdS)Nversion bootstrapz/usr/share/python{}-wheels/csRtjjtdj|ddj}fddtj|D}tt|tj j dS)Nz{}-z-py2.py3-none-any.whlz{}*{}c3s$|]}|tt VqdS)N)len).0p)prefixsuffix*/usr/lib64/python3.6/ensurepip/__init__.py sz1_get_most_recent_wheel_version..)key) ospathjoin _WHEEL_DIRformatglobstrmax distutilsrZ LooseVersion)ZpkgpatternZversionsr )rrr _get_most_recent_wheel_version s  rZ setuptoolspipc Csd|dk r|tjt_yddlm}Wn tk rDddlm}YnX|ddkr\|jd||S)Nr)maininstalllistwheelz--pre)rrr)sysrZ pip._internalr ImportErrorrappend)argsadditional_pathsrr r r _run_pip s   r"cCstS)zA Returns a string specifying the bundled version of pip. ) _PIP_VERSIONr r r r r0scCs6ddtjD}x|D] }tj|=qWtjtjd<dS)NcSsg|]}|jdr|qS)ZPIP_) startswith)rkr r r :sz7_disable_pip_configuration_settings..ZPIP_CONFIG_FILE)r environdevnull)Zkeys_to_remover%r r r #_disable_pip_configuration_settings6s  r)F)rootupgradeuser altinstall default_pip verbositycCst||||||ddS)z Bootstrap pip into the current Python installation (or the given root directory). Note that calling this function will alter both sys.path and os.environ. )r*r+r,r-r.r/N) _bootstrap)r*r+r,r-r.r/r r r rBs cCs4|r|rtdt|r&dtjd<n|s4dtjd<tj}g}x~tD]v\}} dj|| } ttj j t | d4} ttj j || d} | j | j WdQRXWdQRX|jtj j || qHWdd d |g} |r| d |g7} |r| d g7} |r| d g7} |r| dd|g7} t| ddtD|SQRXdS)z Bootstrap pip into the current Python installation (or the given root directory). Returns pip command status code. Note that calling this function will alter both sys.path and os.environ. z.Cannot use altinstall and default_pip togetherr-ZENSUREPIP_OPTIONSrz{}-{}-py2.py3-none-any.whlrbwbNz --no-indexz --find-linksz--rootz --upgradez--user-vcSsg|] }|dqS)rr )rrr r r r&sz_bootstrap..) ValueErrorr)r r'tempfileZTemporaryDirectory _PROJECTSropenrrrwritereadrr")r*r+r,r-r.r/Ztmpdirr!ZprojectrZ wheel_nameZsfpfpr r r r r0Qs2     "    r0)r/c Csy ddl}Wntk r dSX|jtkrLd}t|j|jttjddStdddg}|rr|dd |g7}t |d d t t DS) z~Helper to support a clean default uninstall process on Windows Note that calling this function may alter os.environ. rNzOensurepip will only uninstall a matching version ({!r} installed, {!r} bundled))fileZ uninstallz-yz--disable-pip-version-checkr3r4cSsg|] }|dqS)rr )rrr r r r&sz%_uninstall_helper..) rr __version__r#printrrstderrr)r"reversedr7)r/rmsgr r r r _uninstall_helpers   rBcCsddl}|jdd}|jdddjtdd|jd d d dd d d|jdddddd|jddddd|jdddd|jddddd|jddddd|j|}t|j|j|j |j |j |j dS)Nrzpython -m ensurepip)progz --versionrzpip {}z9Show the version of pip that is bundled with this Python.)actionrhelpz-vz --verbosecountr/zDGive more output. Option is additive, and can be used up to 3 times.)rDdefaultdestrEz-Uz --upgrade store_trueFz8Upgrade pip and dependencies, even if already installed.)rDrGrEz--userzInstall using the user scheme.z--rootz=Install everything relative to this alternate root directory.)rGrEz --altinstallzoMake an alternate install, installing only the X.Y versioned scripts (Default: pipX, pipX.Y, easy_install-X.Y).z --default-pipzqMake a default pip install, installing the unqualified pip and easy_install in addition to the versioned scripts.)r*r+r,r/r-r.) argparseArgumentParser add_argumentrr parse_argsr0r*r+r,r/r-r.)argvrJparserr r r r _mainsZ   rP)N)N)Zdistutils.versionrrr Zos.pathrr6__all__r version_inforrZ_SETUPTOOLS_VERSIONr#r7r"rr)rr0rBrPr r r r s.    2