
    5hxu              
         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mZ ddlmZ ddlmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZmZmZmZ ddlm Z! dZ"ddddddZ#dddddddddddde#dddddddddddddZ$e"rd d d!d"d#de$d$<   d d d%d&d#de$d'<   e$%                    e!j&                   dZ'd( Z(d) Z)d* Z*d+ Z+d, Z,d- Z-d. Z.d/ Z/d0 Z0 G d1 d2e          Z1dS )3zFdistutils.command.install

Implements the Distutils 'install' command.    )annotationsN)log)	USER_BASE	USER_SITE)ClassVar   )Command)DEBUG)DistutilsOptionErrorDistutilsPlatformError)
write_file)get_config_vars)change_rootconvert_pathget_platform
subst_vars   )_framework_compatTz{base}/Lib/site-packagesz{base}/Include/{dist_name}z{base}/Scriptsz{base})purelibplatlibheadersscriptsdatazA{base}/lib/{implementation_lower}{py_version_short}/site-packageszN{platbase}/{platlibdir}/{implementation_lower}{py_version_short}/site-packageszM{base}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z
{base}/binz!{base}/lib/{implementation_lower}z*{base}/{platlibdir}/{implementation_lower}z1{base}/include/{implementation_lower}/{dist_name}z{base}/site-packagesz{base}/include/{dist_name})posix_prefix
posix_homentpypypypy_ntz
{usersite}zF{userbase}/{implementation}{py_version_nodot_plat}/Include/{dist_name}z:{userbase}/{implementation}{py_version_nodot_plat}/Scriptsz
{userbase}nt_userzQ{userbase}/include/{implementation_lower}{py_version_short}{abiflags}/{dist_name}z{userbase}/bin
posix_userc                     t          j        t                    5  d t          j                    D             cd d d            S # 1 swxY w Y   d S )Nc                <    i | ]}|t          j        |d           S )F)expand)	sysconfig	get_paths).0schemes     Elib/python3.11/site-packages/setuptools/_distutils/command/install.py
<dictcomp>z+_load_sysconfig_schemes.<locals>.<dictcomp>e   s:     
 
 
 I'u===
 
 
    )
contextlibsuppressAttributeErrorr$   get_scheme_names r*   r(   _load_sysconfig_schemesr0   c   s    		^	,	, 
 

 
#466
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   AAAc                      t                      pi   fdt          t          j        t                               D             S )z=
    Extend default schemes with schemes from sysconfig.
    c                x    i | ]6}|i t                               |i                               |i           7S r/   )INSTALL_SCHEMESget)r&   r'   sysconfig_schemess     r(   r)   z!_load_schemes.<locals>.<dictcomp>r   s`       
 	 	 
!!&"--
##FB//
  r*   )r0   set	itertoolschainr3   )r5   s   @r(   _load_schemesr9   k   sX    
 0117R   
 )//;LMMNN   r*   c                 4    t          t          d          rdS dS )Npypy_version_infoPyPyPython)hasattrsysr/   r*   r(   _get_implementationr@   {   s    s'(( vxr*   c                    t          |t          t          |                              }t          |                               t          | t          |                               d S N)_inject_headers_load_scheme_resolve_schemevarsupdate_remove_set_scheme_attrs)obnamer'   s      r(   _select_schemerL      sQ    T<0E0E#F#FGGFHHOOKM&$9$9::;;;;;r*   c                D      fd|                                 D             S )z1
    Include only attrs that are None in ob.
    c                <    i | ]\  }}t          |          ||S rB   )getattr)r&   keyvaluerJ   s      r(   r)   z_remove_set.<locals>.<dictcomp>   s.    SSS:3'"c:J:J:RC:R:R:Rr*   )items)rJ   attrss   ` r(   rH   rH      s(     TSSSSSSSr*   c                    |                      d          \  }}}	 t          j        |          }n$# t          $ r t	          j        |           }Y nw xY w|S )N_)	partitionr$   get_preferred_scheme	Exceptionfwr'   )rK   os_nameseprP   resolveds        r(   rE   rE      sb    s++GS##1#66 # # #9T??#Os   0 AAc                *    t                      |          S rB   )r9   )rK   s    r(   rD   rD      s    ??4  r*   c                \    t          |           }|                    d|d                    |S )z
    Given a scheme name and the resolved scheme,
    if the scheme does not include headers, resolve
    the fallback scheme for the name and use headers
    from it. pypa/distutils#88
    r   )rD   
