
    wBf                       d Z ddlmZ ddlZddlZddl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mZ dd	lm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 ddlmZ ddlm Z 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-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 erddl6Z6 e	e7      Z8 G d de      Z9e9xZ:Z; G d de      Z< G d de      Z= G d d e      Z> G d! d"e>      Z? G d# d$e>      Z@ G d% d&e>      ZA G d' d(e      ZB G d) d*e=      ZC G d+ d,e      ZD G d- d.eD      ZE G d/ d0eD      ZF G d1 d2eD      ZG G d3 d4eD      ZH G d5 d6e      ZI G d7 d8eeJ      ZK G d9 d:e      ZL G d; d<e      ZM G d= d>e      ZN G d? d@e      ZO G dA dBe      ZP G dC dDeeQ      ZR G dE dFe      ZS G dG dHeeT      ZU G dI dJe      ZV G dK dLe      ZW G dM dNeeJ      ZX G dO dPe      ZY G dQ dReeZ      Z[ G dS dTe[      Z\ G dU dVee]      Z^ G dW dXe      Z_ G dY dZe_      Z` G d[ d\e_      Za G d] d^e      Zb G d_ d`eec      Zd G da dbe      Ze G dc ddee      Zf G de dfe      Zg G dg dhe      Zh G di dje      Zi G dk dle      Zj G dm dne      Zk G do dpe      Zl G dq dre      Zm G ds dte      Zn G du dve      Zo G dw dxe      Zp G dy dzeeq      Zr G d{ d|ees      Zt G d} d~ees      Zu G d de      Zv G d de      Zw G d de      Zx G d de      Zy G d de      Zz G d dee{      Z| G d deeJ      Z} G d de      Z~ G d de      Z G d de      Z G d de      Z G d de      Z G d dees      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Zd ZddZddZ G d de      Zy)zConda exceptions.    )annotationsN)	timedelta)	getLoggerjoin)dedent)format_exceptionformat_exception_only)TYPE_CHECKING)JSONDecodeError   )
CondaErrorCondaExitZeroCondaMultiError)EntityEncoder)dals)	stringify)COMPATIBLE_SHELLSPathConflictSafetyChecks)on_win)dashlist)groupby_to_dict)get_signal_name)join_urlmaybe_unquote)DeprecatedError)ExceptionHandlerconda_exception_handler)Channelc                       e Zd Z fdZ xZS )ResolvePackageNotFoundc                    t        d |D              | _        t        d |D              }|| _        ddj                  d |D              z   }t        |   |       y )Nc              3  4   K   | ]  }|D ]	  }|s|   y wN ).0depsdeps      0lib/python3.12/site-packages/conda/exceptions.py	<genexpr>z2ResolvePackageNotFound.__init__.<locals>.<genexpr>-   s     Nd$N3#cNcNs   	c              3  Z   K   | ]#  }d j                  t        t        |             % yw) -> N)r   mapstrr'   	bad_chains     r*   r+   z2ResolvePackageNotFound.__init__.<locals>.<genexpr>.   s%      !
1:FKKC+,!
s   )+
c              3  &   K   | ]	  }d |z    yw)z  - %sNr&   r0   s     r*   r+   z2ResolvePackageNotFound.__init__.<locals>.<genexpr>2   s      #
'0X	!#
   )tuplebad_deps_formatted_chainsr   super__init__)selfr6   formatted_chainsmessage	__class__s       r*   r9   zResolvePackageNotFound.__init__*   sj     NhNN  !
>F!
 
 "2 #
4D#
 
 
 	!    __name__
