3
ûâdeÞ  ã               @   s‚   d dl 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 e jeƒZG d	d
„ d
eƒZdS )é    N)ÚIterableÚSetÚTuple)ÚBuildEnvironment)ÚAbstractDistribution)ÚInstallationError)ÚPackageFinder)ÚBaseDistribution)Úrunner_with_spinner_messagec               @   s’   e Zd ZdZedœdd„Zeeddœdd„Zedd	œd
d„Z	e
e dœdd„Ze
e dœdd„Zedd	œdd„Zeeeeef  ddœdd„ZdS )ÚSourceDistributionz½Represents a source distribution.

    The preparation step for these needs metadata for the packages to be
    generated, either using PEP 517 or using the legacy `setup.py egg_info`.
    )Úreturnc             C   s   ddl m} || jjƒ ƒS )Nr   )ÚDistribution)Z$pip._internal.metadata.pkg_resourcesr   ÚreqÚget_dist)ÚselfZ_Dist© r   ú@/tmp/pip-build-red6nood/pip/pip/_internal/distributions/sdist.pyÚget_metadata_distribution   s    z,SourceDistribution.get_metadata_distributionN)ÚfinderÚbuild_isolationr   c             C   sF   | j jƒ  | j jo|}|r8| j|ƒ | j jƒ  | j|ƒ | j jƒ  d S )N)r   Zload_pyproject_tomlZ
use_pep517Ú_prepare_build_backendZisolated_editable_sanity_checkÚ_install_build_reqsZprepare_metadata)r   r   r   Zshould_isolater   r   r   Úprepare_distribution_metadata   s    



z0SourceDistribution.prepare_distribution_metadata)r   r   c             C   sŠ   | j j}|d k	st‚tƒ | j _| j jj||ddƒ | j jj| j jƒ\}}|rX| jd|ƒ |r†t	j
d| j ƒ t	j
ddjttt|ƒƒƒƒ d S )NZoverlayzInstalling build dependenciesz"PEP 517/518 supported requirementsz4Missing build requirements in pyproject.toml for %s.z`The project does not specify a build backend, and pip cannot fall back to setuptools without %s.z and )r   Úpyproject_requiresÚAssertionErrorr   Ú	build_envÚinstall_requirementsÚcheck_requirementsZrequirements_to_checkÚ_raise_conflictsÚloggerÚwarningÚjoinÚmapÚreprÚsorted)r   r   r   ÚconflictingÚmissingr   r   r   r   3   s     
z)SourceDistribution._prepare_build_backendc             C   sN   | j j�< tdƒ}| j j}|d k	s&t‚|j|ƒ�
 |jƒ S Q R X W d Q R X d S )Nz#Getting requirements to build wheel)r   r   r
   Úpep517_backendr   Úsubprocess_runnerZget_requires_for_build_wheel)r   ÚrunnerÚbackendr   r   r   Ú_get_build_requires_wheelM   s    
z,SourceDistribution._get_build_requires_wheelc             C   sN   | j j�< tdƒ}| j j}|d k	s&t‚|j|ƒ�
 |jƒ S Q R X W d Q R X d S )Nz&Getting requirements to build editable)r   r   r
   r'   r   r(   Zget_requires_for_build_editable)r   r)   r*   r   r   r   Ú_get_build_requires_editableU   s    
z/SourceDistribution._get_build_requires_editablec             C   sf   | j jr$| j jr$| j jƒ r$| jƒ }n| jƒ }| j jj|ƒ\}}|rN| jd|ƒ | j jj	||ddƒ d S )Nzthe backend dependenciesZnormalzInstalling backend dependencies)
r   ÚeditableZpermit_editable_wheelsZsupports_pyproject_editabler,   r+   r   r   r   r   )r   r   Z
build_reqsr%   r&   r   r   r   r   _   s    

z&SourceDistribution._install_build_reqs)Úconflicting_withÚconflicting_reqsr   c             C   s6   d}|j | j|djdd„ t|ƒD ƒƒd�}t|ƒ‚d S )NzZSome build dependencies for {requirement} conflict with {conflicting_with}: {description}.z, c             s   s    | ]\}}|› d |› �V  qdS )z is incompatible with Nr   )Ú.0Ú	installedZwantedr   r   r   ú	<genexpr>}   s   z6SourceDistribution._raise_conflicts.<locals>.<genexpr>)Úrequirementr.   Údescription)Úformatr   r!   r$   r   )r   r.   r/   Úformat_stringÚerror_messager   r   r   r   r   s    z#SourceDistribution._raise_conflicts)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   Úboolr   r   r   Ústrr+   r,   r   r   r   r   r   r   r   r   r      s   
r   )ÚloggingÚtypingr   r   r   Zpip._internal.build_envr   Z pip._internal.distributions.baser   Zpip._internal.exceptionsr   Z"pip._internal.index.package_finderr   Zpip._internal.metadatar	   Zpip._internal.utils.subprocessr
   Ú	getLoggerr8   r   r   r   r   r   r   Ú<module>   s   