setdefault)rK   r'   fallbacks      r(   rC   rC      s1     D!!H
i)!4555Mr*   c                *      fdt           D             S )z<Resolve install directories by applying the install schemes.c                (    i | ]}d | |         S )install_r/   )r&   rP   r'   s     r(   r)   z!_scheme_attrs.<locals>.<dictcomp>   s(    AAAcsfSkAAAr*   )SCHEME_KEYS)r'   s   `r(   rI   rI      s    AAAA[AAAAr*   c                  `   e Zd ZU dZg dZg dZded<   er1e                    ddde	 d	f           e                    d           d
diZ
ded<   d+dZd+dZd+dZd+dZd+dZd+dZd Zd+dZd+dZd+dZd+dZd+dZd+dZd Zd Zd Zd  Zd! Zd" Zd# Zd$ Zd%efd&efd'efd(efd)d* fgZ dS ),installz'install everything from build directory))zprefix=Nzinstallation prefix)zexec-prefix=Nz.(Unix only) prefix for platform-specific files)zhome=Nz+(Unix only) home directory to install under)zinstall-base=Nz;base installation directory (instead of --prefix or --home))zinstall-platbase=Nz\base installation directory for platform-specific files (instead of --exec-prefix or --home))zroot=Nz<install everything relative to this alternate root directory)zinstall-purelib=Nz;installation directory for pure Python module distributions)zinstall-platlib=Nz8installation directory for non-pure module distributions)zinstall-lib=Nzginstallation directory for all module distributions (overrides --install-purelib and --install-platlib))zinstall-headers=Nz(installation directory for C/C++ headers)zinstall-scripts=Nz)installation directory for Python scripts)zinstall-data=Nz%installation directory for data files)compileczcompile .py to .pyc [default])
no-compileNzdon't compile .py files)z	optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])forcefz1force installation (overwrite any existing files))
skip-buildNz2skip rebuilding everything (for testing/debugging))zrecord=Nz3filename in which to record list of installed files)rg   rk   rm   zClassVar[list[str]]boolean_optionsuserNzinstall in user site-package ''ri   rg   zClassVar[dict[str, str]]negative_optreturnNonec                x   d| _         d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _	        d| _
        d| _        d| _        t          | _        t          | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        dS )zInitializes options.NFT)prefixexec_prefixhomero   install_baseinstall_platbaserootinstall_purelibinstall_platlibinstall_headersinstall_libinstall_scriptsinstall_datar   install_userbaser   install_usersiterg   optimize
extra_pathinstall_path_filerk   
skip_buildwarn_dir
build_base	build_librecordselfs    r(   initialize_optionszinstall.initialize_options   s     #''+ $		
 ! $ $	  $##'+#  ) ) !% 
  r*   c                *	   | j         s| j        s| j        r| j        s| j        rt          d          | j        r| j         s| j        rt          d          | j        r2| j         s| j        s| j        s| j        s| j        rt          d          t          j        dk    r#| j        r| 	                    d           d| _        | 
                    d           t          j        dk    r|                                  n|                                  | 
                    d           t          j                                        d	         }t!          d
d          \  }}	 t          j        }n# t$          $ r d}Y nw xY w| j                                        | j                                        | j                                        |t          j        j         dt          j        j         t          j        j         t          j        j         |||||t5          t          dd          t7                                                      t7                      d}t;          t5          t          dd                              dd                    }t>          r| j         |d<   | j!        |d<   tE          j#        |tI          j                    |tK          j&                              | _'        | (                                 | 
                    d           | j        |d<   | j        |d<   tR          r2d	dl*m*} tW          d            |t;          | j'                             | ,                                 | 
                    d           | j        r| -                                 | j.        2| j        /                                r| j0        | _.        n| j1        | _.        | 2                    dddddddd           | 3                                 | j.        | _4        t          j5        6                    | j.        | j7                  | _.        | j8        | 9                    d dddddd           | 
                    d!           | :                    d"d#d$           dS )%zFinalizes options.zWmust supply either prefix/exec-prefix/home or install-base/install-platbase -- not bothz9must supply either home or prefix/exec-prefix -- not bothzGcan't combine user with prefix, exec_prefix/home, or install_(plat)baseposixz+exec-prefix option ignored on this platformNzpre-finalize_{unix,other}zpost-finalize_{unix,other}()r   ru   rv    .
