B
    '¦\IÈ  ã               @   s&  d dl mZmZmZmZ d dlmZmZm	Z	m
Z
mZmZ d dlmZ d dlZd dlmZmZmZ d dlmZ d dlZd dlmZ dd	lmZ dd
lmZmZmZmZ ddl m!Z! ee"ƒZ#e$ej%dkƒZ&eedƒƒZ'e' (dd¡Z)eeej*dƒƒ (dd¡Z+dd„ Z,dd„ Z-dd„ Z.G dd„ deƒZdd„ Z/dd„ Z0dd„ Z1G dd „ d eƒZ2d!d"„ Z3d#d$„ Z4d%d&„ Z5d'd(„ Z6d)d*„ Z7d+d,„ Z8d-d.„ Z9d/d0„ Z:d1d2„ Z;dYd4d5„Z<d6d7„ Z=d8d9„ Z>dZd;d<„Z?d=d>„ Z@d?d@„ ZAdAdB„ ZBdCdD„ ZCdEdF„ ZDdGdH„ ZEdIdJ„ ZFdKdL„ ZGdMdN„ ZHdOdP„ ZIdQdR„ ZJdSdT„ ZKdUdV„ ZLdWdX„ ZMdS )[é    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literals)ÚArgumentParserÚ	REMAINDERÚRawDescriptionHelpFormatterÚSUPPRESSÚ_CountActionÚ_HelpAction)Ú	getLoggerN)ÚabspathÚ
expanduserÚjoin)ÚPopen)Údedenté   )Ú__version__)ÚCOMPATIBLE_SHELLSÚCONDA_HOMEPAGE_URLÚDepsModifierÚUpdateModifier)ÚNULLÚwin32z
~/.condarcú%z%%z.condarcc              C   sÚ   t dd} | jddddt dd | jd	d
td | jdd
td | jddd}d|_t|ƒ t|ƒ t|ƒ t	|ƒ t
|ƒ t|ƒ t|ƒ t|ƒ t|ƒ t|ƒ t|dd t|ƒ t|ƒ t|ƒ t|dd | S )NzSconda is a tool for managing and deploying applications, environments and packages.)Údescriptionz-Vz	--versionÚversionzconda %sz'Show the conda version number and exit.)Úactionr   Úhelpz--debugÚ
store_true)r   r   z--jsonÚcommandÚcmd)ÚmetavarÚdestTZ	uninstall)ÚnameZupgrade)r   Úadd_argumentr   r	   Zadd_subparsersZrequiredÚconfigure_parser_cleanÚconfigure_parser_configÚconfigure_parser_createÚconfigure_parser_helpÚconfigure_parser_infoÚconfigure_parser_initÚconfigure_parser_installÚconfigure_parser_listÚconfigure_parser_packageÚconfigure_parser_removeÚconfigure_parser_runÚconfigure_parser_searchÚconfigure_parser_update)ÚpÚsub_parsers© r5   ú7lib/python3.7/site-packages/conda/cli/conda_argparse.pyÚgenerate_parser   sF    r7   c             C   sH   | j  dd¡\}}ddlm} ||t dd¡d ƒ}t||ƒ| |ƒ}|S )NÚ.é   r   )Úimport_module)ÚfuncÚrsplitÚ	importlibr:   Ú__name__Úgetattr)ÚargsÚparserZrelative_modZ	func_namer:   ÚmoduleZ	exit_coder5   r5   r6   Údo_callL   s
    rC   c             C   s   t | jjd j ¡ ƒS )Nr   )ÚtupleZ_subparsersZ_group_actionsÚchoicesÚkeys)rA   r5   r5   r6   Úfind_builtin_commandsV   s    rG   c                   s<   e Zd Z‡ fdd„Zdd„ Z‡ fdd„Z‡ fdd„Z‡  ZS )	r   c                sb   |  d¡st|d< d|kr(d}d|d< nd}tt| ƒj||Ž |rJt| ƒ | jr^|  jd7  _d S )NÚformatter_classÚadd_helpTFz

Options:
)Úgetr   Úsuperr   Ú__init__Úadd_parser_helpr   )Úselfr@   ÚkwargsZadd_custom_help)Ú	__class__r5   r6   rL   ]   s    

zArgumentParser.__init__c             C   sT   | j }|dkrdS x<|D ]4}d |j¡|kr0|S |j|kr>|S |j|kr|S qW dS )z¹Given a name, get the Action instance registered with this parser.
        If only it were made available in the ArgumentError object. It is
        passed as it's first arg...
        Nú/)Z_actionsr   Zoption_stringsr"   r#   )rN   r$   Z	containerr   r5   r5   r6   Ú_get_action_from_namem   s    