__module____qualname__r9   __classcell__r=   s   @r*   r"   r"   )   s    " "r>   r"   c                       e Zd Z fdZ xZS )	LockErrorc                .    d|z  }t         |   |       y Nz%sr8   r9   r:   r<   msgr=   s      r*   r9   zLockError.__init__<       Wnr>   r?   rD   s   @r*   rF   rF   ;        r>   rF   c                  "     e Zd ZdZ fdZ xZS )ArgumentError   c                &    t        |   |fi | y r%   rI   r:   r<   kwargsr=   s      r*   r9   zArgumentError.__init__D       +F+r>   )r@   rA   rB   return_coder9   rC   rD   s   @r*   rO   rO   A   s    K, ,r>   rO   c                      e Zd Zy)HelpNr@   rA   rB   r&   r>   r*   rW   rW   H       r>   rW   c                       e Zd Z fdZ xZS )ActivateHelpc                :    t        d      }t        | 	  |       y )Na6  
        usage: conda activate [-h] [--[no-]stack] [env_name_or_prefix]

        Activate a conda environment.

        Options:

        positional arguments:
          env_name_or_prefix    The environment name or prefix to activate. If the
                                prefix is a relative path, it must start with './'
                                (or '.\' on Windows).

        optional arguments:
          -h, --help            Show this help message and exit.
          --stack               Stack the environment being activated on top of the
                                previous active environment, rather replacing the
                                current active environment with a new one. Currently,
                                only the PATH environment variable is stacked. This
                                may be enabled implicitly by the 'auto_stack'
                                configuration variable.
          --no-stack            Do not stack the environment. Overrides 'auto_stack'
                                setting.
        r   r8   r9   r:   r<   r=   s     r*   r9   zActivateHelp.__init__M   s!    
2 	!r>   r?   rD   s   @r*   r[   r[   L   s    " "r>   r[   c                       e Zd Z fdZ xZS )DeactivateHelpc                :    t        d      }t        | 	  |       y )Nz
        usage: conda deactivate [-h]

        Deactivate the current active conda environment.

        Options:

        optional arguments:
          -h, --help            Show this help message and exit.
        r]   r^   s     r*   r9   zDeactivateHelp.__init__k   s!    	
 	!r>   r?   rD   s   @r*   r`   r`   j   s    " "r>   r`   c                       e Zd Z fdZ xZS )GenericHelpc                .    d|z  }t         |   |       y )Nzhelp requested for %srI   )r:   commandr<   r=   s      r*   r9   zGenericHelp.__init__|   s    )G3!r>   r?   rD   s   @r*   rc   rc   {   s    " "r>   rc   c                       e Zd Z fdZ xZS )CondaSignalInterruptc                @    t        |      }t        | 	  d||       y )Nz Signal interrupt %(signal_name)s)signal_namesignum)r   r8   r9   )r:   rj   ri   r=   s      r*   r9   zCondaSignalInterrupt.__init__   s'    %f-.KPV 	 	
r>   r?   rD   s   @r*   rg   rg      s    
 
r>   rg   c                  "     e Zd Z	 d fd	Z xZS )TooManyArgumentsErrorc                    || _         || _        || _        || _        ||z
  dkD  rdnd}dj	                  |||dj                  |      |      }t        |   |g|  y )Nr   s z*{} Got {} argument{} ({}) but expected {}., )expectedreceivedoffending_argumentsoptional_messageformatr   r8   r9   )	r:   rq   rr   rs   rt   argssuffixrK   r=   s	           r*   r9   zTooManyArgumentsError.__init__   ss     ! #6  0 8+a/R:AAII)*
 	$t$r>   ro   r?   rD   s   @r*   rl   rl      s    HJ% %r>   rl   c                  $     e Zd Z fdZd Z xZS )ClobberErrorc                4    || _         t        |   |fi | y r%   )path_conflictr8   r9   )r:   r<   r|   rS   r=   s       r*   r9   zClobberError.__init__   s    *+F+r>   c                T    | j                   t        j                  k(  rdnd}| d|  dS )NClobberWarningrz   : r2   )r|   r   warn)r:   clz_names     r*   __repr__zClobberError.__repr__   s:     !!\%6%66  	
 2dV2&&r>   )r@   rA   rB   r9   r   rC   rD   s   @r*   rz   rz      s    ,'r>   rz   c                       e Zd Z fdZ xZS )BasicClobberErrorc                    t        d      }|j                  t        j                  k(  r|dz  }t        |   ||j                  ||       y )Nz
        Conda was asked to clobber an existing path.
          source path: %(source_path)s
          target path: %(target_path)s
        zQConda no longer clobbers existing paths without the use of the --clobber option
.)target_pathsource_pathr   r|   r   preventr8   r9   )r:   r   r   contextr<   r=   s        r*   r9   zBasicClobberError.__init__   s]    
   L$8$88&G 	!!##	 	 	
r>   r?   rD   s   @r*   r   r          
 
r>   r   c                       e Zd Z fdZ xZS )KnownPackageClobberErrorc                    t        d      }|j                  t        j                  k(  r|dz  }t        |   ||j                  |||       y )Na  
        The package '%(colliding_dist_being_linked)s' cannot be installed due to a
        path collision for '%(target_path)s'.
        This path already exists in the target prefix, and it won't be removed by
        an uninstall action in this transaction. The path appears to be coming from
        the package '%(colliding_linked_dist)s', which is already installed in the prefix.
        PIf you'd like to proceed anyway, re-run the command with the `--clobber` flag.
.)r   colliding_dist_being_linkedcolliding_linked_distr   )r:   r   r   r   r   r<   r=   s         r*   r9   z!KnownPackageClobberError.__init__   sb     
   L$8$88+G 	!!#(C"7 	 	
r>   r?   rD   s   @r*   r   r      s    
 
r>   r   c                       e Zd Z fdZ xZS )UnknownPackageClobberErrorc                    t        d      }|j                  t        j                  k(  r|dz  }t        |   ||j                  ||       y )Nax  
        The package '%(colliding_dist_being_linked)s' cannot be installed due to a
        path collision for '%(target_path)s'.
        This path already exists in the target prefix, and it won't be removed
        by an uninstall action in this transaction. The path is one that conda
        doesn't recognize. It may have been created by another package manager.
        r   )r   r   r   )r:   r   r   r   r<   r=   s        r*   r9   z#UnknownPackageClobberError.__init__   s]    
   L$8$88+G 	!!#(C	 	 	
r>   r?   rD   s   @r*   r   r          
 
r>   r   c                       e Zd Z fdZ xZS )SharedLinkPathClobberErrorc           	         t        d      }|j                  t        j                  k(  r|dz  }t        |   ||j                  |dj                  d |D                     y )Nz
        This transaction has incompatible packages due to a shared path.
          packages: %(incompatible_packages)s
          path: '%(target_path)s'
        r   rp   c              3  2   K   | ]  }t        |        y wr%   r/   )r'   ds     r*   r+   z6SharedLinkPathClobberError.__init__.<locals>.<genexpr>  s     +WqCF+W   )r   incompatible_packages)r   r|   r   r   r8   r9   r   )r:   r   incompatible_package_distsr   r<   r=   s        r*   r9   z#SharedLinkPathClobberError.__init__   sm    
   L$8$88+G 	!!#"&))+W<V+W"W	 	 	
r>   r?   rD   s   @r*   r   r      r   r>   r   c                       e Zd Z fdZ xZS )CommandNotFoundErrorc                   h d}h d}h d}ddl m}  |        ||v radg}t        r|j                  t	        d             |j                  t	        d      d	t        t              iz         d
j                  |      }nD||v rd}n=ddlm	} ddl
m}	 d}||z  |z  t         |	             z  }
 |||
      }|r|d|d   z  z  }t        | 9  ||       y )N>   runactivate
deactivate>   --helpinfolistcleanconfigcreateremovesearchupdateinstallpackageupgrade	uninstall>   buildindexrenderconvertdevelopinspectskeletonmetapackager   )init_loggerszGYour shell has not been properly configured to use 'conda %(command)s'.z
                If using 'conda %(command)s' from a batch script, change your
                invocation to 'CALL conda.bat %(command)s'.
                aK  
            To initialize your shell, run

                $ conda init <SHELL_NAME>

            Currently supported shells are:%(supported_shells)s

            See 'conda init --help' for more information and options.

            IMPORTANT: You may need to close and restart your shell after running 'conda init'.
            supported_shellsr2   z0To use 'conda %(command)s', install conda-build.r   )get_close_matches)find_commandszNo command 'conda %(command)s'.z
Did you mean 'conda %s'?)re   )cli.mainr   r   appendr   r   r   r   difflibr   cli.find_commandsr   setr8   r9   )r:   re   activate_commandsconda_commandsbuild_commandsr   builderr<   r   r   choicescloser=   s               r*   r9   zCommandNotFoundError.__init__  s   


	
 	+'' ZG  NN
 '1B(C$ ii(G&HG187G! ! ! mo&'  &gw7E7%(BB'2r>   r?   rD   s   @r*   r   r   
  s    T3 T3r>   r   c                       e Zd Z fdZ xZS )PathNotFoundErrorc                ,    d}t         |   ||       y Nz%(path)s)pathrI   r:   r   r<   r=   s      r*   r9   zPathNotFoundError.__init__c      t,r>   r?   rD   s   @r*   r   r   b      - -r>   r   c                       e Zd Z fdZ xZS )DirectoryNotFoundErrorc                ,    d}t         |   ||       y r   rI   r   s      r*   r9   zDirectoryNotFoundError.__init__i  r   r>   r?   rD   s   @r*   r   r   h  r   r>   r   c                       e Zd Z fdZ xZS )EnvironmentLocationNotFoundc                ,    d}t         |   ||       y )Nz%Not a conda environment: %(location)s)locationrI   )r:   r   r<   r=   s      r*   r9   z$EnvironmentLocationNotFound.__init__o  s    984r>   r?   rD   s   @r*   r   r   n  s    5 5r>   r   c                       e Zd Z fdZ xZS )EnvironmentNameNotFoundc                >    t        d      }t        | 	  ||       y )Nz
        Could not find conda environment: %(environment_name)s
        You can list all discoverable environments with `conda info --envs`.
        )environment_namer]   )r:   r   r<   r=   s      r*   r9   z EnvironmentNameNotFound.__init__u  s'    
 	3CDr>   r?   rD   s   @r*   r   r   t  s    E Er>   r   c                       e Zd Z fdZ xZS )NoBaseEnvironmentErrorc                :    t        d      }t        | 	  |       y )Nz
        This conda installation has no default base environment. Use
        'conda create' to create new environments and 'conda activate' to
        activate environments.
        r]   r^   s     r*   r9   zNoBaseEnvironmentError.__init__  s!    
 	!r>   r?   rD   s   @r*   r   r     s    " "r>   r   c                       e Zd Z fdZ xZS )"DirectoryNotACondaEnvironmentErrorc                >    t        d      }t        | 	  ||       y )Nz
        The target directory exists, but it is not a conda environment.
        Use 'conda create' to convert the directory to a conda environment.
          target directory: %(target_directory)s
        )target_directoryr]   )r:   r   r<   r=   s      r*   r9   z+DirectoryNotACondaEnvironmentError.__init__  s'    
 	3CDr>   r?   rD   s   @r*   r   r     s    E Er>   r   c                       e Zd Z fdZ xZS )CondaEnvironmentErrorc                0    d|z  }t        |   |g|  y rH   rI   r:   r<   rv   rK   r=   s       r*   r9   zCondaEnvironmentError.__init__  s    Wn$t$r>   r?   rD   s   @r*   r   r     s    % %r>   r   c                       e Zd Z fdZ xZS )
DryRunExitc                (    d}t         |   |       y )NzDry run. Exiting.rI   )r:   rK   r=   s     r*   r9   zDryRunExit.__init__  s    !r>   r?   rD   s   @r*   r   r     rM   r>   r   c                       e Zd Z fdZ xZS )CondaSystemExitc                h    dj                  d | j                  D              }t        |   |       y )N c              3  2   K   | ]  }t        |        y wr%   r   )r'   args     r*   r+   z+CondaSystemExit.__init__.<locals>.<genexpr>  s     5Cs3x5r   )r   rv   r8   r9   )r:   rv   rK   r=   s      r*   r9   zCondaSystemExit.__init__  s(    hh549955r>   r?   rD   s   @r*   r   r     rM   r>   r   c                       e Zd Z fdZ xZS )PaddingErrorc                2    d||fz  }t         |   |       y )NzgPlaceholder of length '%d' too short in package %s.
The package must be rebuilt with conda-build > 2.0.rI   )r:   distplaceholderplaceholder_lengthrK   r=   s        r*   r9   zPaddingError.__init__  s*    B!4() 	
 	r>   r?   rD   s   @r*   r   r     s     r>   r   c                       e Zd Z fdZ xZS )	LinkErrorc                $    t         |   |       y r%   rI   r^   s     r*   r9   zLinkError.__init__      !r>   r?   rD   s   @r*   r   r         " "r>   r   c                       e Zd Z fdZ xZS )CondaOSErrorc                0    d|z  }t        |   |fi | y rH   rI   )r:   r<   rS   rK   r=   s       r*   r9   zCondaOSError.__init__  s    Wn''r>   r?   rD   s   @r*   r   r     s    ( (r>   r   c                       e Zd Z fdZ xZS )
ProxyErrorc                :    t        d      }t        | 	  |       y )Na-  
        Conda cannot proceed due to an error in your proxy configuration.
        Check for typos and other configuration errors in any '.netrc' file in your home directory,
        any environment variables ending in '_PROXY', and any other system-wide proxy
        configuration settings.
        r]   r^   s     r*   r9   zProxyError.__init__  s!    
 	!r>   r?   rD   s   @r*   r   r     s    	" 	"r>   r   c                       e Zd Z fdZ xZS )CondaIOErrorc                .    d|z  }t         |   |       y rH   rI   r   s       r*   r9   zCondaIOError.__init__  rL   r>   r?   rD   s   @r*   r  r    rM   r>   r  c                       e Zd Z fdZ xZS )CondaFileIOErrorc                D    || _         d| d| }t        |   |g|  y )N'z'. )filepathr8   r9   )r:   r  r<   rv   rK   r=   s        r*   r9   zCondaFileIOError.__init__  s.     (3wi($t$r>   r?   rD   s   @r*   r  r    s    % %r>   r  c                       e Zd Z fdZ xZS )CondaKeyErrorc                `    || _         |d| | _        t        |   | j                  g|  y )Nr   )keyrK   r8   r9   )r:   r  r<   rv   r=   s       r*   r9   zCondaKeyError.__init__  s2    WBwi()D)r>   r?   rD   s   @r*   r
  r
    s    * *r>   r
  c                      e Zd Zy)ChannelErrorNrX   r&   r>   r*   r  r    rY   r>   r  c                       e Zd Z fdZ xZS )ChannelNotAllowedc                    t        |      }|j                  }t        |j                        }t	        d      }t
        |   |||       y )Nz
        Channel not included in allowlist:
          channel name: %(channel_name)s
          channel url: %(channel_url)s
        )channel_urlchannel_name)r    namer   base_urlr   r8   r9   )r:   channelr  r  r<   r=   s        r*   r9   zChannelNotAllowed.__init__  sK    '"||#G$4$45
 	kUr>   r?   rD   s   @r*   r  r    s    V Vr>   r  c                  2     e Zd ZU ded<   	 d	 d fdZ xZS )UnavailableInvalidChannelz	str | intstatus_codec                   t        |      }|j                  }t        |j                        }t	        |dd       }t        d      }|j                  dk(  r2t        |j                  |j                        }|t        d| d      z  }	 |j                         }	|	j                  dd       xs |}|	j                  dd       xs |}|xs d}|xs d}t        |t              r|j!                         }|| _        t$        
