3
ûâde>  ã               @   s  d 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jeƒZG dd„ deƒZee ee eddœdd„Zee ee ee ee ee e e eee ee
eee dœ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S )ÚLegacyInstallFailureN)Ú__name__Ú
__module__Ú__qualname__© r   r   úF/tmp/pip-build-red6nood/pip/pip/_internal/operations/install/legacy.pyr      s   r   )Úrecord_linesÚrootÚreq_descriptionÚreturnc          
      sê   t t dœ‡ fdd„}x>| D ]$}tjj|ƒ}|jdƒr||ƒ}P qW dj|ƒ}t|ƒ‚g }xD| D ]<}|jƒ }	tjj|	ƒr‚|	tjj	7 }	|j
tjj||	ƒ|ƒƒ q^W |jƒ  t|ƒ tjj|dƒ}
t|
dƒ�}|jdj|ƒd ƒ W d Q R X d S )	N)Úpathr   c                s(   ˆ d kst jj| ƒ r| S tˆ | ƒS d S )N)Úosr   Ú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Ú
)Ústrr   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   s(    


r3   )Úinstall_optionsÚglobal_optionsr   ÚhomeÚprefixÚuse_user_siteÚ	pycompileÚschemeÚsetup_py_pathÚisolatedÚreq_nameÚ	build_envÚunpacked_source_directoryr   r   c          &   C   s   |j }tdd��Ú}yŠtjj|jdƒ}t||| |||||||	|d�}td|
› �ƒ}tƒ �" |� |||d� W d Q R X W d Q R X tjj|ƒsšt	j
d|ƒ dS W n( tk
rÄ } zt|‚W Y d d }~X nX t|ƒ�}|jƒ jƒ }W d Q R X W d Q R X t|||ƒ d	S )
NÚrecord)Úkindzinstall-record.txt)
r5   r4   Úrecord_filenamer   r7   Ú
header_dirr6   r8   Zno_user_configr9   z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Ú
splitlinesr3   )r4   r5   r   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r   rC   Útemp_dirrB   Úinstall_argsZrunnerÚer2   r   r   r   r   Úinstall>   s>    
 rP   )"Ú__doc__Úloggingr   Údistutils.utilr   Útypingr   r   r   Zpip._internal.build_envr   Zpip._internal.exceptionsr   Zpip._internal.models.schemer   Zpip._internal.utils.loggingr	   Zpip._internal.utils.miscr
   Z$pip._internal.utils.setuptools_buildr   Zpip._internal.utils.subprocessr   Zpip._internal.utils.temp_dirr   Ú	getLoggerr   rH   rJ   r   r   r3   ÚboolrP   r   r   r   r   Ú<module>   sB   
"