
    ?[h                         d 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
 ddlmZ ddlmZ ddlZ ej        d	          Z	 eZ G d
 de          ZdS )zRdistutils.command.build_scripts

Implements the Distutils 'build_scripts' command.    N)ST_MODE)	sysconfig)Command)newer)convert_path)logz^#!.*python[0-9.]*([ 	].*)?$c                   f    e Zd ZdZg dZdgZd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zed             ZdS )build_scriptsz("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 pathr   c                 >    d | _         d | _        d | _        d | _        d S N)	build_dirscriptsr   
executableselfs    z/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/setuptools/_distutils/command/build_scripts.pyinitialize_optionsz build_scripts.initialize_options$   s"    
    c                 X    |                      dddd           | j        j        | _        d S )Nbuild)r
   r   )r   r   )r   r   )set_undefined_optionsdistributionr   r   s    r   finalize_optionszbuild_scripts.finalize_options*   s9    ""*(		
 	
 	
 (0r   c                     | j         S r   )r   r   s    r   get_source_fileszbuild_scripts.get_source_files3   s
    |r   c                 @    | j         sd S |                                  d S r   )r   copy_scriptsr   s    r   runzbuild_scripts.run6   s)    | 	Fr   c                     |                      | j                   g }g }| j        D ]}|                     |||           |                     |           ||fS )a2  
        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!   zbuild_scripts.copy_scripts;   sm     	DN###l 	? 	?Ffh>>>>8$$$&&r   c                 V   d }t          |          }t          j                            | j        t          j                            |                    }|                    |           | j        s't          ||          st          j
        d|           d S 	 t          j        |          }|                                }|s|                     d|z             d S t                              |          }n# t"          $ r | j        s d }Y nw xY w|                    |           |rTt          j        d|| j                   | j        st(          j        s| j        }n[t          j                            t)          j        d          dt)          j        d          t)          j        d                    }|                    d          pd	}	d
|z   |	z   dz   }
|                     |
|j                   t          |d|j                  5 }|                    |
           |                    |                                           d d d            n# 1 swxY w Y   |r|                                 d S d S |r|                                 |                     ||           d S )Nznot copying %s (up-to-date)z%s is an empty file (skipping)zcopying and adjusting %s -> %sBINDIRpythonVERSIONEXE    z#!
w)encoding) r   ospathjoinr   basenameappendr   r   r   debugtokenizeopenreadlinewarnshebang_patternmatchOSErrordry_runinfor   python_buildr   get_config_vargroup_validate_shebangr3   write
writelines	readlinesclose	copy_file)r   r)   r'   r(   shebang_matchoutfiler   
first_liner   post_interpshebangoutfs               r   r%   zbuild_scripts._copy_scriptN   s   f%%',,t~rw/?/?/G/GHH   z 	%"8"8 	I3V<<<F	>f%%A J 		:VCDDD+11*==MM  	 	 	< AAA	 	W%%% 	,H5vt~NNN< 3 - 
!%JJ!#!0::: &4Y???%4U;;;" "J ,11!44:+k9D@&&w
;;;'3<<< 3JJw'''OOAKKMM2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3  					   			NN67+++++s$   C7 7DD=IIIc                 ^    t           j        dk    rd S |D ]}|                     |           d S )Nposix)r4   name_change_mode)r   r'   files      r   r&   zbuild_scripts._change_modes   sD    7gF 	$ 	$Dd####	$ 	$r   c                     | j         rt          j        d|           d S t          j        |          t
                   dz  }|dz  dz  }||k    r.t          j        d|||           t          j        ||           d S d S )Nzchanging mode of %si  im  z!changing mode of %s from %o to %o)rA   r   rB   r4   statr   chmod)r   rV   oldmodenewmodes       r   rU   zbuild_scripts._change_mode   s    < 	H*D111F'$--(61U?f,gH8$QQQHT7##### r   c                 "   	 |                      d           n0# t          $ r# t          d                    |                     w xY w	 |                      |           d S # t          $ r$ t          d                    | |                    w xY w)Nzutf-8z,The shebang ({!r}) is not encodable to utf-8z?The shebang ({!r}) is not encodable to the script encoding ({}))encodeUnicodeEncodeError
ValueErrorformat)rP   r3   s     r   rF   zbuild_scripts._validate_shebang   s    	NN7####! 	 	 	AHHQQ  		NN8$$$$$! 	 	 	..4fWh.G.G  	s    -A	A   .BN)__name__
__module____qualname__descriptionuser_optionsboolean_optionsr   r   r   r"   r!   r%   r&   rU   staticmethodrF    r   r   r
   r
      s        >K  L iO  1 1 1    
' ' '&4, 4, 4,l$ $ $	$ 	$ 	$   \  r   r
   )__doc__r4   rerX   r   	distutilsr   distutils.corer   distutils.dep_utilr   distutils.utilr   r   r:   compiler>   first_line_rer
   rh   r   r   <module>rq      s   5 5 
			 				             " " " " " " $ $ $ $ $ $ ' ' ' ' ' '       "*<==
  U U U U UG U U U U Ur   