z$ArgumentParser._get_action_from_namec                sè   dd l }ddlm} t ¡ d }|rÔt|dƒr<|  |j¡}nd }|rÔ|jdkrÔ| 	d|j
¡}|rÔ| d¡}|s‚|  ¡  t d¡ nR|d| ƒ}|s¦dd	lm}	 |	|ƒ‚|d| ƒg}
|
 tjdd … ¡ t|
tjƒ tt| ƒ |¡ d S )
Nr   r9   )Úfind_executableÚargument_namer!   zinvalid choice: u?'([-\w]*?)'zconda-r   )ÚCommandNotFoundError)ÚreÚfind_commandsrS   ÚsysÚexc_infoÚhasattrrR   rT   r#   ÚmatchÚmessageÚgroupÚ
print_helpÚexitÚ
exceptionsrU   ÚextendÚargvÚ_execÚosÚenvironrK   r   Úerror)rN   r\   rV   rS   ÚexcZargumentÚmr!   Ú
executablerU   r@   )rP   r5   r6   rf   }   s,    

zArgumentParser.errorc                s‚   t t| ƒ ¡  tjdd … g dgdgdgdgfkr~ddlm} |ƒ }|r~dg}| d¡ | dd	„ t|ƒD ƒ¡ t	d
 
|¡ƒ d S )Nr9   Ú r   z-hz--help)rW   z-conda commands available from other packages:c             s   s   | ]}d | V  qdS )z  %sNr5   )Ú.0r!   r5   r5   r6   ú	<genexpr>£   s    z,ArgumentParser.print_help.<locals>.<genexpr>Ú
)rK   r   r^   rX   rb   rW   Úappendra   ÚsortedÚprintr   )rN   rW   Zother_commandsZbuilder)rP   r5   r6   r^   š   s    $
zArgumentParser.print_help)r>   Ú
__module__Ú__qualname__rL   rR   rf   r^   Ú__classcell__r5   r5   )rP   r6   r   \   s   r   c             C   s   t rtnt| |ƒS )N)Úon_winÚ	_exec_winÚ
_exec_unix)Úexecutable_argsÚenv_varsr5   r5   r6   rc   §   s    rc   c          	   C   sN   t | |d}z.y| ¡  W n tk
r6   | ¡  Y nX W d t |j¡ X d S )N)Úenv)r   ZcommunicateÚKeyboardInterruptÚwaitrX   r_   Ú
returncode)rw   rx   r3   r5   r5   r6   ru   «   s    ru   c             C   s   t  | d | |¡ d S )Nr   )rd   Úexecvpe)rw   rx   r5   r5   r6   rv   µ   s    rv   c               @   s"   e Zd Zedd„ ƒZddd„ZdS )ÚNullCountActionc             C   s*   t | |tƒtd fkr t| ||ƒ t | |ƒS )N)r?   r   Úsetattr)Ú	namespacer$   Úvaluer5   r5   r6   Ú_ensure_value»   s    zNullCountAction._ensure_valueNc             C   s&   |   || jd¡d }t|| j|ƒ d S )Nr   r9   )r‚   r#   r   )rN   rA   r€   ÚvaluesZoption_stringZ	new_countr5   r5   r6   Ú__call__Á   s    zNullCountAction.__call__)N)r>   rq   rr   Ústaticmethodr‚   r„   r5   r5   r5   r6   r~   ¹   s   r~   c             C   sÔ   t dƒ}t dƒ}| jd|||d}| d¡}|jdddd	d
 |jddddd
 |jddddd
 |jddddd
 |jdddtd
 |jddddd
 |jddddd
 |jddddd  t|ƒ |jd!d" d S )#Nz,
    Remove unused packages and caches.
    z3
    Examples:

        conda clean --tarballs
    Zclean)r   r   ÚepilogzRemoval Targetsz-az--allr   zDRemove index cache, lock files, unused cache packages, and tarballs.)r   r   z-iz--index-cachezRemove index cache.z-lz--lockzRemove all conda lock files.z-pz
