Your IP : 3.135.201.101
U
e5dFR �
@ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZe �e�Z G dd� d�Z
d
dd�Zddd�Zed kr�d
Z
ze� d Z
W n4 ek
r� Z zede ejd� W 5 dZ[X Y nX e�e
� dS )� Nc @ s� e Zd Zddd�Zdd� Zdd� Zd d
� Zdd� Zej d
krHddd�Z
n
ddd�Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� ZdS ) �
EnvBuilderFNc C s( || _ || _|| _|| _|| _|| _d S �N��system_site_packages�clear�symlinks�upgrade�with_pip�prompt)�selfr r r r r r
� r �%/usr/lib64/python3.8/venv/__init__.py�__init__+ s zEnvBuilder.__init__c C sx t j�|�}| �|�}| j}d| _| �|� | �|� | jrF| �|� | j s`| �
|� | �|� |rtd| _| �|� d S )NFT)�os�path�abspath�ensure_directoriesr �create_configuration�setup_pythonr �
_setup_pipr �
setup_scripts�
post_setup)r �env_dir�contextZtrue_system_site_packagesr r r
�create4 s
zEnvBuilder.createc C s\ t �|�D ]L}t j�||�}t j�|�s4t j�|�r@t �|� q
t j�|�r
t� |� q
d S r )
r �listdirr �join�islink�isfile�remove�isdir�shutilZrmtree)r r �fnr r r
�clear_directoryN s zEnvBuilder.clear_directoryc C s� dd� }t j�|�r$| jr$| �|� t�� }||_t j�|�d |_ | j
d k rT| j
n|j }d| |_
||� tj}t j�t j�
|��\}}||_||_||_tjdkr�d}d} t j�|dd �}
n(d
}d} t j�|dd
tjd d� d �}
t j�|| � |_}||� ||
� tjdk�rXt jdk�rXtjdk�rXt j�|d�}t j�|��sXt �d|� t j�||� |_}
||_t j�|
|�|_||
� |S )Nc S s@ t j�| �st �| � n$t j�| �s0t j�| �r<td| ��d S )NzUnable to create directory %r)r r �exists�makedirsr r �
ValueError)�dr r r
�create_if_needed^ s z7EnvBuilder.ensure_directories.<locals>.create_if_needed� z(%s) Zwin32ZScriptsZInclude�Libz
site-packages�binZinclude�libzpython%d.%d� l �posix�darwin�lib64)r r r$ r r# �types�SimpleNamespacer �split�env_namer
�sys�_base_executabler �
executable�
python_dirZ
python_exe�platformr �version_infoZinc_path�maxsize�name�symlink�bin_path�bin_name�env_exe)r r r( r r
r7 �dirnameZexenameZbinnameZincpathZlibpathr Z link_path�binpathr r r
r V sL
��zEnvBuilder.ensure_directoriesc C s� t j�|jd� |_}t|ddd��j}|�d|j � | jrBd}nd}|�d| � |�d t j
d d
� � | jd k r�|�d| j�d�� W 5 Q R X d S )
Nz
pyvenv.cfg�w�utf-8)�encodingz
home = %s
�trueZfalsez"include-system-site-packages = %s
zversion = %d.%d.%d
� z prompt = �
)r r r r Zcfg_path�open�writer8 r r5 r: r
)r r r �fZinclr r r
r � s
zEnvBuilder.create_configuration�ntc C s~ | j }|sjz6tj�|�s@|r4t�tj�|�|� nt�||� W n& tk
rh t�d||� d}Y nX |rzt �
||� d S )N�Unable to symlink %r to %rT)r r r r r= �basename� Exception�logger�warningr! �copyfile)r �src�dst�relative_symlinks_okZ
force_copyr r r
�symlink_or_copy� s
zEnvBuilder.symlink_or_copyc C s\ t j�|�ot j�|� }| jr�|s�t j�|�s�z,|rLt �t j�|�|� nt �||� W d S tk
r~ t �
d||� Y nX t j�t j�|��\}}t j�t j�
t�dd|| �}t�d�s�t j�|��s$|�d�r�d| }|d d� }|dkr�d}n|d k�rd
}t j�t j�
|�|| �}n|}t j�|��sL|�sHt �
d|� d S t�||� d S )NrM �scriptsrL TZ_d����pythonZvenvlauncherZpythonwZ
venvwlauncherzUnable to copy %r)r r �lexistsr$ r r r= rN rO rP rQ �splitextr rA �__file__� sysconfig�is_python_buildr �endswithr! rR )r rS rT rU Zbad_srcrN ZextZsrcfnr r r
rV � s<