platlibdirlib)	dist_namedist_versiondist_fullname
py_versionpy_version_shortpy_version_nodot
sys_prefixru   sys_exec_prefixrv   abiflagsr   implementation_lowerimplementationwinver)py_version_nodot_platuserbaseusersitezpost-expand_basedirs()baseplatbase)pprintzconfig vars:zpost-expand_dirs()r   r   r   r   r   libbasezafter prepending rootbuild)r   r   )r   r   );ru   rv   rw   rx   ry   r   ro   osrK   warn	dump_dirsfinalize_unixfinalize_otherr?   versionsplitr   r   r-   distributionget_nameget_versionget_fullnameversion_infomajorminorrO   r@   lowerdictreplaceHAS_USER_SITEr   r   collectionsChainMapr$   rY   rF   config_varsexpand_basedirsr
   r   printexpand_dirscreate_home_pathr~   has_ext_modulesr|   r{   convert_pathshandle_extra_pathinstall_libbasepathjoin
extra_dirsrz   change_rootsset_undefined_options)r   r   ru   rv   r   
local_varscompat_varsr   s           r(   finalize_optionszinstall.finalize_optionsD  s     K 	4+ 	ty 		!%!6	 'i   9 	$+ 	)9 	&K   9 
	K
	
	 y
	  	
	
 $
	 ':   7g (		GHHH#'  	23337g    !!!5666 [&&((+
 /- H H	|HH 	 	 	HHH	 *3355 -99;;!.;;==$#&#3#9 T TC<L<R T T#&#3#9 S3;K;Q S S *& !#|U;;$7$9$9$?$?$A$A133
 

$ ")#x"<"<"D"DS""M"M
 
 

  	;%)%:Jz"%)%:Jz"&/%''GII	
 
 	/000 ".
6!%!6
: 	+%%%%%%.!!!F4())*** 	+,,, 9 	$!!### # 0022 8#'#7  #'#7  			
 		
 		
  	   #/7<<(8$/JJ 9 5)Y	69   	./// 	""13M	
 	
 	
 	
 	
s   E+ +E:9E:c                   t           sdS ddlm} t          j        |dz              | j        D ]}|d         }|d         dk    r
|dd         }|| j        v r4| j        |         }|                    |          }t          | |           }n%|                    |          }t          | |          }t          j        d||           dS )	zDumps the list of user options.Nr   )longopt_xlate:r   =z  %s: %s)	r
   fancy_getoptr   r   debuguser_optionsrq   	translaterO   )r   msgr   optopt_namevals         r(   r   zinstall.dump_dirs  s     	F000000	#)$ 	1 	1C1vH|s""#AbD>4,,,,X6#--m<<!$111#--m<<dH--Ij(C0000	1 	1r*   c                P   | j         | j        I| j        du o| j        du o| j        du p| j        du p| j        du p| j        du }|rt          d          dS | j	        r@| j
        t          d          | j
        x| _         | _        |                     d           dS | j        *| j        x| _         | _        |                     d           dS | j        | j        t          d          t!          t"          dd          }t$          j                            t*          j                  |z   | _        t$          j                            t*          j                  |z   | _        n| j        | j        | _        | j        | _         | j        | _        |                     d	           dS )
z&Finalizes options for posix platforms.NzPinstall-base or install-platbase supplied, but installation scheme is incomplete$User base directory is not specifiedr    r   z*must not supply exec-prefix without prefix_prefix_additionr   r   )rx   ry   r~   r{   r|   r}   r   r   r   ro   r   r   select_schemerw   ru   rv   rO   r$   r   r   normpathr?   )r   incomplete_schemer   s      r(   r   zinstall.finalize_unix  s   (D,A,M $, 5,45,4-
 '4/- '4/- $,  ! *8   F9 	/$,,-STTT8<8MMD 5|,,,,,Y"8<	AD 5|,,,,,{"#/.D  
 $+96H"#M#M  g..sz::=MM#%7#3#3CO#D#DGW#W   #+'+{D$ $D$($4D!~.....r*   c                6   | j         rM| j        t          d          | j        x| _        | _        |                     t          j        dz              dS | j        *| j        x| _        | _        |                     d           dS | j	        .t          j
                            t          j	                  | _	        | j	        x| _        | _        	 |                     t          j                   dS # t          $ r t          dt          j         d          w xY w)z)Finalizes options for non-posix platformsNr   _userr   z&I don't know how to install stuff on 'rp   )ro   r   r   rx   ry   r   r   rK   rw   ru   r   r   r?   KeyErrorr   s    r(   r   zinstall.finalize_other@  s   9 	$,,-STTT8<8MMD 5rw011111Y"8<	AD 5|,,,,,{" g..sz::8<CD 5""27+++++   ,GRWGGG  s   C0 0(Dc                &    t          | |           d S rB   )rL   )r   rK   s     r(   r   zinstall.select_schemeV  s    tT"""""r*   c                    |D ]g}t          | |          }|St          j        dv rt          j                            |          }t          || j                  }t          | ||           hd S )N)r   r   )rO   r   rK   r   
expanduserr   r   setattr)r   rS   attrr   s       r(   _expand_attrszinstall._expand_attrsY  sv     	) 	)D$%%C7o--',,S11C d&677dC(((	) 	)r*   c                4    |                      g d           dS )zNCalls `os.path.expanduser` on install_base, install_platbase and
        root.)rx   ry   rz   Nr   r   s    r(   r   zinstall.expand_basedirsb  s%     	GGGHHHHHr*   c                4    |                      g d           dS )z+Calls `os.path.expanduser` on install dirs.)r{   r|   r~   r}   r   r   Nr   r   s    r(   r   zinstall.expand_dirsg  s3     
 
 
 	 	 	 	 	r*   c                r    |D ]3}d|z   }t          | |t          t          | |                               4dS )z!Call `convert_path` over `names`.rc   N)r   r   rO   r   namesrK   r   s       r(   r   zinstall.convert_pathsr  sP     	C 	CD$DD$WT4-@-@ A ABBBB	C 	Cr*   c                   | j         | j        j         | _         | j         t          j        d           t	          | j         t
                    r| j                             d          | _         t          | j                   dk    r| j         d         x}}n2t          | j                   dk    r| j         \  }}nt          d          t          |          }nd}d}|| _
        || _        dS )	z4Set `path_file` and `extra_dirs` using `extra_path`.NzIDistribution option extra_path is deprecated. See issue27919 for details.,r   r   r   zY'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementsr   )r   r   r   warning
