a
    &(a5                     @   s   d Z ddlZddlZddl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 dd
lmZ ddlmZ ddlmZ eeZG dd deZee ee eddddZ dd Z!dS )z6Legacy installation process, i.e. `setup.py install`.
    N)change_root)ListOptionalSequence)BuildEnvironment)InstallationError)Scheme)
indent_log)
ensure_dir)make_setuptools_install_args)runner_with_spinner_message)TempDirectoryc                   @   s   e Zd Zdd ZdS )LegacyInstallFailurec                 C   s   t  | _d S N)sysexc_infoparent)self r   /private/var/folders/m4/wm8f9dms7t78045sws6ggdl80000gn/T/pip-unpacked-wheel-vn48x2xj/pip/_internal/operations/install/legacy.py__init__   s    zLegacyInstallFailure.__init__N)__name__
__module____qualname__r   r   r   r   r   r      s   r   )record_linesrootreq_descriptionreturnc                    s    fdd}| D ]&}t j|}|dr||} qJqd|}t|g }| D ]<}| }	t j|	rv|	t jj7 }	|	t j
||	| qR|  t| t j|d}
t|
d$}|d|d  W d    n1 s0    Y  d S )Nc                    s&    d u st j| s| S t | S d S r   )ospathisabsr   )r   r   r   r   prepend_root!   s    zBwrite_installed_files_from_setuptools_record.<locals>.prepend_rootz	.egg-infoz{} did not indicate that it installed an .egg-info directory. Only setup.py projects generating .egg-info directories are supported.zinstalled-files.txtw
)r   r   dirnameendswithformatr   stripisdirsepappendrelpathsortr
   joinopenwrite)r   r   r   r"   line	directoryegg_info_dirmessage	new_linesfilenameinst_files_pathfr   r!   r   ,write_installed_files_from_setuptools_record   s0    
r9   c                 C   sR  |j }tdd}ztj|jd}t||| |||||||	|d}td|
 }t @ | |||d W d    n1 s0    Y  W d    n1 s0    Y  tj|st	
d| W W d    dS W n ty   tY n0 t|}|  }W d    n1 s0    Y  W d    n1 s80    Y  t||| d	S )
Nrecord)kindzinstall-record.txt)
global_optionsinstall_optionsrecord_filenamer   prefix
header_dirhomeuse_user_siteno_user_config	pycompilezRunning setup.py install for )cmdcwdzRecord file %s not foundFT)headersr   r   r   r.   r   r   r	   existsloggerdebug	Exceptionr   r/   read
splitlinesr9   )r=   r<   r   rA   r?   rB   rD   schemesetup_py_pathisolatedreq_name	build_envunpacked_source_directoryr   r@   temp_dirr>   install_argsrunnerr8   r   r   r   r   installD   sD    B

LrW   )"__doc__loggingr   r   distutils.utilr   typingr   r   r   pip._internal.build_envr   pip._internal.exceptionsr   pip._internal.models.schemer   pip._internal.utils.loggingr	   pip._internal.utils.miscr
   $pip._internal.utils.setuptools_buildr   pip._internal.utils.subprocessr   pip._internal.utils.temp_dirr   	getLoggerr   rI   rK   r   strr9   rW   r   r   r   r   <module>   s*   
(