B
    UvgL                 @   s  d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
mZ ddlmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ erddlmZ dd ZdddZdddZeeddddddZeeddddddZeedd d!ddedZ eed"d#d$d%dd&dZ!eed'd(ddd)dZ"eed*d+d,dd-dZ#eed.d/d0d%dd1dZ$eed2d3d4e%e& d5d6d7'e&  d8 d9Z(eed:d;d<d=d>d?d@Z)eedAdBddedZ*eedCdDdEdFdGdHZ+eedIdJdKdLdMdHZ,eedNdOdPdQdRdSdTdUZ-eedVdWdEdFedHZ.dXdY Z/eedZd[dEd>d\d]Z0eed^d_dEdd>d`daZ1eedbdcdddedfej2dgdhZ3didj Z4eedkdldddmdZ5dndo Z6dpdq Z7eedrdsdddtdZ8dudv Z9dwdx Z:dydz Z;eed{d|d}d~ddeddh	Z<dd Z=dd Z>dd Z?dd Z@dd ZAeeddddddhZBeeddddddhZCeeddddddhZDeeddddddhZEdd ZFeeddedddZGeedddddZHeedddddddZIeedddddddd@ZJeedddddZKeeddddddZLeeddddddZMeeddddddZNeedddddZOeedddddZPeeddddddZQeeddddedZRddǄ ZSeedddeSddd͍ZTeeddddddZUdeee e!e#e$e)e*e+e,e-e.e/e7e0e1eGeHeQe"gdҜZVde3e4e5e6e8gdҜZWdS )aD  
shared options and groups

The principle here is to define options once, but *not* instantiate them
globally. One reason being that options with action='append' can carry state
between parses. pip parses general options twice internally, and shouldn't
pass on state. To be consistent, all options will follow this design.

    )absolute_importN)partial)SUPPRESS_HELPOptionOptionGroup)CommandError)USER_CACHE_DIR
src_prefix)FormatControl)PyPI)STRONG_HASHES)MYPY_CHECK_RUNNING)	BAR_TYPES)Anyc             C   s0   t || d }x| d D ]}||  qW |S )z
    Return an OptionGroup object
    group  -- assumed to be dict with 'name' and 'options' keys
    parser -- an optparse Parser
    nameoptions)r   
add_option)groupparseroption_groupoption r   =/tmp/pip-install-r_9ig3yj/pip/pip/_internal/cli/cmdoptions.pymake_option_group   s    r   c                sP    dkr|   fdd}dddg}t t||rL| j}|  tjddd	 dS )
zDisable wheels if per-setup.py call options are set.

    :param options: The OptionParser options to update.
    :param check_options: The options to check, if not supplied defaults to
        options.
    Nc                s   t  | d S )N)getattr)n)check_optionsr   r   getname2   s    z+check_install_build_global.<locals>.getnamebuild_optionsglobal_optionsinstall_optionszeDisabling all use of wheels due to the use of --build-options / --global-options / --install-options.   )
stacklevel)anymapformat_controldisallow_binarieswarningswarn)r   r   r   namescontrolr   )r   r   check_install_build_global(   s    
r+   Fc             C   sb   t | j| j| j| jg}tt dh}| j|ko6| j }|rH|rHt	d|r^|r^| j
s^t	ddS )zFunction for determining if custom platform options are allowed.

    :param options: The OptionParser options.
    :param check_target: Whether or not to check if --target is being used.
    z:all:zWhen restricting platform and interpreter constraints using --python-version, --platform, --abi, or --implementation, either --no-deps must be set, or --only-binary=:all: must be set and --no-binary must not be set (or must be set to :none:).zQCan not use any platform or abi specific options unless installing via '--target'N)r#   python_versionplatformabiimplementationr
   setr%   ignore_dependenciesr   
target_dir)r   check_targetdist_restriction_setbinary_onlysdist_dependencies_allowedr   r   r   check_dist_restriction>   s    


