
    xiy7                       d Z ddlmZ ddlZddlZddlZddlZddl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mZmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZ ddl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*m+Z+ erddl,m-Z- ddl.m/Z/  G d ded      Z0 ejb                  e2      Z3d%dZ4 G d d      Z5d&dZ6d'dZ7 G d de      Z8 G d d       Z9 G d! d"      Z: G d# d$e:      Z;y)(z:Build Environment used for isolation during sdist building    )annotationsN)OrderedDict)Iterable)TracebackType)TYPE_CHECKINGProtocol	TypedDict)Version)__file__)open_spinner)get_platlibget_purelib
get_scheme)get_default_environmentget_environment)
deprecated)VERBOSE)get_requirement)call_subprocess)TempDirectorytempdir_kinds)PackageFinder)InstallRequirementc                      e Zd ZU ded<   y)ExtraEnvironzdict[str, str]extra_environN)__name__
__module____qualname____annotations__     R/var/www/html/binance/venv/lib/python3.12/site-packages/pip/_internal/build_env.pyr   r       s    %%r"   r   F)totalc                    | |k7  r| |fS | fS Nr!   )abs     r#   _dedupr)   '   s    !VAq6%!%r"   c                      e Zd ZddZy)_Prefixc                    || _         d| _        t        d|      }|j                  | _        t        |j                  |j                        | _        y )NF )prefix)	pathsetupr   scriptsbin_dirr)   purelibplatliblib_dirs)selfr/   schemes      r#   __init__z_Prefix.__init__,   s=    	
Bt,~~v~~v~~>r"   N)r/   strreturnNone)r   r   r   r8   r!   r"   r#   r+   r+   +   s    ?r"   r+   c                     t        j                  t              j                         j                  } | j                         st        |       S t        j                  | dz        S )zGet a file to pass to a Python executable, to run the currently-running pip.

    This is used to run a pip subprocess, for installing requirements into the build
    environment.
    z__pip-runner__.py)	pathlibPathpip_locationresolveparentis_dirr9   osfsdecode)sources    r#   get_runnable_piprF   4   sK     \\,'//188F==? 6{;;v 3344r"   c                     t        t        d      rt        j                         } nt               t	               g} | D ch c]!  }t
        j                  j                  |      # c}S c c}w )zGet system site packages

    Usually from site.getsitepackages,
    but fallback on `get_purelib()/get_platlib()` if unavailable
    (e.g. in a virtualenv created by virtualenv<20)

    Returns normalized set of strings.
    getsitepackages)hasattrsiterH   r   r   rC   r/   normcase)system_sitesr/   s     r#   _get_system_sitepackagesrM   D   sP     t&'++- ${}5/;<tBGGT"<<<s   &A'c                  ,    e Zd ZdZ	 	 	 	 	 	 	 	 	 	 ddZy)BuildEnvironmentInstallerz]
    Interface for installing build dependencies into an isolated build
    environment.
    c                    y r&   r!   )r6   requirementsr.   kindfor_reqs        r#   installz!BuildEnvironmentInstaller.install^   s     r"   N
rQ   Iterable[str]r.   r+   rR   r9   rS   InstallRequirement | Noner:   r;   )r   r   r   __doc__rT   r!   r"   r#   rO   rO   X   s<    
# 
  + 
r"   rO   c                  P    e Zd ZdZ	 	 d	 	 	 	 	 	 	 ddZddZ	 	 	 	 	 	 	 	 	 	 d	dZy)
#SubprocessBuildEnvironmentInstallerzD
    Install build dependencies by calling pip in a subprocess.
    Nc                6    || _         |xs g | _        || _        y r&   )finder_build_constraints!_build_constraint_feature_enabled)r6   r\   build_constraints build_constraint_feature_enableds       r#   r8   z,SubprocessBuildEnvironmentInstaller.__init__m   s      "3"9r1Q.r"   c                    | j                   s| j                  ryt        j                  j	                  d      }|r|j                         syt        dddd       y)z
        Check for deprecation warning: PIP_CONSTRAINT affecting build environments.

        This warns when build-constraint feature is NOT enabled and PIP_CONSTRAINT
        is not empty.
        NPIP_CONSTRAINTzGSetting PIP_CONSTRAINT will not affect build constraints in the future,zto specify build constraints using --build-constraint or PIP_BUILD_CONSTRAINT. To disable this warning without any build constraints set --use-feature=build-constraint or PIP_USE_FEATURE="build-constraint"z26.2)reasonreplacementgone_inissue)r^   r]   rC   environgetstripr   )r6   pip_constraints     r#   _deprecation_constraint_checkzASubprocessBuildEnvironmentInstaller._deprecation_constraint_checkw   sV     11T5L5L(89^%9%9%;35
 	
r"   c                  | j                          | j                  }t        j                  t	               dddd|j
                  ddddd	g}t        j                         t        j                  k  r|j                  d
       n,t        j                         t        k  r|j                  d       dD ][  }t        |j                  |      }|j                  d|j                  dd      z   dj!                  t#        |xs dh            f       ] |j$                  }	|	r4|j                  d|	d   g       |	dd  D ]  }