| M  d	| d
| d| d| d| 
||||t)        |d      xs d|	       y # t        t        f$ r i }	Y {w xY w)Nreasona<  
            The channel is not accessible or is invalid.

            You will need to adjust your conda configuration to proceed.
            Use `conda config --show channels` to view your configuration's current state,
            and use `conda config --show-sources` to view config file locations.
            filez
                As of conda 4.3, a valid channel must contain a `noarch/repodata.json` and
                associated `noarch/repodata.json.bz2` file, even if `noarch/repodata.json` is
                empty. Use `conda index zo`, or create `noarch/repodata.json`
                and associated `noarch/repodata.json.bz2`.
                r<   000zUNAVAILABLE OR INVALIDzHTTP r   z for channel z <z>

   content_max_lenro   )r  r  r  r  response_detailsjson)r    r  r   r  getattrr   schemer   r   r   r"  getAttributeErrorr   
isinstancer/   upperr  r8   r9   r   )r:   r  r  responser  r  r  r<   urlbodyr=   s             r*   r9   z"UnavailableInvalidChannel.__init__  sr    '"||#G$4$45 8T2
 >>V#7++W\\:Cv) *- . G	;==?D XXh-7Fhhy$/:7G "*U33fc"\\^F&K=&|nB{mSXY`Xab%##&xFL" 	 	
 0 	D	s   D, ,E ?E r%   )r)  zrequests.models.Response | None)r@   rA   rB   __annotations__r9   rC   rD   s   @r*   r  r    s"     QU7