r7   z-hz--helphelpz
Show help.)destactionr8   z
--isolatedisolated_mode
store_truezSRun pip in an isolated mode, ignoring environment variables and user configuration.)r9   r:   defaultr8   z--require-virtualenvz--require-venvrequire_venvz-vz	--verboseverbosecountzDGive more output. Option is additive, and can be used up to 3 times.z
--no-colorno_colorzSuppress colored outputz-Vz	--versionversionzShow version and exit.z-qz--quietquietzGive less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).z--progress-barprogress_barchoiceonz*Specify type of progress to be displayed [|z] (default: %default))r9   typechoicesr=   r8   z--logz
--log-filez--local-loglogpathz Path to a verbose appending log.)r9   metavarr8   z
--no-inputno_inputz--proxyproxystr z<Specify a proxy in the form [user:passwd@]proxy.server:port.)r9   rH   r=   r8   z	--retriesretriesint   zRMaximum number of retries each connection should attempt (default %default times).z	--timeoutz--default-timeoutsectimeoutfloat   z2Set the socket timeout (default %default seconds).)rL   r9   rH   r=   r8   z--skip-requirements-regexskip_requirements_regexc            
   C   s"   t ddddddddgg d	d
ddS )Nz--exists-actionexists_actionrE   siwbaappendr:   zZDefault action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort).)r9   rH   rI   r=   r:   rL   r8   )r   r   r   r   r   rY      s    rY   z--certcertzPath to alternate CA bundle.)r9   rH   rL   r8   z--client-certclient_certzkPath to SSL client certificate, a single file containing the private key and the certificate in PEM format.)r9   rH   r=   rL   r8   z-iz--index-urlz
--pypi-url	index_urlURLzBase URL of Python Package Index (default %default). This should point to a repository compliant with PEP 503 (the simple repository API) or a local directory laid out in the same format.)r9   rL   r=   r8   c               C   s   t ddddg ddS )Nz--extra-index-urlextra_index_urlsrc   r_   zmExtra URLs of package indexes to use in addition to --index-url. Should follow the same rules as --index-url.)r9   rL   r:   r=   r8   )r   r   r   r   r   extra_index_url%  s    re   z
--no-indexno_indexzAIgnore package index (only looking at --find-links URLs instead).c            	   C   s   t ddddg dddS )Nz-fz--find-links
find_linksr_   urlzIf a url or path to an html file, then parse for links to archives. If a local path or file:// url that's a directory, then look for archives in the directory listing.)r9   r:   r=   rL   r8   )r   r   r   r   r   rg   <  s    rg   c               C   s   t ddddg ddS )Nz--trusted-hosttrusted_hostsr_   HOSTNAMEzKMark this host as trusted, even though it does not have valid or any HTTPS.)r9   r:   rL   r=   r8   )r   r   r   r   r   trusted_hostI  s    rk   z--process-dependency-linksprocess_dependency_linksz*Enable the processing of dependency links.c            	   C   s   t ddddg dddS )Nz-cz--constraintconstraintsr_   filez\Constrain versions using the given constraints file. This option can be used multiple times.)r9   r:   r=   rL   r8   )r   r   r   r   r   rm   `  s    rm   c            	   C   s   t ddddg dddS )Nz-rz--requirementrequirementsr_   rn   zQInstall from the given requirements file. This option can be used multiple times.)r9   r:   r=   rL   r8   )r   r   r   r   r   ro   l  s    ro   c            	   C   s   t ddddg dddS )Nz-ez
--editable	editablesr_   zpath/urlzkInstall a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS url.)r9   r:   r=   rL   r8   )r   r   r   r   r   editablex  s    rq   z--srcz--sourcez--source-dirz--source-directorysrc_dirdirzDirectory to check out editable projects into. The default in a virtualenv is "<venv path>/src". The default for global installs is "<current dir>/src".c             C   s   t | |jS )zGet a format_control object.)r   r9   )valuesr   r   r   r   _get_format_control  s    ru   c             C   s"   t |j| }t||j|j d S )N)ru   rt   r
   handle_mutual_excludes	no_binaryonly_binary)r   opt_strvaluer   existingr   r   r   _handle_no_binary  s    r|   c             C   s"   t |j| }t||j|j d S )N)ru   rt   r
   rv   rx   rw   )r   ry   rz   r   r{   r   r   r   _handle_only_binary  s    r}   c           	   C   s$   t t t } tdddtd| ddS )Nz--no-binaryr%   callbackrO   aR  Do not use binary packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either :all: to disable all binary packages, :none: to empty the set, or one or more package names with commas between them. Note that some packages are tricky to compile and may fail to install when this option is used on them.)r9   r:   r~   rH   r=   r8   )r
   r0   r   r|   )r%   r   r   r   rw     s    rw   c           	   C   s$   t t t } tdddtd| ddS )Nz--only-binaryr%   r~   rO   aG  Do not use source packages. Can be supplied multiple times, and each time adds to the existing value. Accepts either :all: to disable all source packages, :none: to empty the set, or one or more package names with commas between them. Packages without binary distributions will fail to install when this option is used on them.)r9   r:   r~   rH   r=   r8   )r
   r0   r   r}   )r%   r   r   r   rx     s    rx   z
