
    n&ph8A                     ~    S r SSK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Jr  SSKJr   " S	 S
\5      rg)zHdistutils.command.build_py

Implements the Distutils 'build_py' command.    N)log)ClassVar   )Command)DistutilsFileErrorDistutilsOptionError)convert_pathc                      \ rS rSr% Sr/ SQrSS/r\\\	      \
S'   SS0r\\\	\	4      \
S'   S	 rS S jrS S jrS rS rS S jrS rS rS rS rS rS rS rS rS!S\S
\\	   4S jjrS rS S jrS S jrS S jr Sr!g)"build_py   z5"build" pure Python modules (copy to build directory)))z
build-lib=dzdirectory to "build" (copy) to)compileczcompile .py to .pyc)
no-compileNz!don't compile .py files [default])z	optimize=Ozlalso compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0])forcefz2forcibly build everything (ignore file timestamps)r   r   boolean_optionsr   negative_optc                 t    S U l         S U l        S U l        S U l        S U l        SU l        SU l        S U l        g )NFr   )	build_lib
py_modulespackagepackage_datapackage_dirr   optimizer   selfs    Y/var/www/html/venv/lib/python3.13/site-packages/setuptools/_distutils/command/build_py.pyinitialize_optionsbuild_py.initialize_options$   s<     
    returnNc                    U R                  SSS5        U R                  R                  U l        U R                  R                  U l        U R                  R                  U l        0 U l        U R                  R
                  (       aE  U R                  R
                  R                  5        H  u  p[        U5      U R
                  U'   M     U R                  5       U l	        [        U R                  [        5      (       d8   [        U R                  5      U l        SU R                  s=::  a  S::  d   e   eg g ! [        [        4 a    [        S5      ef = f)Nbuild)r   r   )r   r   r   r   zoptimize must be 0, 1, or 2)set_undefined_optionsdistributionpackagesr   r   r   itemsr	   get_data_files
data_files
isinstancer   int
ValueErrorAssertionErrorr   )r   namepaths      r   finalize_optionsbuild_py.finalize_options.   s"   ""/1C	
 ))22++66 --::(("//;;AAC
)5d);  & D--/ $----J #DMM 2DMM.Q..... . / J*+HIIJs   6D9 9Ec                     U R                   (       a  U R                  5         U R                  (       a   U R                  5         U R	                  5         U R                  U R                  SS95        g )NF)include_bytecode)r   build_modulesr(   build_packagesbuild_package_databyte_compileget_outputsr   s    r   runbuild_py.runG   sR    , ?? ==!##%$**E*BCr"   c                    / nU R                   (       d  U$ U R                    H  nU R                  U5      n[        R                  R                  " U R
                  /UR                  S5      -   6 nSnU(       a  [        U5      S-   nU R                  X#5       Vs/ s H  ofUS PM	     nnUR                  X#XG45        M     U$ s  snf )z?Generate list of '(package,src_dir,build_dir,filenames)' tuples.r      N)
r(   get_package_dirosr1   joinr   splitlenfind_data_filesappend)r   datar   src_dir	build_dirplenfile	filenamess           r   r*   build_py.get_data_filese   s    }}K}}G**73G '7'--:L'LNI D7|a' 261E1Eg1WX1Wde1WIXKK9@A %  Ys   Cc           	         U R                   R                  S/ 5      U R                   R                  U/ 5      -   n/ nU H  n[        R                  " [        R                  R                  [        R                  " U5      [        U5      5      5      nUR                  U Vs/ s H2  owU;  d  M
  [        R                  R                  U5      (       d  M0  UPM4     sn5        M     U$ s  snf )z6Return filenames for package's data files in 'src_dir' )
r   getglobrA   r1   rB   escaper	   extendisfile)r   r   rH   globsfilespatternfilelistfns           r   rE   build_py.find_data_files{   s    !!%%b"-0A0A0E0Egr0RRGyyT[[1<3HIH LL%%r5RWW^^B=OX   s   !	C'
."C'
C'
c                 8   U R                    H  u  pp4U H~  n[        R                  R                  X55      nU R	                  [        R                  R                  U5      5        U R                  [        R                  R                  X%5      USS9  M     M     g)z$Copy data files into build directoryFpreserve_modeN)r+   rA   r1   rB   mkpathdirname	copy_file)r   _packagerH   rI   rL   filenametargets          r   r8   build_py.build_package_data   sp    7;3Hy%i:BGGOOF34GGLL3V5   & 8Gr"   c                 L   UR                  S5      nU R                  (       d%  U(       a  [        R                  R                  " U6 $ g/ nU(       aN   U R                  SR	                  U5         nUR                  SU5        [        R                  R                  " U6 $ U R                  R                  S5      nUb  UR                  SU5        U(       a  [        R                  R                  " U6 $ g! [         a    UR                  SUS   5        US	  Of = fU(       a  M  N)zReturn the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any).r>   rO   r   )rC   r   rA   r1   rB   insertKeyErrorrP   )r   r   r1   tailpdirs        r   r@   build_py.get_package_dir   s     }}S!ww||T**D/++CHHTN;D
 KK4(77<<.. ''++B/#KK4(77<<..+   !KK48,R! $s   C4 4"DDc                 v   US:w  af  [         R                  R                  U5      (       d  [        SU S35      e[         R                  R	                  U5      (       d  [        SU S35      eU(       aF  [         R                  R                  US5      n[         R                  R                  U5      (       a  U$ g )NrO   zpackage directory 'z' does not existzsupposed package directory 'z ' exists, but is not a directoryz__init__.py)rA   r1   existsr   isdirrB   rT   )r   r   r   init_pys       r   check_packagebuild_py.check_package   s    
 "77>>+..()+6FG  77==--(2;- @- -  ggll;>Gww~~g&& r"   c                 |    [         R                  R                  U5      (       d  [        R                  " SX!5        gg)Nz!file %s (for module %s) not foundFT)rA   r1   rT   r   warning)r   modulemodule_files      r   check_modulebuild_py.check_module   s*    ww~~k**KK;[Qr"   c                 L   U R                  X5        [        R                  " [        R                  R	                  [        R
                  " U5      S5      5      n/ n[        R                  R                  U R                  R                  5      nU H  n[        R                  R                  U5      nXu:w  aT  [        R                  R                  [        R                  R                  U5      5      S   nUR                  XU45        M{  U R                  SU 35        M     U$ )Nz*.pyr   z
excluding )rp   rQ   rA   r1   rB   rR   abspathr'   script_namesplitextbasenamerF   debug_print)	r   r   r   module_filesmodulessetup_scriptr   abs_frt   s	            r   find_package_modulesbuild_py.find_package_modules   s    70yydkk+.F!OPwwt'8'8'D'DEAGGOOA&E$))"''*:*:1*=>qA34  :l^!<=  r"   c                    0 n/ nU R                    H  nUR                  S5      nSR                  USS 5      nUS   n X   u  pxU(       d2  U R                  XW5      n	US4X'   U	(       a  UR                  USU	45        [        R                  R                  XvS-   5      n
U R                  X:5      (       d  M  UR                  XVU
45        M     U$ ! [         a    U R	                  U5      nSn Nf = f)a  Finds individually-specified Python modules, ie. those listed by
module name in 'self.py_modules'.  Returns a list of tuples (package,
module_base, filename): 'package' is a tuple of the path through
package-space to the module; 'module_base' is the bare (no
packages, no dots) module name, and 'filename' is the path to the
".py" file (relative to the distribution root) that implements the
module.
r>   r   rf   Fr?   __init__.py)
r   rC   rB   rh   r@   rp   rF   rA   r1   rv   )r   r(   r   rt   r1   r   module_baser   checkedro   ru   s              r   find_modulesbuild_py.find_modules   s       ooF<<$DhhtAbz*Gr(K )1):&
 ,,WB%0!$4!NNGZ#AB
 '',,{%4GHK$$V99NNG+>?1 &4 '   "227; s   CC10C1c                    / nU R                   (       a  UR                  U R                  5       5        U R                  (       aF  U R                   H6  nU R	                  U5      nU R                  X#5      nUR                  U5        M8     U$ )a  Compute the list of all modules that will be built, whether
they are specified one-module-at-a-time ('self.py_modules') or
by whole packages ('self.packages').  Return a list of tuples
(package, module, module_file), just like 'find_modules()' and
'find_package_modules()' do.)r   rS   r   r(   r@   r   )r   r   r   r   ms        r   find_all_modulesbuild_py.find_all_modules  sm     ??NN4,,./===="227;--gCq! ) r"   c                 R    U R                  5        Vs/ s H  oS   PM	     sn$ s  snf )Nrf   )r   )r   rt   s     r   get_source_filesbuild_py.get_source_files/  s'    )-)>)>)@A)@vr
)@AAAs   $c                 h    U/[        U5      -   US-   /-   n[        R                  R                  " U6 $ )Nr   )listrA   r1   rB   )r   rI   r   rt   outfile_paths        r   get_module_outfilebuild_py.get_module_outfile2  s1    !{T']2fun5EEww||\**r"   r5   c                    U R                  5       n/ nU H  u  pEnUR                  S5      nU R                  U R                  XE5      nUR	                  U5        U(       d  MM  U R
                  (       a-  UR	                  [        R                  R                  USS95        U R                  S:  d  M  UR	                  [        R                  R                  XpR                  S95        M     UU R                   VVV	V
Vs/ s H/  u  pHpU
  H"  n[        R                  R                  X5      PM$     M1     snn
n	nn-  nU$ s  snn
n	nnf )Nr>   rO   )optimizationr   )r   rC   r   r   rF   r   	importlibutilcache_from_sourcer   r+   rA   r1   rB   )r   r5   r   outputsr   rt   _module_filerb   rH   rI   rL   s              r   r:   build_py.get_outputs6  s   '')-4)G\mmC(G..t~~wOHNN8$<<NN!88PR8S ==1$NN!88$== 9  .5  	:>//
:I6)% GGLL-% .:I
 	
 
s   ?6E c                 T   [        U[        5      (       a  UR                  S5      nO&[        U[        [        45      (       d  [        S5      eU R                  U R                  X15      n[        R                  R                  U5      nU R                  U5        U R                  X$SS9$ )Nr>   z:'package' must be a string (dot-separated), list, or tupleFr\   )r,   strrC   r   tuple	TypeErrorr   r   rA   r1   r_   r^   r`   )r   rt   ru   r   outfiledirs         r   build_modulebuild_py.build_moduleQ  s    gs##mmC(GGdE]33L  ))$..'Jggoog&C~~k%~HHr"   c                 `    U R                  5       nU H  u  p#nU R                  X4U5        M     g N)r   r   )r   r   r   rt   ru   s        r   r6   build_py.build_modulesa  s1    ##%,3(G[
 f7; -4r"   c                     U R                    HJ  nU R                  U5      nU R                  X5      nU H  u  pEnX:X  d   eU R                  XVU5        M!     ML     g r   )r(   r@   r   r   )r   r   r   r   package_rt   ru   s          r   r7   build_py.build_packagesj  s_    }}G ..w7K//EG 29-+***!!&w? 29 %r"   c                    [         R                  (       a  U R                  S5        g SSKJn  U R
                  nUS   [        R                  :w  a  U[        R                  -   nU R                  (       a  U" USU R                  X0R                  S9  U R                  S:  a)  U" UU R                  U R                  UU R                  S9  g g )Nz%byte-compiling is disabled, skipping.r   )r9   rf   r   )r   r   prefixdry_run)sysdont_write_bytecodewarnr   r9   r   rA   sepr   r   r   r   )r   rV   r9   r   s       r   r9   build_py.byte_compile~  s    ""II=>'":bff_F
 <<FLL ==1jj r"   )
r   r   r+   r   r   r   r   r   r(   r   )r#   N)T)"__name__
__module____qualname____firstlineno__descriptionuser_optionsr   r   r   r   __annotations__r   dictr    r2   r;   r*   rE   r8   r@   rp   rv   r   r   r   r   r   boolr:   r   r6   r7   r9   __static_attributes__ r"   r   r   r      s    KKL -6w+?OXd3i(?.:I-FL(4S>*FJ2D<,%N42h B+D DI 6I <@(r"   r   )__doc__rQ   importlib.utilr   rA   r   distutils._logr   typingr   corer   errorsr   r   r   r	   r   r   r"   r   <module>r      s5   0   	 
    = Fw Fr"   