3
ûâde™  ã               @   s’   d Z ddlZddl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eed	œd
d„Zeeeeeedœdd„ZdS )z;Metadata generation logic for legacy source distributions.
é    N)ÚBuildEnvironment)Úopen_spinner)ÚInstallationError)Úmake_setuptools_egg_info_args)Úcall_subprocess)ÚTempDirectory)Ú	directoryÚreturnc             C   sR   dd„ t j| ƒD ƒ}|s&td| › �ƒ‚t|ƒdkr@tdj| ƒƒ‚t jj| |d ƒS )z.Find an .egg-info subdirectory in `directory`.c             S   s   g | ]}|j d ƒr|‘qS )z	.egg-info)Úendswith)Ú.0Úf© r   úM/tmp/pip-build-red6nood/pip/pip/_internal/operations/build/metadata_legacy.pyú
<listcomp>   s    z"_find_egg_info.<locals>.<listcomp>z No .egg-info directory found in é   z-More than one .egg-info directory found in {}r   )ÚosÚlistdirr   ÚlenÚformatÚpathÚjoin)r   Ú	filenamesr   r   r   Ú_find_egg_info   s    r   )Ú	build_envÚsetup_py_pathÚ
source_dirÚisolatedÚdetailsr	   c             C   sf   t jd||ƒ tddd�j}t|||d�}| �* tdƒ�}t||d|d� W d	Q R X W d	Q R X t|ƒS )
znGenerate metadata using setup.py-based defacto mechanisms.

    Returns the generated metadata directory.
    z2Running setup.py (path:%s) egg_info for package %szpip-egg-infoT)ÚkindZglobally_managed)Úegg_info_dirZno_user_configzPreparing metadata (setup.py)zpython setup.py egg_info)ÚcwdÚcommand_descÚspinnerN)ÚloggerÚdebugr   r   r   r   r   r   )r   r   r   r   r   r   Úargsr"   r   r   r   Úgenerate_metadata    s"    
r&   )Ú__doc__Úloggingr   Zpip._internal.build_envr   Zpip._internal.cli.spinnersr   Zpip._internal.exceptionsr   Z$pip._internal.utils.setuptools_buildr   Zpip._internal.utils.subprocessr   Zpip._internal.utils.temp_dirr   Ú	getLoggerÚ__name__r#   Ústrr   Úboolr&   r   r   r   r   Ú<module>   s    
