3
ÀÞL]º  ã               @   sJ   d dl 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)ÚBuildEnvironment)ÚAbstractDistribution)ÚInstallationErrorc               @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚSourceDistributionaÅ  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`.

    NOTE from @pradyunsg (14 June 2019)
    I expect SourceDistribution class will need to be split into
    `legacy_source` (setup.py based) and `source` (PEP 517 based) when we start
    bringing logic for preparation out of InstallRequirement into this class.
    c             C   s
   | j jƒ S )N)ÚreqÚget_dist)Úself© r	   úA/tmp/pip-build-69lrc5qx/pip/pip/_internal/distributions/source.pyÚget_pkg_resources_distribution   s    z1SourceDistribution.get_pkg_resources_distributionc                s  ˆj jƒ  ˆj jo|}‡ ‡fdd„}|røtƒ ˆj _ˆj jj|ˆj jddƒ ˆj jjˆj jƒ\‰ }ˆ rn|dˆ ƒ |rœt	j
dˆj ƒ t	j
ddjttt|ƒƒƒƒ ˆj j� d	ˆj _ˆj jjƒ }W d Q R X ˆj jj|ƒ\‰ }ˆ rä|d
ˆ ƒ ˆj jj||ddƒ ˆj jƒ  ˆj jƒ  d S )Nc                s,   t dˆj| djdd„ tˆ ƒD ƒƒf ƒ‚d S )Nz4Some build dependencies for %s conflict with %s: %s.z, c             s   s   | ]\}}d ||f V  qdS )z%s is incompatible with %sNr	   )Ú.0Ú	installedZwantedr	   r	   r
   ú	<genexpr>%   s   z]SourceDistribution.prepare_distribution_metadata.<locals>._raise_conflicts.<locals>.<genexpr>)r   r   ÚjoinÚsorted)Zconflicting_withZconflicting_reqs)Úconflictingr   r	   r
   Ú_raise_conflicts!   s
    
zJSourceDistribution.prepare_distribution_metadata.<locals>._raise_conflictsZ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 z#Getting requirements to build wheelzthe backend dependenciesZnormalzInstalling backend dependencies)r   Zload_pyproject_tomlZ
use_pep517r   Z	build_envZinstall_requirementsZpyproject_requiresÚcheck_requirementsZrequirements_to_checkÚloggerÚwarningr   ÚmapÚreprr   Úspin_messageZpep517_backendZget_requires_for_build_wheelZprepare_metadataÚassert_source_matches_version)r   ÚfinderZbuild_isolationZshould_isolater   ÚmissingÚreqsr	   )r   r   r
   Úprepare_distribution_metadata   s>    





z0SourceDistribution.prepare_distribution_metadataN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   r	   r	   r
   r   
   s   
r   )ÚloggingZpip._internal.build_envr   Z pip._internal.distributions.baser   Zpip._internal.exceptionsr   Ú	getLoggerr   r   r   r	   r	   r	   r
   Ú<module>   s
   
