U
    @vg                     @   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loggergetEffectiveLevelloggingDEBUGendswithr   )command_argscommand_outputcommand_desctext r   O/tmp/pip-unpacked-wheel-gw11q0wt/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   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 )	zBuild one unpacked package using the "legacy" build process.

    Returns path to wheel if successfully built. Otherwise, returns None.
    )global_optionsbuild_options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   	Exceptionfinishr*   r   listdirr$   )r"   setup_py_path
source_dirr%   r&   tempd
wheel_argsspin_messager)   outputr    
wheel_pathr   r   r   build_wheel_legacyH   s8    




r6   )r   os.pathr   $pip._internal.utils.setuptools_buildr   pip._internal.utils.subprocessr   r   r   pip._internal.utils.typingr   pip._internal.utils.uir   typingr   r	   r
   	getLogger__name__r   r   r$   r6   r   r   r   r   <module>   s   
