a
    Ï‘`S  ã                   @   s˜   d dl mZmZmZmZ d dlZd dlZd dlZej 	d¡Z
ejZe
rJdndZeeee
r\dndƒZeeedƒZd	d
„ Zdd„ Zdd„ Zdd„ Zeƒ ZdS )é    )ÚbasenameÚdirnameÚjoinÚexistsNÚwinZScriptsÚbinz	conda.exeÚcondaz	conda.batc                  C   s   dd l } | jjS )Nr   )Zconda.configZconfigÚroot_dir)r   © r
   ú3lib/python3.9/site-packages/repo_cli/utils/conda.pyÚ_import_conda_root   s    r   c                  C   s(   t } trtt ƒrt nt} t| ƒs$d } | S )N)Ú	CONDA_EXEÚWINDOWSr   Ú	CONDA_BAT)Úcommandr
   r
   r   Ú_get_conda_exe   s    r   c               
   C   sZ   t ƒ } | sd S z*t | ddg¡ d¡}t |¡}|d W S  tttjfyT   Y d S 0 d S )NÚinfoz--jsonzutf-8Zroot_prefix)	r   Ú
subprocessZcheck_outputÚdecodeÚjsonÚloadsÚ
ValueErrorÚKeyErrorZCalledProcessError)r   ÚoutputZ
conda_infor
   r
   r   Ú_conda_root_from_conda_info   s    

r   c                  C   sF   z
t ƒ } W n6 ty@   ttƒ}t|ƒdkr6t|ƒ} ntƒ } Y n0 | S )zsGet the PREFIX of the conda installation.

    Returns:
        str: the ROOT_PREFIX of the conda installation
    Zenvs)r   ÚImportErrorr   ÚCONDA_PREFIXr   r   )Z
conda_rootZenvs_dirr
   r
   r   Úget_conda_root+   s    

r   )Zos.pathr   r   r   r   r   Úsysr   ÚplatformÚ
startswithr   Úprefixr   ZBIN_DIRr   r   r   r   r   r   Z
CONDA_ROOTr
   r
   r
   r   Ú<module>   s   
