
    k"g5                         d dl Z d dlmZ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
e	      Zy)    N)IterableOptionalSetTuple)BuildEnvironment)AbstractDistribution)InstallationError)PackageFinder)BaseDistribution)runner_with_spinner_messagec                       e Zd ZdZedee   fd       ZdefdZ	de
dededdfd	Zde
ddfd
Zdee   fdZdee   fdZde
ddfdZdedeeeef      ddfdZdee   ddf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`.
    returnc                 r    | j                   j                  sJ | j                   j                  j                  S )z/Identify this requirement uniquely by its link.)reqlinkurl_without_fragmentselfs    Z/var/www/html/djangosite/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   finderbuild_isolationcheck_build_depsNc                 &   | 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   r   r   r   should_isolateshould_check_depsr&   conflictingmissings	            r   prepare_distribution_metadataz0SourceDistribution.prepare_distribution_metadata   s     	$$& ,,@ ''/ HH335$$V, HH//D4D!%!<!<%111#'88#5#5#H#H"$ K %%&@+N((1!!#r   c                    | j                   j                  }|J t               | j                   _        | j                   j                  j	                  ||dd       | 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kindz"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_backendE   s     "XX88!----///&	8L 	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_wheel_   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_editablerA   s      r   _get_build_requires_editablez/SourceDistribution._get_build_requires_editableg   s    XX 	A08F hh--G&&&**62 A>>@A A	A 	AA A A	A 	A 	ArE   c                    | j                   j                  rA| j                   j                  r+| j                   j                         r| j	                         }n| j                         }| j                   j                  j                  |      \  }}|r| j                  d|       | j                   j                  j                  ||dd       y )Nr    normalzbackend dependenciesr3   )
r   editablepermit_editable_wheelssupports_pyproject_editablerH   rD   r'   r(   r)   r5   )r   r   
build_reqsr.   r/   s        r   r%   z&SourceDistribution._install_build_reqsq   s    
 HH//446::<J779J#xx11DDZPW!!"<kJ//GX,B 	0 	
r   conflicting_withconflicting_reqsc           
          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   )requirementrO   description)formatr   r9   r<   r	   )r   rO   rP   format_stringerror_messages        r   r)   z#SourceDistribution._raise_conflicts   sY    ? 	 &,,-		 ")/0@)A"  - 
  ..r   r/   c                     d}|j                  | j                  dj                  t        t        t        |                        }t        |      )NzASome build dependencies for {requirement} are missing: {missing}.rR   )rY   r/   )r[   r   r9   r:   r;   r<   r	   )r   r/   r\   r]   s       r   r*   z&SourceDistribution._raise_missing_reqs   sK    O 	 &,,$))CfWo4N*O - 
  ..r   )__name__
__module____qualname____doc__propertyr   strr   r   r   r
   boolr0   r#   r   rD   rH   r%   r   r   r)   r*   rT   r   r   r   r      s     2(3- 2 2
#+; #%$%$ %$ 	%$
 
%$N] t 4>8C= >Ahsm A
- 
D 
&/ #/7:5c?7K/	/"/3s8 / /r   r   )loggingtypingr   r   r   r   pip._internal.build_envr    pip._internal.distributions.baser   pip._internal.exceptionsr	   "pip._internal.index.package_finderr
   pip._internal.metadatar   pip._internal.utils.subprocessr   	getLoggerr_   r7   r   rT   r   r   <module>ro      sA     1 1 4 A 6 < 3 F			8	$N/- N/r   