--platformr-   z[Only use wheels compatible with <platform>. Defaults to the platform of the running system.z--python-versionr,   a!  Only use wheels compatible with Python interpreter version <version>. If not specified, then the current system interpreter minor version is used. A major version (e.g. '2') can be specified to match all minor revs of that major version.  A minor version (e.g. '34') can also be specified.z--implementationr/   zOnly use wheels compatible with Python implementation <implementation>, e.g. 'pp', 'jy', 'cp',  or 'ip'. If not specified, then the current interpreter implementation is used.  Use 'py' to force implementation-agnostic wheels.z--abir.   zOnly use wheels compatible with Python abi <abi>, e.g. 'pypy_41'.  If not specified, then the current interpreter abi tag is used.  Generally you will need to specify --implementation, --platform, and --python-version when using this option.c               C   s   t ddddddS )Nz--prefer-binaryprefer_binaryr<   Fz8Prefer older binary packages over newer source packages.)r9   r:   r=   r8   )r   r   r   r   r   r     s    r   z--cache-dir	cache_dirzStore the cache data in <dir>.)r9   r=   rL   r8   z--no-cache-dirstore_falsezDisable the cache.z	--no-depsz--no-dependenciesr1   z#Don't install package dependencies.z-bz--buildz--build-dirz--build-directory	build_dira>  Directory to unpack packages into and build in. Note that an initial build still takes place in a temporary directory. The location of temporary directories can be controlled by setting the TMPDIR environment variable (TEMP on Windows) appropriately. When passed, build directories are not cleaned in case of failures.z--ignore-requires-pythonignore_requires_pythonz'Ignore the Requires-Python information.z--no-build-isolationbuild_isolationTzDisable isolation when building a modern source distribution. Build dependencies specified by PEP 518 must be already installed if this option is used.z--install-optionr    r_   r   a"  Extra arguments to be supplied to the setup.py install command (use like --install-option="--install-scripts=/usr/local/bin"). Use multiple --install-option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.)r9   r:   rL   r8   z--global-optionr   zTExtra global options to be supplied to the setup.py call before the install command.z
--no-cleanz!Don't clean up build directories.)r:   r=   r8   z--prezYInclude pre-release and development versions. By default, pip only finds stable versions.z--disable-pip-version-checkdisable_pip_version_checkz{Don't periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.z-Zz--always-unzipalways_unzipc             C   s   |j jsi |j _y|dd\}}W n" tk
rF   |d|  Y nX |tkrh|d|dtf  |j j|g | dS )zkGiven a value spelled "algo:digest", append the digest to a list
    pointed to in a dict by the algo name.:   zTArguments to %s must be a hash name followed by a value, like --hash=sha256:abcde...z&Allowed hash algorithms for %s are %s.z, N)	rt   hashessplit
ValueErrorerrorr   join
setdefaultr_   )r   ry   rz   r   algodigestr   r   r   _merge_hashx  s    r   z--hashr   r~   stringzgVerify that the package's archive matches this hash before installing. Example: --hash=sha256:abcdef...)r9   r:   r~   rH   r8   z--require-hashesrequire_hasheszRequire a hash to check each requirement against, for repeatable installs. This option is implied when any package in a requirements file has a --hash option.zGeneral Options)r   r   zPackage Index Options)N)F)X__doc__
__future__r   r'   	functoolsr   optparser   r   r   pip._internal.exceptionsr   pip._internal.locationsr   r	   #pip._internal.models.format_controlr
   pip._internal.models.indexr   pip._internal.utils.hashesr   pip._internal.utils.typingr   pip._internal.utils.uir   typingr   r   r+   r7   help_r;   require_virtualenvr?   rA   rB   rC   listkeysr   rD   rJ   rM   rN   rQ   rU   rX   rY   r`   ra   
simple_urlrb   re   rf   rg   rk   rl   rm   ro   rq   srcru   r|   r}   rw   rx   r-   r,   r/   r.   r   r   no_cacheno_depsr   r   no_build_isolationr    r   no_cleanprer   r   r   hashr   general_groupindex_groupr   r   r   r   <module>	   s|  

+
		