.M7
 7
r>   r  c                       e Zd Z fdZ xZS )OperationNotAllowedc                $    t         |   |       y r%   rI   r^   s     r*   r9   zOperationNotAllowed.__init__1  r   r>   r?   rD   s   @r*   r.  r.  0  r   r>   r.  c                       e Zd Z fdZ xZS )CondaImportErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zCondaImportError.__init__6  rL   r>   r?   rD   s   @r*   r1  r1  5  rM   r>   r1  c                       e Zd Z fdZ xZS )
ParseErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zParseError.__init__<  rL   r>   r?   rD   s   @r*   r4  r4  ;  rM   r>   r4  c                       e Zd Z fdZ xZS )CouldntParseErrorc                L    || _         t        | 	  | j                  d          y )Nr   )r  r8   r9   rv   )r:   r  r=   s     r*   r9   zCouldntParseError.__init__B  s    1&r>   r?   rD   s   @r*   r7  r7  A  s    ' 'r>   r7  c                       e Zd Z fdZ xZS )ChecksumMismatchErrorc                \    t        d      }t        |      }t        |   ||||||       y )Na   
        Conda detected a mismatch between the expected content and downloaded content
        for url '%(url)s'.
          download saved to: %(target_full_path)s
          expected %(checksum_type)s: %(expected_checksum)s
          actual %(checksum_type)s: %(actual_checksum)s
        )r*  target_full_pathchecksum_typeexpected_checksumactual_checksum)r   r   r8   r9   )r:   r*  r<  r=  r>  r?  r<   r=   s          r*   r9   zChecksumMismatchError.__init__H  sD     
 C -'/+ 	 	
r>   r?   rD   s   @r*   r:  r:  G  r   r>   r:  c                       e Zd Z fdZ xZS )PackageNotInstalledErrorc                @    t        d      }t        | 	  |||       y )Nz{
        Package is not installed in prefix.
          prefix: %(prefix)s
          package name: %(package_name)s
        )prefixpackage_namer]   )r:   rC  rD  r<   r=   s       r*   r9   z!PackageNotInstalledError.__init__`  s(    
 	lKr>   r?   rD   s   @r*   rA  rA  _  s    L Lr>   rA  c                  $     e Zd Z	 	 d fd	Z xZS )CondaHTTPErrorc                b   	 |j                         }|j                  dd       xs |}|j                  dd       xs |}t	        |      }|xs d}|xs d}t        |t              r|j                         }|xs d}t        |t              rt        |      j                  dd      d   }	 |j                  d	   }	d
|	 d}	t        
| 5  t        d| d| d| d| d|	 d      |z   ||||t        |d      xs d||       y # t        t        f$ r i }Y w xY w# t        t        f$ r d}	Y mw xY w)Nr  r<   r  zCONNECTION FAILED-:r   zCF-RAYzCF-RAY: r2   ro   z
                HTTP r   z
 for url <z>
                Elapsed: z
                r  r  )r*  r  r  elapsed_timer!  r"  	caused_by)r"  r%  r&  r   r   r'  r/   r(  r   splitheadersKeyErrorr8   r9   r   r   )r:   r<   r*  r  r  rK  r)  rL  r+  cf_rayr=   s             r*   r9   zCondaHTTPError.__init__l  sz   	;==?D XXh-7Fhhy$/:7G C !*U..fc"\\^F#*slI.|,223:2>L	+%%h/F  xr*F!]!F8:cU ;& (   #%&xFL"! 	 	
1 0 	D	& ) 	F	s#   D +D DDD.-D.NNr?   rD   s   @r*   rF  rF  k  s     6
 6
r>   rF  c                      e Zd Zy)CondaSSLErrorNrX   r&   r>   r*   rS  rS    rY   r>   rS  c                      e Zd Zy)AuthenticationErrorNrX   r&   r>   r*   rU  rU    rY   r>   rU  c                        e Zd Zd fd	Z xZS )PackagesNotFoundErrorc                    d }|r<t        d      }ddlm} |j                  r|t        d      z  } ||      } ||      }nt        d      } ||      }d}t        |   |||||       y )	Nc                8    ddj                  d | D              z   S )Nz  - z
  - c              3  2   K   | ]  }t        |        y wr%   r   )r'   xs     r*   r+   zCPackagesNotFoundError.__init__.<locals>.<lambda>.<locals>.<genexpr>  s     =Wc!f=Wr   r   )iterables    r*   <lambda>z0PackagesNotFoundError.__init__.<locals>.<lambda>  s    v=Wh=W0W'W r>   a  
            The following packages are not available from current channels:

            %(packages_formatted)s

            Current channels:

            %(channels_formatted)s

            To search for alternate channels that may provide the conda package you're
            looking for, navigate to

                https://anaconda.org

            and use the search bar at the top of the page.
            r   r   z
                Note: 'use_only_tar_bz2' is enabled. This might be omitting some
                packages from the index. Set this option to 'false' and retry.
                z|
            The following packages are missing from the target environment:
            %(packages_formatted)s
            r&   )packagespackages_formattedchannel_urlschannels_formatted)r   base.contextr   use_only_tar_bz2r8   r9   )	r:   r_  ra  format_listr<   r   r`  rb  r=   s	           r*   r9   zPackagesNotFoundError.__init__  s    WG$ .''4  "-X!6!,\!:G "-X!6!#1%1 	 	
