
    ,h8A                     ~    d 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 ddlmZ  G d	 d
e      Zy)zHdistutils.command.build_py

Implements the Distutils 'build_py' command.    N)log)ClassVar   )Command)DistutilsFileErrorDistutilsOptionError)convert_pathc                       e Zd ZU dZg dZddgZeee      e	d<   ddiZ
eeeef      e	d<   d ZddZddZd Zd ZddZd Zd Zd Zd Zd Zd Zd Zd Zdded	ee   fdZd ZddZddZddZy
) build_pyz5"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    d | _         d | _        d | _        d | _        d | _        d| _        d| _        d | _        y )NFr   )	build_lib
py_modulespackagepackage_datapackage_dirr   optimizer   selfs    h/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/setuptools/_distutils/command/build_py.pyinitialize_optionszbuild_py.initialize_options$   s<     
    returnNc                    | j                  ddd       | j                  j                  | _        | j                  j                  | _        | j                  j                  | _        i | _        | j                  j
                  rD| j                  j
                  j                         D ]  \  }}t        |      | j
                  |<    | j                         | _	        t        | j                  t              s6	 t        | j                        | _        d| j                  cxk  rdk  sJ  J y y # t        t        f$ r t        d      w xY w)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_optionszbuild_py.finalize_options.   s%   ""/1C	
 ))22++66 --::(("//;;AAC <
d)5d);  &<--/ $---J #DMM 2DMM.Q..... . / J*+HIIJs   64D, ,Ec                     | j                   r| j                          | j                  r | j                          | j	                          | j                  | j                  d             y )NF)include_bytecode)r   build_modulesr&   build_packagesbuild_package_databyte_compileget_outputsr   s    r   runzbuild_py.runG   sR    , ?? ==!##%$**E*BCr    c                 x   g }| j                   s|S | j                   D ]  }| j                  |      }t        j                  j                  | j
                  g|j                  d      z    }d}|rt        |      dz   }| j                  ||      D cg c]  }||d 	 }}|j                  ||||f        |S c c}w )z?Generate list of '(package,src_dir,build_dir,filenames)' tuples.r      N)
r&   get_package_dirosr/   joinr   splitlenfind_data_filesappend)r   datar   src_dir	build_dirplenfile	filenamess           r   r(   zbuild_py.get_data_filese   s    }}K}} 	BG**73G '7'--:L'LNI D7|a' 261E1Egw1WXdeXIXKK'9i@A	B  Ys   B7c           	         | j                   j                  dg       | j                   j                  |g       z   }g }|D ]  }t        j                  t        j                  j                  t        j                  |      t        |                  }|j                  |D cg c])  }||vst        j                  j                  |      s(|+ c}        |S c c}w )z6Return filenames for package's data files in 'src_dir' )
r   getglobr=   r/   r>   escaper	   extendisfile)r   r   rD   globsfilespatternfilelistfns           r   rA   zbuild_py.find_data_files{   s    !!%%b"-0A0A0E0Egr0RR 	GyyT[[1<3HIH LL%5RWW^^B=O 	 s   	C
)C
	C
c                 >   | j                   D ]  \  }}}}|D ]  }t        j                  j                  ||      }| j	                  t        j                  j                  |             | j                  t        j                  j                  ||      |d         y)z$Copy data files into build directoryFpreserve_modeN)r)   r=   r/   r>   mkpathdirname	copy_file)r   _packagerD   rE   rH   filenametargets          r   r5   zbuild_py.build_package_data   s    7; 	3Hgy)% i:BGGOOF34GGLL(3V5  	r    c                    |j                  d      }| j                  s|rt        j                  j                  | S yg }|rM	 | j                  dj	                  |         }|j                  d|       t        j                  j                  | S | j                  j                  d      }||j                  d|       |rt        j                  j                  | S y# t        $ r |j                  d|d          |d= Y nw xY w|rŌy)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:   rJ   r   )r?   r   r=   r/   r>   insertKeyErrorrK   )r   r   r/   tailpdirs        r   r<   zbuild_py.get_package_dir   s     }}S!ww||T**D/++CHHTN;D
 KK4(77<<.. ''++B/#KK4(77<<..+   !KK48,R! s   C !D ?D c                 L   |dk7  r\t         j                  j                  |      st        d| d      t         j                  j	                  |      st        d| d      |rAt         j                  j                  |d      }t         j                  j                  |      r|S y )NrJ   zpackage directory 'z' does not existzsupposed package directory 'z ' exists, but is not a directoryz__init__.py)r=   r/   existsr   isdirr>   rO   )r   r   r   init_pys       r   check_packagezbuild_py.check_package   s    
 "77>>+.()+6FG  77==-(2;- @- -  ggll;>Gww~~g& r    c                 r    t         j                  j                  |      st        j                  d||       yy)Nz!file %s (for module %s) not foundFT)r=   r/   rO   r   warning)r   modulemodule_files      r   check_modulezbuild_py.check_module   s)    ww~~k*KK;[&Qr    c                 F   | j                  ||       t        j                  t        j                  j	                  t        j
                  |      d            }g }t        j                  j                  | j                  j                        }|D ]  }t        j                  j                  |      }||k7  rTt        j                  j                  t        j                  j                  |            d   }|j                  |||f       {| j                  d|         |S )Nz*.pyr   z