|j                  d|
g        n|j                  d       |j&                  D ]  }|j                  d|g        |j(                  r|j                  d|j(                  g       |j*                  D ]  }|j                  d|g        |j,                  r|j                  d|j,                  g       |j.                  r|j                  d|j.                  g       |j0                  r|j                  d       |j2                  r|j                  d       | j4                  r|j                  ddg       | j6                  r7| j6                  D ](  }|j                  d |g       |j                  d!|g       * i }| j4                  r| j6                  sd"d#d$ii}|j                  d       |j                  |       |r|j8                  rd%|j8                   nd	}t;        d&|       5 }t=        |fd'| | |d(| d d d        y # 1 sw Y   y xY w))NrT   z--ignore-installedz	--no-userz--prefixz--no-warn-script-locationz--disable-pip-version-checkz--no-compilez--targetr-   z-vvz-v)	no_binaryonly_binaryz--_-,z:none:z-ir      z--extra-index-urlz
--no-indexz--find-linksz--proxyz--trusted-hostz--certz--client-certz--prez--prefer-binaryz--use-featurezbuild-constraintz--constraintz--build-constraintr    _PIP_IN_BUILD_IGNORE_CONSTRAINTS1z for zInstalling zinstalling )command_descspinner)rk   r\   sys
executablerF   r/   loggergetEffectiveLevelloggingDEBUGappendr   getattrformat_controlextendreplacejoinsorted
index_urls
find_linksproxytrusted_hostscustom_certclient_certallow_all_prereleasesprefer_binaryr^   r]   namer   r   )r6   rQ   r.   rR   rS   r\   argsr   formatsr   extra_indexlinkhostconstraint_filer   identify_requirementrv   s                    r#   rT   z+SubprocessBuildEnvironmentInstaller.install   s=    	**,NN KK')  #
& ##%6KK%%'72KK: 	Nf33^DGKK>11#s;;HHVG$9z:;	 &&
KKz!}-.)!"~ @0+>?@ KK%%% 	0DKK./	0 <<KKFLL12(( 	2DKK)401	2KK6#5#567KK&*<*<=>''KK KK)* 11KK*<=>"" $(#:#: E^_=>1?CDE ')11$:Q:Q -/QSV.WXMDL! '.',,eGLL>"B 	 Kv./ 	7*4&1E0FG  		 	 	s   /MM)NF)r\   r   r_   zlist[str] | Noner`   boolr:   r;   r:   r;   rU   )r   r   r   rX   r8   rk   rT   r!   r"   r#   rZ   rZ   h   s     /316	RR ,R +/	R
 
R
:a#a a
 a +a 
ar"   rZ   c                  h    e Zd ZdZd	dZd
dZ	 	 	 	 	 	 	 	 ddZ	 	 	 	 ddZdd	 	 	 	 	 	 	 	 	 ddZy)BuildEnvironmentzACreates and manages an isolated environment to install build depsc                   || _         t        t        j                  d      t	        fddD              | _        g | _        g | _        t        t        | j
                  j                                     D ]L  }| j                  j                  |j                         | j                  j                  |j                         N t               }t         j"                  j%                  j"                  d      | _        t         j"                  j)                  | j&                        st!        j*                  | j&                         t-        t         j"                  j%                  | j&                  d      dd	      5 }|j/                  t1        j2                  d
      j5                  || j                               d d d        y # 1 sw Y   y xY w)NT)rR   globally_managedc              3     K   | ]9  }|t        t        j                  j                  j                  |            f ; y wr&   )r+   rC   r/   r   ).0r   temp_dirs     r#   	<genexpr>z,BuildEnvironment.__init__.<locals>.<genexpr>   s6      %
 7277<<t<=>%
s   ?A)normaloverlayrJ   zsitecustomize.pywzutf-8)encodinga  
                import os, site, sys

                # First, drop system-sites related paths.
                original_sys_path = sys.path[:]
                known_paths = set()
                for path in {system_sites!r}:
                    site.addsitedir(path, known_paths=known_paths)
                system_paths = set(
                    os.path.normcase(path)
                    for path in sys.path[len(original_sys_path):]
                )
                original_sys_path = [
                    path for path in original_sys_path
                    if os.path.normcase(path) not in system_paths
                ]
                sys.path = original_sys_path

                # Second, add lib directories.
                # ensuring .pth file are processed.
                for path in {lib_dirs!r}:
                    assert not path in sys.path
                    site.addsitedir(path)
                )rL   r5   )	installerr   r   	BUILD_ENVr   	_prefixes	_bin_dirs	_lib_dirsreversedlistvaluesr}   r2   r   r5   rM   rC   r/   r   	_site_direxistsmkdiropenwritetextwrapdedentformat)r6   r   r.   rL   fpr   s        @r#   r8   zBuildEnvironment.__init__   sL   " m&=&=PTU$ %
-%
 

 %'$&tDNN$9$9$;<= 	3FNN!!&..1NN!!&//2	3 01hmmV<ww~~dnn-HHT^^$GGLL);<cG
 	HH2 &lT^^&L5	 	 	s   =A GGc                   dD ci c]#  }|t         j                  j                  |d       % c}| _        | j                  d d  }| j                  d   }|r.|j                  |j                  t         j                               | j                  g}t         j                  j                  t         j                  j                  |      dt         j                  j                  |      d       y c c}w )N)PATHPYTHONNOUSERSITE
PYTHONPATHr   rt   )rC   rg   rh   	_save_envr   r   splitpathsepr   updater   )r6   r   r/   old_path
pythonpaths        r#   	__enter__zBuildEnvironment.__enter__2  s     C
 "**..t,,

 ~~a >>&)KKrzz23nn%





-$' jjooj9	

s   (C.c                    | j                   j                         D ];  \  }}|!t        j                  j	                  |d        )|t        j                  |<   = y r&   )r   itemsrC   rg   pop)r6   exc_typeexc_valexc_tbvarname	old_values         r#   __exit__zBuildEnvironment.__exit__G  sK     #'.."6"6"8 	0GY 

w-&/

7#		0r"   c                |   t               }t               }|r"t        | d      rt        | j                        n	t	               }|D ]  }t        |      }|j                  |j                  j                  ddi      s8|j                  |j                        }|s|j                  |       gt        |j                  t              r|j                   d|j                   }n|j                   d|j                   }|j                  j                  |j                  d      r|j                  ||f        ||fS )zReturn 2 sets:
        - conflicting requirements: set of (installed, wanted) reqs tuples
        - missing requirements: set of reqs
        r   extrar-   z==z===T)prereleases)setrI   r   r   r   r   markerevaluateget_distributionr   add
isinstanceversionr
   	specifiercontains)	r6   reqsmissingconflictingenvreq_strreqdistinstalled_req_strs	            r#   check_requirementsz#BuildEnvironment.check_requirementsS  s    %e 4-  /,. 
   B%g. ::)#**2E2EwPRm2T++CHH5KK(dllG4+.88*Bt||n(E%+.88*C~(F%}}--dll-MOO%6$@AB" G##r"   NrS   c                   | j                   |   }|j                  rJ d|_        |sy | j                  j                  ||||       y )NT)rR   rS   )r   r0   r   rT   )r6   rQ   prefix_as_stringrR   rS   r.   s         r#   install_requirementsz%BuildEnvironment.install_requirementsu  sH      01<<|V$Pr"   )r   rO   r:   r;   r   r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner:   r;   )r   rV   r:   z%tuple[set[tuple[str, str]], set[str]]
rQ   rV   r   r9   rR   r9   rS   rW   r:   r;   )	r   r   r   rX   r8   r   r   r   r   r!   r"   r#   r   r      s    K5n
*
0,
0 &
0 %	
0
 

0 $! $	. $P .2Q#Q Q
 Q +Q 
Qr"   r   c                  `    e Zd ZdZd	dZd	dZ	 	 	 	 	 	 	 	 d
dZd	dZdd	 	 	 	 	 	 	 	 	 ddZy)NoOpBuildEnvironmentz0A no-op drop-in replacement for BuildEnvironmentc                     y r&   r!   r6   s    r#   r8   zNoOpBuildEnvironment.__init__      r"   c                     y r&   r!   r   s    r#   r   zNoOpBuildEnvironment.__enter__  r   r"   c                     y r&   r!   )r6   r   r   r   s       r#   r   zNoOpBuildEnvironment.__exit__  s     	r"   c                     y r&   r!   r   s    r#   cleanupzNoOpBuildEnvironment.cleanup  r   r"   Nr   c                   t               r&   )NotImplementedError)r6   rQ   r   rR   rS   s        r#   r   z)NoOpBuildEnvironment.install_requirements  s     "##r"   r   r   r   )	r   r   r   rX   r8   r   r   r   r   r!   r"   r#   r   r     sy    :, & %	
 
 .2$#$ $
 $ +$ 
$r"   r   )r'   r9   r(   r9   r:   ztuple[str] | tuple[str, str])r:   r9   )r:   zset[str])<rX   
__future__r   r{   rC   r=   rJ   rw   r   collectionsr   collections.abcr   typesr   typingr   r   r	   pip._vendor.packaging.versionr
   pipr   r?   pip._internal.cli.spinnersr   pip._internal.locationsr   r   r   pip._internal.metadatar   r   pip._internal.utils.deprecationr   pip._internal.utils.loggingr   pip._internal.utils.packagingr   pip._internal.utils.subprocessr   pip._internal.utils.temp_dirr   r   "pip._internal.index.package_finderr   pip._internal.req.req_installr   r   	getLoggerr   ry   r)   r+   rF   rM   rO   rZ   r   r   r!   r"   r#   <module>r      s    @ "  	   
  # $  5 5 1 ( 3 H H K 6 / 9 : E@@&y & 
		8	$&? ?5 =(  M M`JQ JQZ$+ $r"   