
    H.d                         d dl Z d dlZd dlZd dlZddlmZmZ g dZ G d d          Z	 	 	 	 dde	d	e
d
e
de	de	f
dZ	 	 	 	 dde	d	e
d
e
de	de	f
dZdS )    N   )	get_indexload_channels)MambaSolvercreateinstallc                   *    e Zd ZddZd Zd ZddZdS )r   Nc                    || _         || _        || _        |pd| _        t	          j                    | _        g | _        t          | j        | j         | j        |          | _	        g | _
        i | _        |                                  d S )Nlocal)platform)channelsr   contextoutput_folder
libmambapyPoolpoolreposr   indexlocal_indexlocal_reposreplace_channels)selfr   r   r   r   s        )lib/python3.11/site-packages/mamba/api.py__init__zMambaSolver.__init__   s      *5gO%%	
"It}dj8
 
 

     c                     t          j        |          }t          j                    }|                    |           t          j        | j        |          }|                                 d S N)r   
PrefixDataget_virtual_packagesadd_packagesRepor   set_installed)r   prefixprefix_datavprepos        r   replace_installedzMambaSolver.replace_installed   s_     +F33,..  $$$ty+66r   c                 @   t          | j        f| j        d          | _        | j                                        D ]\  }}|                    d           t          | j                  t          | j	                  z   }| j        D ]\  }}|
                                st          |t                    r|d         }|d         }n%t          |          }|                    d          }|                                }|                    d          r<t#          j        |                                           |                    dd          }t)          j        | j        |||          | j        |<   | j        |                             |d           |d	z  }d S )
NF)r   prependTurl)with_credentialsz.solvz.jsonr   r   )r   r   r   r   r   itemsclearlenr   r   loaded
isinstancedictstrr*   
cache_pathendswithosremovereplacer   r!   r   set_priority)	r   _v
start_priosubdirchannel
channelstr
channelurlcps	            r   r   zMambaSolver.replace_channels$   s   $!DM5
 
 
 $**,, 	 	DAqGGDMMMM''#dj//9
#/ 	 	OFG==??  '4(( @$U^
$U^

 \\
$[[$[??
""$$B{{7## 2	&++--...ZZ11+5?	:r:, ,DZ( Z(55j!DDD!OJJ-	 	r   c                    t           j        dfg}t          j        | j        |          }|}|                    |t           j                   |                                }|s`d}|D ]}|d| dz  }|dz  }| j        D ]}	|d|	 dz  }||                                z  }t          |           t          d|z             || j        j        }t          j        |          }
t          j        ||
          S )a  Solve given a set of specs.
        Parameters
        ----------
        specs : list of str
            A list of package specs. You can use `conda.models.match_spec.MatchSpec`
            to get them to the right form by calling
            `MatchSpec(mypec).conda_build_form()`
        Returns
        -------
        transaction : libmambapy.Transaction
            The mamba transaction.
        Raises
        ------
        RuntimeError :
            If the solver did not find a solution.
        r   zMamba failed to solve:
z - 
z
with channels:
zSolver could not find solution.)r   SOLVER_FLAG_ALLOW_DOWNGRADESolverr   add_jobsSOLVER_INSTALL	try_solver   explain_problemsprintRuntimeErrorr   	pkgs_dirsMultiPackageCacheTransaction)r   specspkg_cache_pathsolver_options
api_solver_specssuccesserror_stringscpackage_caches              r   solvezMambaSolver.solveE   s#   " &A1EF&ty.AA
FJ$=>>>&&(( 		Q5L , ,a+00L] , ,a+J77999L,@<OPPP!!\3N"4^DD%j-@@@r   r   )__name__
__module____qualname__r   r'   r   rX    r   r   r   r      sa                    B(A (A (A (A (A (Ar   r   r\   env_namerN   r   target_platformbase_prefixc                 ,   |*t           j                            dt          j                  }t          j        |          }|dz  | z  }|dz                      dd           |dz                      dd           t          j	                    }t          |          |_        t          |dz            g|_        t          |||          }|                    |          }|                    t          j        t          |                              S )aY  Install packages in a given environment.

    Arguments
    ---------
    env_name : str
        The name of the environment where to install the packages.
    specs : tuple of str
        The list of spec strings e.g. ['xeus-python', 'matplotlib=3'].
    channels : tuple of str
        The channels from which to pull packages e.g. ['default', 'conda-forge'].
    base_prefix : str
        The base prefix where to create the environment, defaults to the current base prefix.

    Raises
    ------
    RuntimeError :
        If the solver did not find a solution or if the installation failed.
    NMAMBA_ROOT_PREFIXenvsz
conda-metaT)parentsexist_okpkgs)r5   environgetsysr#   pathlibPathmkdirr   Contextr2   target_prefixrK   r   rX   executer   )	r]   rN   r   r^   r_   r#   r   solvertransactions	            r   r   r   p   s    2 jnn%8#*EE,{++K6!H,Fl!!$!>>>6   === ""GKKG[61223G?G<<F,,u%%Kz4S[[AABBBr   c                 (    t          | ||||          S )ay  Create a mamba environment.

    Arguments
    ---------
    env_name : str
        The name of the environment.
    specs : tuple of str
        The list of spec strings e.g. ['xeus-python', 'matplotlib=3'].
    channels : tuple of str
        The channels from which to pull packages e.g. ['default', 'conda-forge'].
    target_platform : str
        The target platform for the environment.
    base_prefix : str
        The base prefix where to create the environment, defaults to the current base prefix.

    Raises
    ------
    RuntimeError :
        If the solver did not find a solution or if the installation failed.
    )r   )r]   rN   r   r^   r_   s        r   r   r      s    6 8UHo{KKKr   )r\   r\   NN)r5   ri   rh   r   utilsr   r   __all__r   r2   tupler   r   r\   r   r   <module>ru      sS   				  



     + + + + + + + +
.
.
.aA aA aA aA aA aA aA aAL *C *C*C*C *C 	*C
 *C *C *C *C^ L LLL L 	L
 L L L L L Lr   