
    n&ph                         S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SS	KJr  \R                   " S
5      r \r " S S\5      rg)zRdistutils.command.build_scripts

Implements the Distutils 'build_scripts' command.    N)log)ST_MODE)ClassVar   )newer)Command)convert_pathz^#!.*python[0-9.]*([ 	].*)?$c                       \ rS rSr% Sr/ SQr\\\\	\	\	4         \
S'   S/r\\\	      \
S'   S rS rS	 rS
 rS rS rS rS r\S 5       rSrg)build_scripts   z("build" scripts (copy and fixup #! line)))z
build-dir=dzdirectory to "build" (copy) to)forcefz1forcibly build everything (ignore file timestamps)zexecutable=ez*specify final destination interpreter pathuser_optionsr   boolean_optionsc                 <    S U l         S U l        S U l        S U l        g N)	build_dirscriptsr   
executableselfs    ^/var/www/html/venv/lib/python3.13/site-packages/setuptools/_distutils/command/build_scripts.pyinitialize_options build_scripts.initialize_options$   s    
    c                 b    U R                  SSSS5        U R                  R                  U l        g )Nbuild)r   r   )r   r   )r   r   )set_undefined_optionsdistributionr   r   s    r   finalize_optionsbuild_scripts.finalize_options*   s1    ""*(		
 ((00r   c                     U R                   $ r   )r   r   s    r   get_source_filesbuild_scripts.get_source_files3   s    ||r   c                 H    U R                   (       d  g U R                  5         g r   )r   copy_scriptsr   s    r   runbuild_scripts.run6   s    ||r   c                     U R                  U R                  5        / n/ nU R                   H  nU R                  X1U5        M     U R	                  U5        X4$ )a  
Copy each script listed in ``self.scripts``.

If a script is marked as a Python script (first line matches
'shebang_pattern', i.e. starts with ``#!`` and contains
"python"), then adjust in the copy the first line to refer to
the current Python interpreter.
)mkpathr   r   _copy_script_change_modes)r   outfilesupdated_filesscripts       r   r(   build_scripts.copy_scripts;   sU     	DNN#llFf> # 	8$&&r   c                    S n[        U5      n[        R                  R                  U R                  [        R                  R                  U5      5      nUR                  U5        U R                  (       d(  [        X5      (       d  [        R                  " SU5        g  [        R                  " U5      nUR                  5       nU(       d  U R                  U S35        g [        R!                  U5      nUR                  U5        U(       a  [        R&                  " SXR                  5        U R$                  (       d  UR)                  S5      =(       d    SnSU R*                  -   U-   S-   n	U R-                  XR.                  5        [        USUR.                  S	9 n
U
R1                  U	5        U
R3                  UR5                  5       5        S S S 5        U(       a  UR7                  5         g g U(       a  UR7                  5         U R9                  X5        g ! ["         a    U R$                  (       d  e S n GNEf = f! , (       d  f       Nu= f)
Nznot copying %s (up-to-date)z is an empty file (skipping)zcopying and adjusting %s -> %s    z#!
w)encoding)r	   ospathjoinr   basenameappendr   r   r   debugtokenizeopenreadlinewarnshebang_patternmatchOSErrordry_runinfogroupr   _validate_shebangr8   write
writelines	readlinesclose	copy_file)r   r1   r/   r0   shebang_matchoutfiler   
first_linepost_interpshebangoutfs              r   r-   build_scripts._copy_scriptN   s   f%'',,t~~rww/?/?/GH zz%"8"8II3V<	>f%A J		VH$@AB+11*=MW%HH5v~~N<<+11!4:0;>E&&w

;'3<JJw'OOAKKM2 = 	  	NN6+7  	<<A	& =<s    H  1I H=<H= 
Ic                 b    [         R                  S:w  a  g U H  nU R                  U5        M     g )Nposix)r9   name_change_mode)r   r/   files      r   r.   build_scripts._change_modesy   s)    77gDd# r   c                    U R                   (       a  [        R                  " SU5        g [        R                  " U5      [
           S-  nUS-  S-  nX2:w  a/  [        R                  " SXU5        [        R                  " X5        g g )Nzchanging mode of %si  im  z!changing mode of %s from %o to %o)rF   r   rG   r9   statr   chmod)r   rZ   oldmodenewmodes       r   rY   build_scripts._change_mode   sh    <<HH*D1''$-(61U?f,HH8$QHHT# r   c                      U R                  S5         U R                  U5        g ! [         a    [        SU < S35      ef = f! [         a    [        SU < SU S35      ef = f)Nzutf-8zThe shebang (z) is not encodable to utf-8z+) is not encodable to the script encoding ())encodeUnicodeEncodeError
ValueError)rS   r8   s     r   rI   build_scripts._validate_shebang   s    	UNN7#	NN8$ " 	U}WK7RSTT	U " 	{ +++3*A7 	s   & A AA")r   r   r   r   N)__name__
__module____qualname____firstlineno__descriptionr   r   listtuplestr__annotations__r   r   r"   r%   r)   r(   r-   r.   rY   staticmethodrI   __static_attributes__ r   r   r   r      s~    >K:L(4c3m 456  -49OXd3i(41
'&),V$	$  r   r   )__doc__r9   rer?   distutils._logr   r]   r   typingr   	_modifiedr   corer   utilr	   compilerC   first_line_rer   rs   r   r   <module>r}      sP   5 
 	       **<=
  GG Gr   