U
    cc	                     @   s   d Z ddlZddlZddlmZmZmZ ddlmZ ddl	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 e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)ListOptionalSequence)BuildEnvironment)InstallationErrorLegacyInstallFailure)change_root)Scheme)
ensure_dir)make_setuptools_install_args)runner_with_spinner_message)TempDirectory)record_linesrootreq_descriptionreturnc              	      s   t t d fdd}| D ]&}tj|}|dr||} qRqd|}t|g }| D ]<}| }	tj|	r~|	tjj	7 }	|
tj||	| qZ|  t| tj|d}
t|
d}|d|d  W 5 Q R X d S )	N)pathr   c                    s&    d kst j| s| S t | S d S )N)osr   isabsr   )r   r    a/var/www/html/project/venv/lib/python3.8/site-packages/pip/_internal/operations/install/legacy.py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filenameZinst_files_pathfr   r   r   ,write_installed_files_from_setuptools_record   s,    
r/   )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}ztj|jd}t||| |||||||	|d}td|
 }| |||d W 5 Q R X tj|st	d| W W 5 Q R  dS W n. t
k
r } zt|
d	|W 5 d }~X Y nX t|}|  }W 5 Q R X W 5 Q R X t||| d
S )Nrecord)kindzinstall-record.txt)
r1   r0   record_filenamer   r3   
header_dirr2   r4   no_user_configr5   zRunning setup.py install for )cmdcwdzRecord file %s not foundF)package_detailsT)headersr   r   r   r%   r   r   existsloggerdebug	Exceptionr   r&   read
splitlinesr/   )r0   r1   r   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r   r?   temp_dirr>   Zinstall_argsrunnerer.   r   r   r   r   install9   sD    
 rN   )__doc__loggingr   typingr   r   r   pip._internal.build_envr   pip._internal.exceptionsr   r   Zpip._internal.locations.baser   pip._internal.models.schemer	   pip._internal.utils.miscr
   $pip._internal.utils.setuptools_buildr   pip._internal.utils.subprocessr   pip._internal.utils.temp_dirr   	getLogger__name__rF   r   r/   boolrN   r   r   r   r   <module>   sB   
&