r>   )r&   r?   rD   s   @r*   rW  rW    s    1
 1
r>   rW  c                  *     e Zd ZdZd Zd fd	Z xZS )UnsatisfiableErrora  An exception to report unsatisfiable dependencies.

    Args:
        bad_deps: a list of tuples of objects (likely MatchSpecs).
        chains: (optional) if True, the tuples are interpreted as chains
            of dependencies, from top level to bottom. If False, the tuples
            are interpreted as simple lists of conflicting specs.

    Returns:
        Raises an exception with a formatted message detailing the
        unsatisfiable specifications.
    c                   i }t        |t        d      D ]  }|dd  D cg c]  }|j                  d       }}|d   ft        d |D              z   }dt        d |D              z   }d	}|j	                         D ]>  \  }	}
|	d t        |       |k(  st        |
|      D ]  \  }}|j                  |        d}@ |r|D cg c]  }|h c}||<    |j	                         D ]  \  }}
g }t        ||
      D ]  \  }}d
|vrnAt        |      dk(  r|j                          n"|j                  d
       |j                  d       |d   dk(  rd|dd  z   }|j                  |r*dj                  |dj                  t        |                  n|        dj                  |      ||<    t        |j                               D cg c]  }||   	 c}S c c}w c c}w c c}w )NT)r  reverser   r   r   c              3  &   K   | ]	  }|d      yw)r   Nr&   r'   vs     r*   r+   z7UnsatisfiableError._format_chain_str.<locals>.<genexpr>  s     #7QAaD#7r4   rx   c              3  &   K   | ]	  }|d      yw)rP   Nr&   rk  s     r*   r+   z7UnsatisfiableError._format_chain_str.<locals>.<genexpr>  s      4!1 4r4   Fro   *@zfeature:z{} {}|r-   )sortedlen	partitionr5   itemszipaddclearr   r   ru   r   keys)r:   r6   chainsr)   rn   dep1r  valsfoundkey2csetscsetvalr(   r  s                  r*   _format_chain_strz$UnsatisfiableError._format_chain_str  s   (T: 	6C.1!"g6AKK$6D6q6)e#7$#777C5 4t 444DE%||~ !e
#c(#s*%(%5 &	c& E	!
 045u5s	6 !,,. 	,JCD!#uo 