--packagesz’Remove unused packages from writable package caches. WARNING: This does not check for packages installed using symlinks back to the package cache.z-sz--source-cachez-tz
--tarballszRemove cached package tarballs.z-fz--force-pkgs-dirsz¾Remove *all* writable package caches. This option is not included with the --all flag. WARNING: This will break environments with packages installed using symlinks back to the package cache.z-cz--tempfilesú+z™Remove temporary files that could not be deleted earlier due to being in-use.  Argument is path(s) to prefix(es) where files should be found and removed.)Únargsr   z.main_clean.execute)r;   )r   Ú
add_parserÚadd_argument_groupr%   r	   Úadd_output_and_prompt_optionsÚset_defaults)r4   ÚdescrÚexampler3   Zremoval_target_optionsr5   r5   r6   r&   Ì   sX    
r&   c             C   sÊ   d}| j d||d}t|ƒ |jddttd |jdddd	d
 |jdddd
 |jddddd
 |jdddtd
 |jddddd
 |jddtdd |jdddd
 |jdddtd |jdd d S ) Nz0Display information about current conda install.Úinfo)r   r   z	--offliner   )r   Údefaultr   z-az--allzShow all information.)r   r   z--basezDisplay base environment path.z-ez--envsz"List all known conda environments.z-lz	--licensez-sz--systemzList environment variables.z--rootÚbase)r   r   r#   z--unsafe-channelsz-Display list of channels with tokens exposed.ÚpackagesÚstoreÚ*)r   rˆ   r   z.main_info.execute)r;   )r‰   Úadd_parser_jsonr%   r   r	   rŒ   )r4   r   r3   r5   r5   r6   r*     s\    r*   c       
   	   C   sÈ  t dƒt }t dƒt }| jd|||d}t|ƒ | ddt ¡}| ¡ }|jddd	t d
 |jdddt	 
dd¡ dd¡tf d
 |jdddd
 | d¡}| ¡ }|jddd dd |jdddd
 |jdddd
 |jddd dd |jddd d
 | d!¡}| ¡ }	|	jd"ddd#d d$d% |	jd&d'd(d)g d*d% |	jd+d,d'd(d-g d*d% |	jd.d'd(d/g d*d% |	jd0d'd(d1g d*d% |	jd2d3d(d4g d$d% |	jd5dd6d
 |jd7d8dttd9 |jd:d; d S )<Nz™
    Modify configuration values in .condarc.  This is modeled after the git
    config command.  Writes to the user .condarc file (%s) by default.

    aã  
    See `conda config --describe` or %s/docs/config.html
    for details on all the options that can go in .condarc.

    Examples:

    Display all configuration values as calculated and compiled:

        conda config --show

    Display all identified configuration sources:

        conda config --show-sources

    Describe all available configuration options:

        conda config --describe

    Add the conda-canary channel:

        conda config --add channels conda-canary

    Set the output verbosity to level 3 (highest) for the current activate environment:

        conda config --set verbosity 3 --env

    Add the 'conda-forge' channel as a backup to 'defaults':

        conda config --append channels conda-forge

    Zconfig)r   r   r†   zConfig File Location SelectionzAWithout one of these flags, the user config file at '%s' is used.z--systemr   z*Write to the system .condarc file at '%s'.)r   r   z--envzzWrite to the active conda environment .condarc file (%s). If no environment is active, write to the user config file (%s).ZCONDA_PREFIXz<no active environment>r   z%%z--filer“   zWrite to the given file.zConfig Subcommandsz--showr”   z~Display configuration values as calculated and compiled. If no arguments given, show information for all configuration values.)rˆ   r   r   z--show-sourcesz-Display all identified configuration sources.z
