
    dh(                        d dl m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 d d	lmZ erd d
lmZ  ej$                  e      Z G d de
      Zy)    )annotationsN)Iterable)TYPE_CHECKING)BuildEnvironment)AbstractDistribution)InstallationError)BaseDistribution)runner_with_spinner_message)BuildEnvironmentInstallerc                      e Zd ZdZedd       ZddZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZddZ	ddZ
	 	 	 	 ddZ	 	 	 	 	 	 dd	Zdd
Zy)SourceDistributionzRepresents 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`.
    c                r    | j                   j                  sJ | j                   j                  j                  S )z/Identify this requirement uniquely by its link.)reqlinkurl_without_fragmentselfs    c/var/www/html/vivango/api/ia/venv/lib/python3.12/site-packages/pip/_internal/distributions/sdist.pybuild_tracker_idz#SourceDistribution.build_tracker_id   s(     xx}}}xx}}111    c                6    | j                   j                         S )N)r   get_distr   s    r   get_metadata_distributionz,SourceDistribution.get_metadata_distribution    s    xx  ""r   c                &   | j                   j                          | j                   j                  xr |}|r<| j                  |       | j                   j	                          | j                  |       | j                   j                  xr |}|ri| j                   j                  }|J | j                   j                  j                  |      \  }}|r| j                  d|       |r| j                  |       | j                   j                          y )Nthe backend dependencies)r   load_pyproject_toml
use_pep517_prepare_build_backendisolated_editable_sanity_check_install_build_reqspyproject_requires	build_envcheck_requirements_raise_conflicts_raise_missing_reqsprepare_metadata)	r   build_env_installerbuild_isolationcheck_build_depsshould_isolateshould_check_depsr!   conflictingmissings	            r   prepare_distribution_metadataz0SourceDistribution.prepare_distribution_metadata#   s     	$$& ,,@ ''(;< HH335$$%89 HH//D4D!%!<!<%111#'88#5#5#H#H"$ K %%&@+N((1!!#r   c                0   | j                   j                  }|J t        |      | j                   _        | j                   j                  j	                  |dd| j                          | j                   j                  j                  | j                   j                        \  }}|r| j                  d|       |r]t        j                  d| j                          t        j                  ddj                  t        t        t        |                         y y )Noverlayzbuild dependencieskindfor_reqz"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   r!   r   r"   install_requirementsr#   requirements_to_checkr$   loggerwarningjoinmapreprsorted)r   r'   r!   r,   r-   s        r   r   z)SourceDistribution._prepare_build_backendJ   s    
 "XX88!----.AB//	0Ddhh 	0 	
  $xx11DDHH** 
W !!"FTNNF NNASvg78 r   c                &   | j                   j                  5  t        d      }| j                   j                  }|J |j	                  |      5  |j                         cd d d        cd d d        S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nz#Getting requirements to build wheel)r   r"   r
   pep517_backendsubprocess_runnerget_requires_for_build_wheelr   runnerbackends      r   _get_build_requires_wheelz,SourceDistribution._get_build_requires_wheelf   s    XX 	>01VWFhh--G&&&**62 >;;=> >		> 	>> > >		> 	> 	>#   7BA1	B1A:	6BBc                &   | j                   j                  5  t        d      }| j                   j                  }|J |j	                  |      5  |j                         cd d d        cd d d        S # 1 sw Y   nxY w	 d d d        y # 1 sw Y   y xY w)Nz&Getting requirements to build editable)r   r"   r
   r=   r>   get_requires_for_build_editabler@   s      r   _get_build_requires_editablez/SourceDistribution._get_build_requires_editablen   s    XX 	A08F hh--G&&&**62 A>>@A A	A 	AA A A	A 	A 	ArD   c                   | j                   j                  r=| j                   j                  r'| j                   j                  r| j	                         }n| j                         }| j                   j                  j                  |      \  }}|r| j                  d|       | j                   j                  j                  |dd| j                          y )Nr   normalzbackend dependenciesr1   )
r   editablepermit_editable_wheelssupports_pyproject_editablerG   rC   r"   r#   r$   r4   )r   r'   
build_reqsr,   r-   s        r   r    z&SourceDistribution._install_build_reqsx   s     HH//44::<J779J#xx11DDZPW!!"<kJ//X$:DHH 	0 	
r   c           
         d}|j                  | j                  |dj                  d t        |      D                    }t	        |      )NzZSome build dependencies for {requirement} conflict with {conflicting_with}: {description}., c              3  0   K   | ]  \  }}| d |   yw)z is incompatible with N ).0	installedwanteds      r   	<genexpr>z6SourceDistribution._raise_conflicts.<locals>.<genexpr>   s(      "%Iv +3F8<"s   )requirementconflicting_withdescription)formatr   r8   r;   r   )r   rW   conflicting_reqsformat_stringerror_messages        r   r$   z#SourceDistribution._raise_conflicts   sY    ? 	 &,,-		 ")/0@)A"  - 
  ..r   c                    d}|j                  | j                  dj                  t        t        t        |                        }t        |      )NzASome build dependencies for {requirement} are missing: {missing}.rO   )rV   r-   )rY   r   r8   r9   r:   r;   r   )r   r-   r[   r\   s       r   r%   z&SourceDistribution._raise_missing_reqs   sK    O 	 &,,$))CfWo4N*O - 
  ..r   N)returnz
str | None)r^   r	   )r'   r   r(   boolr)   r_   r^   None)r'   r   r^   r`   )r^   zIterable[str])rW   strrZ   zset[tuple[str, str]]r^   r`   )r-   zset[str]r^   r`   )__name__
__module____qualname____doc__propertyr   r   r.   r   rC   rG   r    r$   r%   rQ   r   r   r   r      s     2 2
#%$6%$ %$ 	%$
 
%$N#<	8>A
#<
	
*/ #/7K/	/"/r   r   )
__future__r   loggingcollections.abcr   typingr   pip._internal.build_envr    pip._internal.distributions.baser   pip._internal.exceptionsr   pip._internal.metadatar	   pip._internal.utils.subprocessr
   r   	getLoggerrb   r6   r   rQ   r   r   <module>rq      sG    "  $   4 A 6 3 FA			8	$R/- R/r   