dT>Y!^JJLKKOHHSM7c>%QR0DDHGNN4&,)?@d !++d+F3K	,  (.fkkm'<=s==7 7 6" >s   G
GGc                   ddl m} t        d      t        d      t        d      t        d      d}d}g | _        t	        |      d	k(  r|d
z  }n|j                         D ]  \  }}|s
g }	|dk(  rN||d   z  }|D 
ch c]  }
|
d	   d   j                   }}
i }|D ]t  }|d	   d   j                  |v s|j                  |d	   d   j                        sg ||d	   d   j                  <   ||d	   d   j                     j                  |d	          v |dz  }|j                         D ]  \  }}t	        |      dkD  s|d|z  z  }|dj                  |D cg c]*  }dj                  |D cg c]  }t        |       c}      , c}}      z  }| xj                  |D cg c]  }t        |       c}z  c_         `|D ]6  \  }}|D cg c]  }t         ||d              }}|	j                  |       8 |	r| j                  |	      }	n|	D cg c]  }dj                  |       }	}|||   j                  t        |	            z  } |r|dz  }t        | A  |       y c c}
w c c}w c c}}w c c}w c c}w c c}w )Nr   )	MatchSpeca  

The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:
{specs}

Your python: {ref}

If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.

        z

The following specifications were found to be incompatible with a past
explicit spec that is not an explicit spec in this operation ({ref}):
{specs}

                    zb

The following specifications were found to be incompatible with each other:
                    zy

The following specifications were found to be incompatible with your system:
{specs}

Your installed version is: {ref}
)pythonrequest_conflict_with_historydirectvirtual_packagero   r   z
Did not find conflicting dependencies. If you would like to know which
packages conflict ensure that you have enabled unsatisfiable hints.

conda config --set unsatisfiable_hints True
            r  rJ  z:
Output in format: Requested package -> Available versionsz

Package %s conflicts for:
r2   r-   )targetrp   )specsrefzY
Note that strict channel priority may have removed packages required for satisfiability.)models.match_specr  r   unsatisfiablerr  rt  r  r%  r   r   r/   r5   r  ru   r   r8   r9   )r:   r6   ry  strictr  messagesrK   
class_name	dep_class_chainsr   last_dep_entrydep_constraint_mapr)   chaincientries	dep_chaininstalled_blockerr=   s                       r*   r9   zUnsatisfiableError.__init__  s   0 $ .2.   $ C)
V x=A  C *2)9 $%
I G!X-x11AJ)KA!A$r(--)K)K-/*#, SC"1vbz.@'9'='=c!fRjoo'NJL$6s1vbz$G 23q6":?? C J J3q6 R	S
 \\*<*B*B*D "JC"5zA~ #'H3'N N #tyyOT$U!V[[!1DQ#a&1D%E$U(" !" !% 2 2BG7"7>E'N7" !" 2" =F 68I'8 MV)EHIc$$? @)I ) $NN956 #&*&<&<W&EG=D&Etyy|&EG&Ex
3::"*7"39J  ;   E$J 8C
 	M *L 2E$U7") 'Fs0   ?I*I4,I/>	I4!I:I?J/I4)TF)r@   rA   rB   __doc__r  r9   rC   rD   s   @r*   rg  rg    s    >@c cr>   rg  c                       e Zd Z fdZ xZS )RemoveErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zRemoveError.__init__w  rL   r>   r?   rD   s   @r*   r  r  v  rM   r>   r  c                       e Zd Z fdZ xZS )DisallowedPackageErrorc                z    ddl m} |j                  |      }d}t        |   |f||j                         d| y )Nr   PackageRecordziThe package '%(dist_str)s' is disallowed by configuration.
See 'conda config --show disallowed_packages'.)package_refdist_str)models.recordsr  from_objectsr8   r9   r  )r:   r  rS   r  r<   r=   s        r*   r9   zDisallowedPackageError.__init__}  sM    1#00== 	 		
!,{7K7K7M	
QW	
r>   r?   rD   s   @r*   r  r  |  s    

 

r>   r  c                       e Zd Z fdZ xZS )SpecsConfigurationConflictErrorc           	         t        d      j                  t        |d      t        |d      t        |dd            }t        |   ||||       y )Nap  
        Requested specs conflict with configured specs.
          requested specs: {requested_specs_formatted}
          pinned specs: {pinned_specs_formatted}
        Use 'conda config --show-sources' to look for 'pinned_specs' and 'track_features'
        configuration parameters.  Pinned specs may also be defined in the file
        {pinned_specs_path}.
           z
conda-metapinned)requested_specs_formattedpinned_specs_formattedpinned_specs_path)requested_specspinned_specsrC  )r   ru   r   r   r8   r9   )r:   r  r  rC  r<   r=   s        r*   r9   z(SpecsConfigurationConflictError.__init__  sf    	
 &&.&B#+L!#<"6<B  
 	 	+%	 	 	
r>   r?   rD   s   @r*   r  r    r   r>   r  c                       e Zd Z fdZ xZS )CondaIndexErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zCondaIndexError.__init__  rL   r>   r?   rD   s   @r*   r  r    rM   r>   r  c                       e Zd Z fdZ xZS )CondaValueErrorc                ,    t        |   |g|i | y r%   rI   )r:   r<   rv   rS   r=   s       r*   r9   zCondaValueError.__init__  s    24262r>   r?   rD   s   @r*   r  r    s    3 3r>   r  c                       e Zd Z fdZ xZS )CyclicalDependencyErrorc                    ddl m t        fd|D              }dt        d |D              z  }t	        |   |fd|i| y )Nr   r  c              3  @   K   | ]  }j                  |        y wr%   )r  )r'   pr  s     r*   r+   z3CyclicalDependencyError.__init__.<locals>.<genexpr>  s!      %
./M&&q)%
s   z/Cyclic dependencies exist among these items: %sc              3  <   K   | ]  }|j                           y wr%   )r  )r'   r  s     r*   r+   z3CyclicalDependencyError.__init__.<locals>.<genexpr>  s      O
AJJLO
s   packages_with_cycles)r  r  r5   r   r8   r9   )r:   r  rS   r<   r  r=   s       @r*   r9   z CyclicalDependencyError.__init__  s\    1$ %
3G%
  
 Dh O
"6O
 G
 
 	V7KVvVr>   r?   rD   s   @r*   r  r    s    	W 	Wr>   r  c                       e Zd Z fdZ xZS )CorruptedEnvironmentErrorc                B    t        d      }t        |   |f||d| y )Na-  
        The target environment has been corrupted. Corrupted environments most commonly
        occur when the conda process is force-terminated while in an unlink-link
        transaction.
          environment location: %(environment_location)s
          corrupted file: %(corrupted_file)s
        )environment_locationcorrupted_filer]   )r:   r  r  rS   r<   r=   s        r*   r9   z"CorruptedEnvironmentError.__init__  s9    
 		
!5)	
 		
r>   r?   rD   s   @r*   r  r    s    
 
r>   r  c                       e Zd Z fdZ xZS )CondaHistoryErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zCondaHistoryError.__init__  rL   r>   r?   rD   s   @r*   r  r    rM   r>   r  c                       e Zd Z fdZ xZS )CondaUpgradeErrorc                .    d|z  }t         |   |       y rH   rI   rJ   s      r*   r9   zCondaUpgradeError.__init__  rL   r>   r?   rD   s   @r*   r  r    rM   r>   r  c                       e Zd Z fdZ xZS )CondaVerificationErrorc                $    t         |   |       y r%   rI   r^   s     r*   r9   zCondaVerificationError.__init__  r   r>   r?   rD   s   @r*   r  r    r   r>   r  c                       e Zd Z fdZ xZS )SafetyErrorc                $    t         |   |       y r%   rI   r^   s     r*   r9   zSafetyError.__init__  r   r>   r?   rD   s   @r*   r  r    r   r>   r  c                       e Zd Z fdZ xZS )CondaMemoryErrorc                .    d}t        |   |fd|i| y )NzMThe conda process ran out of memory. Increase system memory and/or try again.rL  rI   r:   rL  rS   r<   r=   s       r*   r9   zCondaMemoryError.__init__  s    a@I@@r>   r?   rD   s   @r*   r  r        A Ar>   r  c                       e Zd Z fdZ xZS )NotWritableErrorc                   |j                  ||d       t        rt        d      }nCt        d      }|j                  t        j                         t        j
                         d       t        |   |fi | || _        y )N)r   errnoz{
            The current user does not have write permissions to a required path.
              path: %(path)s
            a  
            The current user does not have write permissions to a required path.
              path: %(path)s
              uid: %(uid)s
              gid: %(gid)s

            If you feel that permissions on this path are set incorrectly, you can manually
            change them by executing

              $ sudo chown %(uid)s:%(gid)s %(path)s

            In general, it's not advisable to use 'sudo conda'.
            uidgid)	r   r   r   osgeteuidgetegidr8   r9   r  )r:   r   r  rS   r<   r=   s        r*   r9   zNotWritableError.__init__  s    	
 G G MM::<::< 	+F+
r>   r?   rD   s   @r*   r  r    s    % %r>   r  c                       e Zd Z fdZ xZS )NoWritableEnvsDirErrorc                F    dt        |      z  }t        |   |fd|i| y )Nz+No writeable envs directories configured.%s	envs_dirsr   r8   r9   )r:   r  rS   r<   r=   s       r*   r9   zNoWritableEnvsDirError.__init__  )    ?(9BUU@I@@r>   r?   rD   s   @r*   r  r    r  r>   r  c                       e Zd Z fdZ xZS )NoWritablePkgsDirErrorc                F    dt        |      z  }t        |   |fd|i| y )Nz+No writeable pkgs directories configured.%s	pkgs_dirsr  )r:   r  rS   r<   r=   s       r*   r9   zNoWritablePkgsDirError.__init__  r  r>   r?   rD   s   @r*   r  r    r  r>   r  c                       e Zd Z fdZ xZS )EnvironmentNotWritableErrorc                    |j                  d|i       t        rt        d      }nCt        d      }|j                  t        j                         t        j
                         d       t        |   |fi | y )Nr  z
            The current user does not have write permissions to the target environment.
              environment location: %(environment_location)s
            z
            The current user does not have write permissions to the target environment.
              environment location: %(environment_location)s
              uid: %(uid)s
              gid: %(gid)s
            r  )r   r   r   r  r  r  r8   r9   )r:   r  rS   r<   r=   s       r*   r9   z$EnvironmentNotWritableError.__init__  sx    &(<	

 G G MM::<::< 	+F+r>   r?   rD   s   @r*   r  r    s    , ,r>   r  c                       e Zd Z fdZ xZS )CondaDependencyErrorc                $    t         |   |       y r%   rI   r^   s     r*   r9   zCondaDependencyError.__init__?  r   r>   r?   rD   s   @r*   r  r  >  r   r>   r  c                       e Zd Z fdZ xZS )BinaryPrefixReplacementErrorc                L    t        d      }|||||d}t        |   |fi | y )Na  
        Refusing to replace mismatched data length in binary file.
          path: %(path)s
          placeholder: %(placeholder)s
          new prefix: %(new_prefix)s
          original data Length: %(original_data_length)d
          new data length: %(new_data_length)d
        )r   r   
new_prefixoriginal_data_lengthnew_data_lengthr]   )	r:   r   r   r  r  r  r<   rS   r=   s	           r*   r9   z%BinaryPrefixReplacementError.__init__D  s@     	
 &$$8.
 	+F+r>   r?   rD   s   @r*   r  r  C  s    , ,r>   r  c                        e Zd Zd fdZ xZS )InvalidSpecc                &    t        |   |fi | y r%   rI   rR   s      r*   r9   zInvalidSpec.__init__\  rT   r>   )r<   r/   r?   rD   s   @r*   r  r  [  s    , ,r>   r  c                        e Zd Zd fdZ xZS )InvalidVersionSpecc                .    d}t         |   |||       y )Nz/Invalid version '%(invalid_spec)s': %(details)sinvalid_specdetailsrI   r:   r  r  r<   r=   s       r*   r9   zInvalidVersionSpec.__init__a  s    C|WMr>   r  r/   r  r/   r?   rD   s   @r*   r  r  `      N Nr>   r  c                        e Zd Zd fdZ xZS )InvalidMatchSpecc                .    d}t         |   |||       y )Nz,Invalid spec '%(invalid_spec)s': %(details)sr  rI   r  s       r*   r9   zInvalidMatchSpec.__init__g  s    @|WMr>   r  r?   rD   s   @r*   r  r  f  r  r>   r  c                       e Zd Z fdZ xZS )EncodingErrorc                F    t        d      |z  }t        |   |fd|i| y )Na  
        A unicode encoding or decoding error has occurred.
        Python 2 is the interpreter under which conda is running in your base environment.
        Replacing your base environment with one having Python 3 may help resolve this issue.
        If you still have a need for Python 2 environments, consider using 'conda create'
        and 'conda activate'.  For example:

            $ conda create -n py2 python=2
            $ conda activate py2

        Error details: %r

        rL  r]   r  s       r*   r9   zEncodingError.__init__m  s8      	$ 	@I@@r>   r?   rD   s   @r*   r  r  l  s    A Ar>   r  c                       e Zd Z fdZ xZS )NoSpaceLeftErrorc                .    d}t        |   |fd|i| y )NzNo space left on devices.rL  rI   r  s       r*   r9   zNoSpaceLeftError.__init__  s    -@I@@r>   r?   rD   s   @r*   r  r    r  r>   r  c                       e Zd Z fdZ xZS )CondaEnvExceptionc                6    d|z  }t        |   |g|i | y rH   rI   )r:   r<   rv   rS   rK   r=   s        r*   r9   zCondaEnvException.__init__  s#    Wn.t.v.r>   r?   rD   s   @r*   r
  r
    s    / /r>   r
  c                       e Zd Z fdZ xZS )EnvironmentFileNotFoundc                F    d| d}|| _         t        |   |g|i | y )Nr  z' file not foundfilenamer8   r9   r:   r  rv   rS   rK   r=   s        r*   r9   z EnvironmentFileNotFound.__init__  s0    (+, .t.v.r>   r?   rD   s   @r*   r  r        / /r>   r  c                       e Zd Z fdZ xZS ) EnvironmentFileExtensionNotValidc                F    d| d}|| _         t        |   |g|i | y )Nr  z9' file extension must be one of '.txt', '.yaml' or '.yml'r  r  s        r*   r9   z)EnvironmentFileExtensionNotValid.__init__  s0    (TU .t.v.r>   r?   rD   s   @r*   r  r    r  r>   r  c                       e Zd Z fdZ xZS )EnvironmentFileEmptyc                F    || _         d| d}t        |   |g|i | y )Nr  z