excluding )rh   rL   r=   r/   r>   rM   abspathr%   script_namesplitextbasenamerB   debug_print)	r   r   r   module_filesmodulessetup_scriptr   abs_frk   s	            r   find_package_moduleszbuild_py.find_package_modules   s    7K0yydkk+.F!OPwwt'8'8'D'DE 	>AGGOOA&E$))"''*:*:1*=>qA34  :l^!<=	> r    c                    i }g }| j                   D ]  }|j                  d      }dj                  |dd       }|d   }	 ||   \  }}|s/| j                  ||      }	|df||<   |	r|j                  |d|	f       t        j                  j                  ||dz         }
| j                  ||
      s|j                  |||
f        |S # t        $ r | j	                  |      }d}Y w xY w)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   r_   Fr;   __init__.py)
r   r?   r>   ra   r<   rh   rB   r=   r/   rm   )r   r&   ru   rk   r/   r   module_baser   checkedrg   rl   s              r   find_moduleszbuild_py.find_modules   s      oo 	@F<<$DhhtAbz*Gr(K )1'):&g
 ,,WkB%0!$4!NNGZ#AB
 '',,{K%4GHK$$V[9NNG[+>?1	@4 '   "227; s   CC%$C%c                    g }| j                   r|j                  | j                                | j                  rE| j                  D ]6  }| j	                  |      }| j                  ||      }|j                  |       8 |S )a4  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   rN   r~   r&   r<   rx   )r   ru   r   r   ms        r   find_all_moduleszbuild_py.find_all_modules  st     ??NN4,,./==== ""227;--g{Cq!" r    c                 N    | j                         D cg c]  }|d   	 c}S c c}w )Nr_   )r   )r   rk   s     r   get_source_fileszbuild_py.get_source_files/  s#    )-)>)>)@Avr
AAAs   "c                 f    |gt        |      z   |dz   gz   }t        j                  j                  | S )Nr{   )listr=   r/   r>   )r   rE   r   rk   outfile_paths        r   get_module_outfilezbuild_py.get_module_outfile2  s1    !{T']2fun5EEww||\**r    r2   c                    | j                         }g }|D ]  \  }}}|j                  d      }| j                  | j                  ||      }|j	                  |       |sI| j
                  r0|j	                  t        j                  j                  |d             | j                  dkD  s|j	                  t        j                  j                  || j                                || j                  D 	
cg c].  \  }}}	}
|
D ]"  }t        j                  j                  |	|      $ 0 c}}
}	}}z  }|S c c}}
}	}}w )Nr:   rJ   )optimizationr   )r   r?   r   r   rB   r   	importlibutilcache_from_sourcer   r)   r=   r/   r>   )r   r2   ru   outputsr   rk   _module_filer\   rD   rE   rH   s              r   r7   zbuild_py.get_outputs6  s(   '')-4 	)GV\mmC(G..t~~wOHNN8$<<NN!88PR8S ==1$NN!88$4== 9 	  	:>//
 
6)Y%
  GGLLH-
-
 	
 
s   93D7c                 J   t        |t              r|j                  d      }n!t        |t        t        f      st        d      | j                  | j                  ||      }t        j                  j                  |      }| j                  |       | j                  ||d      S )Nr:   z:'package' must be a string (dot-separated), list, or tupleFrV   )r*   strr?   r   tuple	TypeErrorr   r   r=   r/   rY   rX   rZ   )r   rk   rl   r   outfiledirs         r   build_modulezbuild_py.build_moduleQ  s    gs#mmC(GGdE]3L  ))$..'6Jggoog&C~~k7%~HHr    c                 `    | j                         }|D ]  \  }}}| j                  |||        y N)r~   r   )r   ru   r   rk   rl   s        r   r3   zbuild_py.build_modulesa  s:    ##%,3 	<(GV[
 fk7;	<r    c                     | j                   D ]J  }| j                  |      }| j                  ||      }|D ]   \  }}}||k(  sJ | j                  |||       " L y r   )r&   r<   rx   r   )r   r   r   ru   package_rk   rl   s          r   r4   zbuild_py.build_packagesj  sr    }} 	@G ..w7K//EG 29 @-&+(**!!&+w?@	@r    c                    t         j                  r| j                  d       y ddlm} | j
                  }|d   t        j                  k7  r|t        j                  z   }| j                  r! ||d| j                  || j                         | j                  dkD  r, ||| j                  | j                  || j                         y y )Nz%byte-compiling is disabled, skipping.r   )r6   r_   r   )r   r   prefixdry_run)sysdont_write_bytecodewarnr   r6   r   r=   sepr   r   r   r   )r   rQ   r6   r   s       r   r6   zbuild_py.byte_compile~  s    ""II=>'":bff_F
 <<FDLL ==1jj r    )r!   N)T) __name__
__module____qualname__descriptionuser_optionsr   r   r   r   __annotations__r   dictr   r0   r8   r(   rA   r5   r<   rh   rm   rx   r~   r   r   r   boolr7   r   r3   r4   r6    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__rL   importlib.utilr   r=   r   distutils._logr   typingr   corer   errorsr   r   r   r	   r   r   r    r   <module>r      s5   0   	 
    = Fw Fr    