isinstancestrr   lenr   r   	path_filer   )r   r   r   s      r(   r   zinstall.handle_extra_pathx  s    ?""/:DO?&K.   $/3// ="&/"7"7"<"<4?##q(()-);;	JJT_%%**(,%	::*B   &j11JJIJ #$r*   c                ~    |D ]9}d|z   }t          | |t          | j        t          | |                               :dS )z:Change the install directories pointed by name using root.rc   N)r   r   rz   rO   r   s       r(   r   zinstall.change_roots  sT     	M 	MD$DD$DIwtT7J7J K KLLLL	M 	Mr*   c                   | j         sdS t          t          j                            d                    }| j                                        D ]q}t          |                              |          rMt          j        	                    |          s.| 
                    d| d           t          j        |d           rdS )zCreate directories under ~.N~zos.makedirs('z	', 0o700)i  )ro   r   r   r   r   r   valuesr   
startswithisdirdebug_printmakedirs)r   rw   r   s      r(   r   zinstall.create_home_path  s    y 	FBG..s3344$++-- 	) 	)D4yy##D)) )"'--2E2E )  !@!@!@!@AAAD%(((	) 	)r*   c                   | j         s\|                     d           | j                            d          j        }| j        r!|t                      k    rt          d          |                                 D ]}|                     |           | j	        r| 
                                 | j        r|                                 }| j        rFt          | j                  }t          t          |                    D ]}||         |d         ||<   |                     t"          | j        |fd| j         d           t%          t&          j        j        t,          j                  }t%          t&          j        j        |          }t&          j                            t&          j                            | j                            }| j        r.| j	        r| j        s$||vrt5          j        d| j                   dS dS dS dS )zRuns the command.r   z"Can't install when cross-compilingNz$writing list of installed files to 'rp   zmodules installed to '%s', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself)r   run_commandr   get_command_obj	plat_namer   r   r   get_sub_commandsr   create_path_filer   get_outputsrz   r   rangeexecuter   mapr   r   r   r?   normcaser~   r   r   r   )r   