' is emptyr  r  s        r*   r9   zEnvironmentFileEmpty.__init__  s/     (:&.t.v.r>   r?   rD   s   @r*   r  r    r  r>   r  c                       e Zd Z fdZ xZS )EnvironmentFileNotDownloadedc                X    | d| d}|| _         || _        t        |   |g|i | y )N/z file not downloaded)usernamepackagenamer8   r9   )r:   r  r  rv   rS   rK   r=   s         r*   r9   z%EnvironmentFileNotDownloaded.__init__  s<    
!K=(<= &.t.v.r>   r?   rD   s   @r*   r  r    s    / /r>   r  c                       e Zd Z fdZ xZS )SpecNotFoundc                ,    t        |   |g|i | y r%   rI   )r:   rK   rv   rS   r=   s       r*   r9   zSpecNotFound.__init__  s    .t.v.r>   r?   rD   s   @r*   r   r     s    / /r>   r   c                      e Zd Zy)PluginErrorNrX   r&   r>   r*   r#  r#    rY   r>   r#  c                   t        | t              rt        d | j                        }|j	                  dd      }t        d |j	                  dd            }|j	                  dd      }|j	                  dd      }|r|j
                  t        j                  k(  s-|r)|j                  t        j                  k(  r|j                  r|r| |r|j
                  t        j                  k(  s+|r7|j                  t        j                  k(  r|j                  st        |        y y y y t        | t              rb|j                  t        j                  k(  r|j                  s| |j                  t        j                  k(  r|j                  st        |        y y y t        | t              rI|j
                  t        j                  k(  r| |j
                  t        j                  k(  rt        |        y y | )Nc                "    t        | t              S r%   )r'  rz   es    r*   r]  zmaybe_raise.<locals>.<lambda>  s    :a#> r>   Tr&   c                "    t        | t              S r%   )r'  r  r&  s    r*   r]  zmaybe_raise.<locals>.<lambda>  s    :a#= r>   F)r'  r   groupbyerrorsr%  safety_checksr   enabledr|   r   r   clobberr   print_conda_exceptionrz   r  )errorr   groupsclobber_errorssafety_errorsother_errorss         r*   maybe_raiser4    s   %)>MD"-=vzz%QS?TU

4,zz%, w448L8LL))\-A-AAK 5 59J9J J%%):)::OO!%( $ ;  
E<	(  L$8$88K""l&7&77!%( AP7 
E;	'  L$8$88K""l&7&77!%( 8 r>   c                   ddl m} t        | dd       }|j                  st	        | t
              s2|j                  r&t        t        | |      t        j                         y |j                  r`t	        | t
              ry t        |rdnd      }t        j                  | j                         ddt        	      }|j                  d
|z         y t        d      }|j!                  d|        y )Nr   r^  rU   )r  zconda.stdoutzconda.stderrrP   T)indent	sort_keysclsz%s
z
%r
)rc  r   r#  debugr'  r   r   print_format_excsysstderrr"  r   dumpsdump_mapr   r/  )exc_valexc_tbr   rcloggerexc_json	stderrlogs          r*   r.  r.    s    %	-	.B}}Z<k'6*<	gz*R>^D::qDm
 	FX%&n-	'*r>   c                    | t        j                         \  }} }nt        |       }|rt        || |      }nt	        ||       }dj                  |      S )Nro   )r<  exc_infotyper	   r
   r   )r@  rA  exc_typeformatted_exceptions       r*   r;  r;    sQ    $'LLN!'6=.x&I3HgF77&''r>   c                       e Zd Z fdZ xZS )InvalidInstallerc                .    d| }t         |   |       y )NzUnable to load installer for rI   )r:   r  rK   r=   s      r*   r9   zInvalidInstaller.__init__  s    -dV4r>   r?   rD   s   @r*   rL  rL    rM   r>   rL  r%   rQ  )r  
__future__r   r"  r  r<  datetimer   loggingr   os.pathr   textwrapr   	tracebackr	   r
   typingr   requests.exceptionsr   ro   r   r   r   auxlib.entityr   
auxlib.ishr   auxlib.logzr   base.constantsr   r   r   common.compatr   	common.ior   common.iteratorsr   r)  common.signalsr   
common.urlr   r   deprecationsr   exception_handlerr   r   models.channelr    requestsr@   logr"   NoPackagesFoundNoPackagesFoundErrorrF   rO   rW   r[   r`   rc   rg   rl   rz   r   r   r   r   r   OSErrorr   r   r   r   r   r   EnvironmentErrorr   r   
SystemExitr   r   r   r   r   IOErrorr  r  rO  r
  r  r  r  r.  ImportErrorr1  r4  r7  r:  rA  rF  rS  rU  rW  rg  r  r  r  
IndexErrorr  
ValueErrorr  r  r  r  r  r  r  MemoryErrorr  r  r  r  r  r  r  r  r  r  r  r  r
  r  r  r  r  r   r#  r4  r.  r;  	ExceptionrL  r&   r>   r*   <module>ro     sW    "  	 
     =   / 8 8 (  " I I !  8 + / ) H #
"Z " *@ ?&
 ,J ,	: 	"4 "<"T """$ "
: 
%M %(': '
 
,
| 
6
 
0
 
,U3: U3p-
G --Z -5* 5Ej E	"Z 	"	E 	E%J(8 % mZ : "
 "
(:w (
" 
":w %| %*J *	: 	V V:
 :
z"* "
z;  '
 '
J 
0	Lz 	L7
Z 7
t	J 		* 	2
J 2
jQ Qh* 
Z 

j 
0j* 3j* 3

Wj* 
W

 
&
 
 "Z "
"* "
Az; A&z7 &RAZ AAZ A,* ,@": "
,: ,0,*j ,
N NN{ NAJ A.Az A/
 /// //'8 //, //: //: /
	* 	&R+.	(y r>   