U
    E¸Öh  ã                   @   s†   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 e
r`d dlmZmZmZ e  e¡Zdd„ Zd	d
„ Zdd„ ZdS )é    N)Ú make_setuptools_bdist_wheel_args)ÚLOG_DIVIDERÚcall_subprocessÚformat_command_args)ÚMYPY_CHECK_RUNNING)Úopen_spinner)ÚListÚOptionalÚTextc                 C   s^   t | ƒ}d |¡}|s |d7 }n:t ¡ tjkr8|d7 }n"| d¡sJ|d7 }|d |t¡7 }|S )z'Format command information for logging.zCommand arguments: {}
zCommand output: Nonez'Command output: [use --verbose to show]Ú
zCommand output:
{}{})r   ÚformatÚloggerZgetEffectiveLevelÚloggingÚDEBUGÚendswithr   )Úcommand_argsÚcommand_outputZcommand_descÚtext© r   úQ./venv/lib/python3.8/site-packages/pip/_internal/operations/build/wheel_legacy.pyÚformat_command_result   s    



r   c                 C   st   t | ƒ} | s2d |¡}|t||ƒ7 }t |¡ dS t| ƒdkrbd || ¡}|t||ƒ7 }t |¡ tj || d ¡S )z>Return the path to the wheel in the temporary build directory.z1Legacy build of wheel for {!r} created no files.
Né   zZLegacy build of wheel for {!r} created more than one file.
Filenames (choosing first): {}
r   )	Úsortedr   r   r   ZwarningÚlenÚosÚpathÚjoin)ÚnamesÚtemp_dirÚnamer   r   Úmsgr   r   r   Úget_legacy_build_wheel_path*   s$    
ÿþ
ÿ ý
r!   c              
   C   s°   t ||||d}d| f }t|ƒ„}t d|¡ zt|||d}	W n6 tk
rx   | d¡ t d| ¡ Y W 5 Q R £ dS X t 	|¡}
t
|
|| ||	d}|W  5 Q R £ S Q R X dS )	zŒBuild one unpacked package using the "legacy" build process.

    Returns path to wheel if successfully built. Otherwise, returns None.
    )Úglobal_optionsÚbuild_optionsZdestination_dirz Building wheel for %s (setup.py)zDestination directory: %s)ÚcwdÚspinnerÚerrorzFailed building wheel for %sN)r   r   r   r   r   )r   r   r   Údebugr   Ú	ExceptionZfinishr&   r   Úlistdirr!   )r   Zsetup_py_pathZ
source_dirr"   r#   ZtempdZ
wheel_argsZspin_messager%   Úoutputr   Z
wheel_pathr   r   r   Úbuild_wheel_legacyH   s8    ü

ý


ûr+   )r   Zos.pathr   Z$pip._internal.utils.setuptools_buildr   Zpip._internal.utils.subprocessr   r   r   Zpip._internal.utils.typingr   Zpip._internal.utils.uir   Útypingr   r	   r
   Z	getLoggerÚ__name__r   r   r!   r+   r   r   r   r   Ú<module>   s   