build_platcmd_nameoutputsroot_lencountersys_pathr~   s           r(   runzinstall.run  s      	SW%%%*::7CCMJ } S|~~!=!=,-QRRR --// 	' 	'HX&&&&> 	$!!### ; 
	&&((Gy Cty>>$S\\22 C CG'.w'7		'BGG$$LLg&Et{EEE   rw'22rw'22g&&rw'7'78H'I'IJJM	^	(,(>	 8++IE      	 	 ,+	 	r*   c                    t           j                            | j        | j        dz             }| j        r)|                     t          || j        gfd|            dS | 	                    d| d           dS )zCreates the .pth file.pthz	creating zpath file 'z' not createdN)
r   r   r   r   r   r   r  r   r   r   )r   filenames     r(   r  zinstall.create_path_file  s    7<< 4dnv6MNN! 	=LLX'89;Qx;Q;Q     II;H;;;<<<<<r*   c                ^   g }|                                  D ]G}|                     |          }|                                D ]}||vr|                    |           H| j        rG| j        r@|                    t          j                            | j	        | j        dz                        |S )z.Assembles the outputs of all the sub-commands.r  )
r  get_finalized_commandr  appendr   r   r   r   r   r   )r   r  r
  cmdr  s        r(   r  zinstall.get_outputs  s    --// 	- 	-H,,X66C  OO-- - -7**NN8,,,- > 	Xd4 	XNN27<<(<dnv>UVVWWWr*   c                    g }|                                  D ]>}|                     |          }|                    |                                           ?|S )z*Returns the inputs of all the sub-commands)r  r  extend
get_inputs)r   inputsr
  r  s       r(   r  zinstall.get_inputs  s[     --// 	, 	,H,,X66CMM#..**++++r*   c                f    | j                                         p| j                                         S )zSReturns true if the current distribution has any Python
        modules to install.)r   has_pure_modulesr   r   s    r(   has_libzinstall.has_lib  s/     ..00WD4E4U4U4W4W	
r*   c                4    | j                                         S )zLReturns true if the current distribution has any headers to
        install.)r   has_headersr   s    r(   r  zinstall.has_headers        ,,...r*   c                4    | j                                         S )zMReturns true if the current distribution has any scripts to.
        install.)r   has_scriptsr   s    r(   r"  zinstall.has_scripts  r   r*   c                4    | j                                         S )zJReturns true if the current distribution has any data to.
        install.)r   has_data_filesr   s    r(   has_datazinstall.has_data  s      //111r*   r~   r}   r   r   install_egg_infoc                    dS )NTr/   r   s    r(   <lambda>zinstall.<lambda>$  s    $ r*   )rr   rs   )!__name__
__module____qualname__descriptionr   rn   __annotations__r   r  r   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r"  r%  sub_commandsr/   r*   r(   rf   rf      sk        ;K8 8 8Lt ,N+M+MOMMMM '9Y999
 	 	 	
 	v&&&.:I-FLFFFFE E E EZr
 r
 r
 r
n1 1 1 1(// // // //b   ,# # # #) ) )I I I I
	 	 	 	C C C C!% !% !% !%FM M M M) ) ) )0 0 0d= = =     
 
 
/ / /
/ / /
2 2 2 
 	K(	K(	"	../LLLr*   rf   )2__doc__
__future__r   r   r+   r7   r   r?   r$   distutils._logr   siter   r   typingr   corer	   r   r
   errorsr   r   	file_utilr   r   utilr   r   r   r   r   r   rY   r   WINDOWS_SCHEMEr3   rG   schemesrd   r0   r9   r@   rL   rH   rE   rD   rC   rI   rf   r/   r*   r(   <module>r:     s  / / # " " " " "             				 



           % % % % % % % %                   A A A A A A A A " " " " " " ' ' ' ' ' ' F F F F F F F F F F F F % % % % % % *)+  W+3  7?F  ))/  *)/# 3   F  O" "OI  3#% %OL!   rz " " " C
 
 
     < < <
T T T  ! ! !  B B B
w	 w	 w	 w	 w	g w	 w	 w	 w	 w	r*   