a
    a                     @   sX   d Z ddlZddlmZ ddlmZmZ ddlm	Z	m
Z
 i add Zdd Zd	d
 ZdS )z
Pyenv utilities
    N)get_home_dirrunning_in_mac_app)find_programrun_shell_commandc                 C   sX   t  }tjdkr&t|ddd| d}n.| dkr@t|ddd}nt|dd| d	d}|S )
z&Return the complete path of the pyenv.ntz.pyenvz	pyenv-winversionsz
python.exe ZshimsZpythonbin)r   osnameospjoin)r   homepath r   1lib/python3.9/site-packages/spyder/utils/pyenv.pyget_pyenv_path   s    
r   c            
      C   s   i } t d}|du r| S d|dddg}z$t|i d \}}|  }W n tyd   |  Y S 0 |rt|dng }|D ]D}|tj	}t
|d	 }d
|d	  }d|d  }	||	f| |< q|| a| S )z6Return the list of all pyenv envs found in the system.pyenvN r   z--barez--skip-aliases)env
zpyenv: zPython r   )r   r   r   Zcommunicatedecodestrip	Exceptionsplitr   sepr   PYENV_ENV_LIST_CACHE)
Zenv_listr   Zcmdstrout__r   datar   r   versionr   r   r   get_list_pyenv_envs"   s&    
r"   c                   C   s   t S )z5Return a cache of envs to avoid computing them again.)r   r   r   r   r   get_list_pyenv_envs_cache?   s    r#   )__doc__r
   os.pathr   r   Zspyder.config.baser   r   Zspyder.utils.programsr   r   r   r   r"   r#   r   r   r   r   <module>   s   