--validatez#Validate all configuration sources.z
--describezrDescribe given configuration parameters. If no arguments given, show information for all configuration parameters.z--write-defaultz`Write the default configuration to a file. Equivalent to `conda config --describe > ~/.condarc`.zConfig Modifiersz--getzGet a configuration value.ÚKEY)rˆ   r   r   r   r"   z--appendr   rn   z5Add one configuration value to the end of a list key.)r–   ZVALUEz	--prependz--addz;Add one configuration value to the beginning of a list key.z--setzSet a boolean or string keyz--removezZRemove a configuration value from a list key. This removes
    all instances of the value.z--remove-keyr9   z0Remove a configuration key (and all its values).z--stdinzIApply configuration information given in yaml format piped through stdin.z-fz--force)r   r   r   z.main_config.execute)r;   )r   Úescaped_user_rc_pathr   r‰   r•   rŠ   Úadd_mutually_exclusive_groupr%   Úescaped_sys_rc_pathrd   ÚgetenvÚreplacer   r	   rŒ   )
r4   r   Zadditional_descrr3   Zconfig_file_location_groupÚlocationZ_config_subcommandsZconfig_subcommandsZ_config_modifiersZconfig_modifiersr5   r5   r6   r'   Q  sÔ    




r'   c             C   sŠ   d}|d }t dƒ}| jd|||d}|jdddd	d
 t|ƒ\}}|jdddd |jdddtd |jdtddtd |jdd d S )NzBCreate a new conda environment from a list of specified packages. zšTo use the created environment, use 'source activate envname' look in that directory first.  This command requires either the -n NAME or -p PREFIX option.z:
    Examples:

        conda create -n myenv sqlite

    Zcreate)r   r   r†   z--cloner“   z0Path to (or name of) existing local environment.ZENV)r   r   r"   z--no-default-packagesr   z4Ignore create_default_packages in the .condarc file.)r   r   z-mz--mkdirz--devz¥Use `sys.executable -m conda` in wrapper scripts instead of CONDA_EXE This is mainly for use during tests where we test new conda source against old Python versions.Údev)r   r   r#   r   z.main_create.execute)r;   )r   r‰   r%   Ú add_parser_create_install_updater	   r~   r   rŒ   )r4   r   r   rŽ   r3   Úsolver_mode_optionsÚpackage_install_optionsr5   r5   r6   r(     s<    r(   c             C   s  d}|}t dƒ}| jd|||d}|jddttd |jddd	td | d
¡}|jddttd |jddttd |jddttd |jddttd |jdddtd |jdddd ttƒ¡ d t	rÞ|jdddtd t
|ƒ |jddddd |jdd d S )Nz6Initialize conda for shell interaction. [Experimental]a  
    Key parts of conda's functionality require that it interact directly with the shell
    within which conda is being invoked. The `conda activate` and `conda deactivate` commands
    specifically are shell-level commands. That is, they affect the state (e.g. environment
    variables) of the shell context being interacted with. Other core commands, like
    `conda create` and `conda install`, also necessarily interact with the shell environment.
    They're therefore implemented in ways specific to each shell. Each shell must be configured
    to make use of them.

    This command makes changes to your system that are specific and customized for each shell.
    To see the specific files and locations on your system that will be affected before, use the
    '--dry-run' flag.  To see the exact changes that are being or will be made to each location,
    use the '--verbose' flag.

    IMPORTANT: After running `conda init`, most shells will need to be closed and restarted
               for changes to take effect.

    Zinit)r   r   r†   z--devr   )r   r   r   z--allz*Initialize all currently available shells.z
setup typez	--installz--userz	--no-userÚstore_falsez--systemz	--reversez Undo past effects of conda init.Zshellsr”   zÅOne or more shells to be initialized. If not given, the default value is 'bash' on unix and 'cmd.exe' on Windows. Use the '--all' flag to initialize all shells. Currently compatible shells are {%s}z, )rˆ   r   z--anaconda-promptz.Add an 'Anaconda Prompt' icon to your desktop.z-dz	--dry-runz'Only display what would have been done.)r   r   z.main_init.execute)r;   )r   r‰   r%   r	   r   rŠ   r   ro   r   rt   r•   rŒ   )r4   r   r   r†   r3   Zsetup_type_groupr5   r5   r6   r+   6  s|    
r+   c             C   s8   d}| j d||d}|jdddddd	 |jd
d d S )NzCDisplays a list of available conda commands and their help strings.r   )r   r   r    ZCOMMANDr“   ú?zCPrint help information for COMMAND (same as: conda COMMAND --help).)r"   r   rˆ   r   z.main_help.execute)r;   )r‰   r%   rŒ   )r4   r   r3   r5   r5   r6   r)   ²  s    r)   c             C   s²   d}t |d ƒ}t dƒ}| jd|||d}|jdddd	d
 t|ƒ\}}t|ƒ |jddtdd t|ƒ |jddddd |jddtdd |jdtddtd |jdd d S )Nz?Installs a list of packages into a specified conda environment.aí  

    This command accepts a list of package specifications (e.g, bitarray=0.8)
    and installs a set of packages consistent with those specifications and
    compatible with the underlying environment. If full compatibility cannot
    be assured, an error is reported and the environment is not changed.

    Conda attempts to install the newest versions of the requested packages. To
    accomplish this, it may update some packages that are already installed, or
    install additional packages. To prevent existing packages from updating,
    use the --freeze-installed option. This may force conda to install older
    versions of the requested packages, and it does not prevent additional
    dependency packages from being installed.

    If you wish to skip dependency checking altogether, use the '--no-deps'
    option. This may result in an environment with incompatible packages, so
    this option must be used with great caution.

    conda can also be called with a list of explicit conda package filenames
    (e.g. ./lxml-3.2.0-py27_0.tar.bz2). Using conda in this mode implies the
    --no-deps option, and should likewise be used with great caution. Explicit
    filenames and package specifications cannot be mixed in a single command.
    z:
    Examples:

        conda install -n myenv scipy

    Zinstall)r   r   r†   z
--revisionr“   z!Revert to the specified REVISION.ZREVISION)r   r   r"   z--force-reinstallr   z˜Ensure that any user-requested package for the current operation is uninstalled and reinstalled, even if that package already exists in the environment.)r   r   r   z-mz--mkdirz.Create the environment directory if necessary.)r   r   z	--clobberzZAllow clobbering of overlapping file paths within packages, and suppress related warnings.z--devz¥Use `sys.executable -m conda` in wrapper scripts instead of CONDA_EXE This is mainly for use during tests where we test new conda source against old Python versions.r   )r   r   r#   r   z.main_install.execute)r;   )	r   r‰   r%   rž   Úadd_parser_pruner   Úadd_parser_update_modifiersr~   rŒ   )r4   r   r   rŽ   r3   rŸ   r    r5   r5   r6   r,   Ä  sN    r,   c             C   sà   d}t dƒ}| jd||t|dd}t|ƒ t|ƒ t|ƒ t|ƒ |jdddd	d
 |jddddd
 |jdddd
 |jdddd
 |jddddd
 |jddddd
 |jdddddd |jddd d!d" |jd#d$ d S )%Nz,List linked packages in a conda environment.an  
    Examples:

    List all packages in the current environment:

        conda list

    List all packages installed into the environment 'myenv':

        conda list -n myenv

    Save packages for future use:

        conda list --export > package-list.txt

    Reinstall packages from an export file:

        conda create -n myenv --file package-list.txt

    ÚlistF)r   r   rH   r†   rI   z-cz--canonicalr   z;Output canonical names of packages only. Implies --no-pip. )r   r   z-fz--full-namez,Only search for full names, i.e., ^<regex>$.z
--explicitzbList explicitly all installed conda packaged with URL (output may be used by conda create --file).z--md5z%Add MD5 hashsum when using --explicitz-ez--exportzLOutput requirement string only (output may be used by  conda create --file).z-rz--revisionsz#List the revision history and exit.z--no-pipr¡   TZpipz+Do not include pip-only installed packages.)r   r   r#   r   Zregexr“   r¢   z4List only packages matching this regular expression.)r   rˆ   r   z.main_list.execute)r;   )	r   r‰   r   rM   Úadd_parser_prefixr•   Úadd_parser_show_channel_urlsr%   rŒ   )r4   r   Zexamplesr3   r5   r5   r6   r-     sd    r-   c             C   sœ   d}| j d||d}t|ƒ |jdddddd	d
 |jddddd |jddddd |jddddd |jddddd |jddddd |jdd d S )Nz/Low-level conda package utility. (EXPERIMENTAL)Úpackage)r   r   z-wz--whichÚPATHr‡   r“   z=Given some PATH print which conda package the file came from.)r"   rˆ   r   r   z-rz--resetr   z$Remove all untracked files and exit.)r   r   z-uz--untrackedz%Display all untracked files and exit.z
--pkg-nameÚunknownz$Package name of the created package.)r   r   r   z--pkg-versionz0.0z'Package version of the created package.z--pkg-buildr   z,Package build number of the created package.z.main_package.execute)r;   )r‰   r¦   r%   rŒ   )r4   r   r3   r5   r5   r6   r.   f  sH    r.   Úremovec             C   s@  d}t |d ƒ}t dƒ}d}|dkrP| j|t|| ¡  || ¡  || dd}n| j|t|||| dd}t|ƒ t|ƒ t|ƒ t|ƒ | d¡}|j	d	d
d| ¡  d |j	dd
d| ¡  d |j	ddd
ddd |j	dd
dt
dd t|ƒ t|ƒ t|ƒ |j	ddddd| d |j	dtdd t
d! |jd"d# d S )$Nz9%s a list of packages from a specified conda environment.a{  

    This command will also remove any package that depends on any of the
    specified packages as well---unless a replacement can be found without
    that dependency. If you wish to skip this dependency checking and remove
    just the requested packages, add the '--force' option. Note however that
    this may result in a broken environment, so use this with caution.
    z5
    Examples:

        conda %s -n myenv scipy

    zAlias for conda remove.r«   F)rH   r   r   r†   rI   zSolver Mode Modifiersz--allr   z.%s all packages, i.e., the entire environment.)r   r   z
--featuresz"%s features (instead of packages).z--force-removez--forcez¢Forces removal of a package without removing packages that depend on it. Using this option will usually leave your environment in a broken and inconsistent state.Zforce_remove)r   r   r#   z--no-pinÚignore_pinnedzIgnore pinned file.)r   r#   r   r   Zpackage_namesZpackage_namer“   r”   z)Package names to %s from the environment.)r"   r   rˆ   r   z--devz¥Use `sys.executable -m conda` in wrapper scripts instead of CONDA_EXE This is mainly for use during tests where we test new conda source against old Python versions.r   )r   r   r#   r   z.main_remove.execute)r;   )r   r‰   r   Ú
capitalizerM   Úadd_parser_pscheckr¦   Úadd_parser_channelsrŠ   r%   r   r£   Úadd_parser_networkingr‹   r~   rŒ   )r4   r$   r   r   rŽ   Zuninstall_helpr3   rŸ   r5   r5   r6   r/   ”  sz    



r/   c             C   s¤   d}|t dƒ }t dƒ}| jd|||d}t|ƒ |jddtdd	td
 |jdtddtd
 |jdtddtd
 |jddt ¡ d |jdtdd |j	dd d S )Nz8Run an executable in a conda environment. [Experimental]a  

    Use '--' (double dash) to separate CLI flags for 'conda run' from CLI flags sent to
    the process being launched.

    Example usage:

        $ conda create -y -n my-python-2-env python=2
        $ conda run -n my-python-2-env python --version
    z
    Úrun)r   r   r†   z-vz	--verbosez:Use once for info, twice for debug, three times for trace.Ú	verbosity)r   r   r#   r   z--devzÅSets `CONDA_EXE` to `python -m conda`, assuming the CWD containsthe root of conda development sources.  This is mainly for useduring tests where we test new conda source against old Pythonversions.r   z--debug-wrapper-scriptszqWhen this is set, where implemented, the shell wrapper scriptswill echo to stderr a lot of debugging information.Zdebug_wrapper_scriptsz--cwdzACurrent working directory for command to run in.  Defaults to cwd)r   r   Zexecutable_callzXExecutable name, with additional arguments to be passed to the executable on invocation.)rˆ   r   z.main_run.execute)r;   )
r   r‰   r¦   r%   r~   r   rd   Úgetcwdr   rŒ   )r4   r   r   r†   r3   r5   r5   r6   r0   ñ  sL    	r0   c             C   s   t dƒ}t dƒ}| jd|||d}|jdddd |jd	d
ddd |jdddddtd |jdddtd |jddtd |jdddtd |jddtd t|ƒ |jdddtd |jddtd |jddtd t|ƒ t|ƒ t|ƒ |j	dd d S ) Nz—Search for packages and display associated information.
    The input is a MatchSpec, a query language for conda packages.
    See examples below.
    aB  
    Examples:

    Search for a specific package named 'scikit-learn':

        conda search scikit-learn

    Search for packages containing 'scikit' in the package name:

        conda search *scikit*

    Note that your shell may expand '*' before handing the command over to conda.
    Therefore it is sometimes necessary to use single or double quotes around the query.

        conda search '*scikit'
        conda search "*scikit*"

    Search for packages for 64-bit Linux (by default, packages for your current
    platform are shown):

        conda search numpy[subdir=linux-64]

    Search for a specific version of a package:

        conda search 'numpy>=1.12'

    Search for a package on a specific channel

        conda search conda-forge::numpy
        conda search 'numpy[channel=conda-forge, subdir=osx-64]'
    Úsearch)r   r   r†   z--envsr   z”Search all of the current user's environments. If run as Administrator (on Windows) or UID 0 (on unix), search all known environments on the system.)r   r   z-iz--infoz0Provide detailed information about each package.z--subdirz
--platformr“   Zsubdirz‹Search the given subdir. Should be formatted like 'osx-64', 'linux-32', 'win-64', and so on. The default is to search the current platform.)r   r#   r   r   Z
match_specr”   r¢   )r   rˆ   r   z--canonicalz-fz--full-namez--names-onlyz-oz
--outdatedz--specz--reverse-dependencyz.main_search.execute)r;   )
r   r‰   r%   r   r	   Úadd_parser_knownr¯   r°   r•   rŒ   )r4   r   rŽ   r3   r5   r5   r6   r1   3  sr    r1   Úupdatec       	      C   s¢   d}t |d ƒ}t dƒ}d}|dkr<| jd|||| d}n| j||||| d}t|ƒ\}}t|ƒ |jddtd	d
 t|ƒ |jddtdd
 |jdd d S )Nz8Updates conda packages to the latest compatible version.aU  

    This command accepts a list of package names and updates them to the latest
    versions that are compatible with all other packages in the environment.

    Conda attempts to install the newest versions of the requested packages. To
    accomplish this, it may update some packages that are already installed, or
    install additional packages. To prevent existing packages from updating,
    use the --no-update-deps option. This may force conda to install older
    versions of the requested packages, and it does not prevent additional
    dependency packages from being installed.
    z5
    Examples:

        conda %s -n myenv scipy

    zAlias for conda update.r¶   )r   r   r†   z--force-reinstallr   z˜Ensure that any user-requested package for the current operation is uninstalled and reinstalled, even if that package already exists in the environment.)r   r   r   z	--clobberzZAllow clobbering of overlapping file paths within packages, and suppress related warnings.z.main_update.execute)r;   )r   r‰   rž   r£   r%   r   r¤   rŒ   )	r4   r$   r   r   rŽ   Z
alias_helpr3   rŸ   r    r5   r5   r6   r2      s>    r2   c             C   sˆ   t | ƒ t| ƒ t| ƒ}t| ƒ}t| ƒ t| ƒ}|jddtdd t|ƒ t	| ƒ t
| ƒ | jdg ddd | jd	d
dddd ||fS )Nz--download-onlyr   zSolve an environment and ensure package caches are populated, but exit prior to unlinking and linking packages into the prefix.)r   r   r   z--filern   zwRead package versions from the given file. Repeated file specifications can be passed (e.g. --file=file1 --file=file2).)r   r   r   r’   Zpackage_specr“   r”   z7Packages to install or update in the conda environment.)r"   r   rˆ   r   )r¦   r¯   Úadd_parser_solver_modeÚ"add_parser_package_install_optionsr°   r‹   r%   r   r§   r®   rµ   )r3   rŸ   r    Úoutput_and_prompt_optionsr5   r5   r6   rž   à  s4    rž   c             C   s   | j ddtd d S )Nz--force-pscheckr   )r   r   )r%   r	   )r3   r5   r5   r6   r®     s    r®   c             C   s*   | j dddtdd | j dddtd d S )	Nz--show-channel-urlsr   Zshow_channel_urlszXShow channel urls. Overrides the value given by `conda config --show show_channel_urls`.)r   r#   r   r   z--no-show-channel-urlsr¡   )r   r#   r   )r%   r   r	   )r3   r5   r5   r6   r§     s    r§   c             C   s   | j ddtdd dS )zë
    So we can use consistent capitalization and periods in the help. You must
    use the add_help=False argument to ArgumentParser or add_parser to use
    this. Add this first to be consistent with the default argparse output.

    z-hz--helpz Show this help message and exit.)r   r   N)r%   r   )r3   r5   r5   r6   rM   !  s    rM   c             C   s>   |   d¡}| ¡ }|jdddddd |jdd	dd
dd d S )Nz Target Environment Specificationz-nz--namer“   zName of environment.ZENVIRONMENT)r   r   r"   z-pz--prefixz0Full path to environment location (i.e. prefix).r©   )rŠ   r˜   r%   )r3   Ztarget_environment_groupZnpgroupr5   r5   r6   r¦   /  s    
r¦   c             C   s\   |   d¡}|jddttd |jddtdd |jddtd	d
td |jdddtdd |S )Nz(Output, Prompt, and Flow Control Optionsz--debugr   )r   r   r   z--jsonzEReport all output as json. Suitable for using conda programmatically.z-vz	--verbosez:Use once for info, twice for debug, three times for trace.r²   )r   r   r#   r   z-qz--quietzDo not display progress bar.)rŠ   r%   r   r	   r~   )r3   r¹   r5   r5   r6   r•   @  s.    
r•   c             C   s‚   |   d¡}|jddttd |jddddd |jd	dtd
d |jdddtdd |jddtddtd |jdddtdd |S )Nz(Output, Prompt, and Flow Control Optionsz--debugr   )r   r   r   z-dz	--dry-runz'Only display what would have been done.)r   r   z--jsonzEReport all output as json. Suitable for using conda programmatically.z-qz--quietzDo not display progress bar.z-vz	--verbosezRCan be used multiple times. Once for INFO, twice for DEBUG, three times for TRACE.r²   )r   r   r#   r   z-yz--yeszDo not ask for confirmation.)rŠ   r%   r   r	   r~   )r3   r¹   r5   r5   r6   r‹   ^  s@    
r‹   c             C   sD   |   d¡}|jdddddd |jdd	td
d |jdd	dd |S )NzChannel Customizationz-cz	--channelZchannelrn   aß  Additional channel to search for packages. These are URLs searched in the order
        they are given (including file:// for local directories).  Then, the defaults
        or channels from .condarc are searched (unless --override-channels is given).  You can use
        'defaults' to get the default packages for conda.  You can also use any name and the
        .condarc channel_alias value will be prepended.  The default channel_alias
        is http://conda.anaconda.org/.)r#   r   r   z--use-localr   z4Use locally built packages. Identical to '-c local'.)r   r   r   z--override-channelsz@Do not search default or .condarc channels.  Requires --channel.)r   r   )rŠ   r%   r   )r3   Zchannel_customization_optionsr5   r5   r6   r¯   ‡  s     
r¯   c             C   sš   |   d¡}| ¡ }|jdddtddd |jdd	dttd
 |jdddtddd |jddtjddtd |jddtjddtd |jdd	dtdd
 |S )NzSolver Mode Modifiersz--strict-channel-priorityÚstore_constZchannel_priorityÚstrictz|Packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel.)r   r#   r   Úconstr   z--channel-priorityr   )r   r#   r   r   z--no-channel-priorityZdisabledz|Package version takes precedence over channel priority. Overrides the value given by `conda config --show channel_priority`.z	--no-depsZdeps_modifierzŽDo not install, update, remove, or change dependencies. This WILL lead to broken environments and inconsistent behavior. Use at your own risk.)r   r¼   r#   r   r   z--only-depszOnly install dependencies.z--no-pinr¬   zIgnore pinned file.)rŠ   r˜   r%   r   r	   r   ZNO_DEPSZ	ONLY_DEPS)r3   rŸ   Zdeps_modifiersr5   r5   r6   r·   £  sV    
r·   c          	   C   sr   |   ¡ }|jdddtjdtdd |jddtjdtdd |jd	d
dtjdtdd |jdddtjddtd d S )Nz--freeze-installedz--no-update-depsrº   Zupdate_modifierz7Do not update or change already-installed dependencies.)r   r¼   r#   r   r   z--update-depszUpdate dependencies.z-Sz--satisfied-skip-solvezÉExit early and do not run the solver if the requested specs are satisfied. Also skips aggressive updates as configured by 'aggressive_update_packages'. Similar to the default behavior of 'pip install'.z--update-allz--allz1Update all installed packages in the environment.)r   r¼   r#   r   r   )r˜   r%   r   ZFREEZE_INSTALLEDr   ZUPDATE_DEPSZSPECS_SATISFIED_SKIP_SOLVEZ
UPDATE_ALL)rŸ   Zupdate_modifiersr5   r5   r6   r¤   Ú  s:    r¤   c             C   s   | j ddtdd d S )Nz--pruner   z”Remove packages that have previously been brought into the environment to satisfy dependencies of user-requested packages, but are no longer needed.)r   r   r   )r%   r   )r3   r5   r5   r6   r£      s
    r£   c             C   sJ   |   d¡}|jdddddd |jdd	d
dtdd |jddtdd |S )NzNetworking Optionsz-Cz--use-index-cacher   Fz9Use cache of channel index files, even if it has expired.)r   r   r   z-kz
--insecurer¡   Z
ssl_verifyzoAllow conda to perform "insecure" SSL connections and transfers. Equivalent to setting 'ssl_verify' to 'false'.)r   r#   r   r   z	--offlinez,Offline mode. Don't connect to the Internet.)rŠ   r%   r   )r3   Znetworking_optionsr5   r5   r6   r°   
  s$    
r°   c             C   s`   |   d¡}|jdddttd |jddtdd tr\|jddtd	td
 |jdddd	td
 |S )Nz(Package Linking and Install-time Optionsz-fz--forcer   )r   r   r   z--copyzCInstall all packages using copies instead of hard- or soft-linking.z--shortcutsZ	shortcuts)r   r   r#   r   z--no-shortcutsr¡   z"Don't install start menu shortcuts)rŠ   r%   r   r	   rt   )r3   r    r5   r5   r6   r¸   #  s2    
r¸   c             C   s   | j ddddtd d S )Nz	--unknownr   Frª   )r   r   r#   r   )r%   r	   )r3   r5   r5   r6   rµ   C  s    rµ   )r«   )r¶   )NZ
__future__r   r   r   r   Úargparser   ZArgumentParserBaser   r   r	   r
   r   Zloggingr   rd   Úos.pathr   r   r   Ú
subprocessr   rX   Útextwrapr   rj   r   Zbase.constantsr   r   r   r   Zcommon.constantsr   r>   ÚlogÚboolÚplatformrt   Zuser_rc_pathr›   r—   Úprefixr™   r7   rC   rG   rc   ru   rv   r~   r&   r*   r'   r(   r+   r)   r,   r-   r.   r/   r0   r1   r2   rž   r®   r§   rM   r¦   r•   r‹   r¯   r·   r¤   r£   r°   r¸   rµ   r5   r5   r5   r6   Ú<module>   sf    0
K
F? 7/|OS.
]Bm
@()7&
 