
    njN                    :   S r SSKJr  SSKrSSKrSSK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  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JrJr  SSKJrJrJ r   \" \!5      r"S r#\SS j5       r$S r%S r&S r' " S S\RP                  5      r(g)a9  distutils.unixccompiler

Contains the UnixCCompiler class, a subclass of CCompiler that handles
the "typical" Unix-style command-line C compiler:
  * macros defined with -Dname[=value]
  * macros undefined with -Uname
  * include search directories specified with -Idir
  * libraries specified with -lllib
  * library search directories specified with -Ldir
  * compile handled by 'cc' (or similar) executable with -c option:
    compiles .c to .o
  * link static library handled by 'ar' command (possibly with 'ranlib')
  * link shared library handled by 'cc -shared'
    )annotationsN)Iterable)ClassVar)	pass_none   )newer)
get_loggermacos)compiler_fixup   )base)_Macrogen_lib_optionsgen_preprocess_options)CompileErrorLibError	LinkErrorc                     [         R                  " U 6 n[        XSS9 VVs/ s H  u  p#Ub  M
  UPM     nnnU(       a
   SU 35       eU$ s  snnf )NF)strictz Unexpected None in config vars: )	sysconfigget_config_varszip)namesvaluesnamevaluemissings        b/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/setuptools/_distutils/compilers/C/unix.py_require_config_varsr    )   s[    &&.F #E% @ @E @   D:7)DD;M	s
   	A
A
c                f    [         R                  R                  U S35      nU(       a  U  SU 3$ U $ )zCAppend any ``$<flag_type>FLAGS`` from the environment to ``value``.FLAGS )osenvironget)r   	flag_typeflagss      r   
_add_flagsr)   2   s5     JJNNi[./E!&eWAeW1E1    c                    Sn[         R                  R                  U S   5      S:X  a  SnSX   ;   a  US-  nSX   ;   a  M  U SU XS 4$ )z
For macOS, split command into 'env' portion (if any)
and the rest of the linker command.

>>> _split_env(['a', 'b', 'c'])
([], ['a', 'b', 'c'])
>>> _split_env(['/usr/bin/env', 'A=3', 'gcc'])
(['/usr/bin/env', 'A=3'], ['gcc'])
r   envr   =Nr$   pathbasenamecmdpivots     r   
_split_envr4   I   s]     E	wwA5(SZQJE SZv;F##r*   c                ^    [         R                  R                  U S   5      S:H  nU SU XS 4$ )z
AIX platforms prefix the compiler with the ld_so_aix
script, so split that from the linker command.

>>> _split_aix(['a', 'b', 'c'])
([], ['a', 'b', 'c'])
>>> _split_aix(['/bin/foo/ld_so_aix', 'gcc'])
(['/bin/foo/ld_so_aix'], ['gcc'])
r   	ld_so_aixNr.   r1   s     r   
_split_aixr7   [   s6     GGSV$3Ev;F##r*   c                :    [        U5      nU SU U:X  a  UOSnXS $ )a  
The linker command usually begins with the compiler
command (possibly multiple elements), followed by zero or more
params for shared library building.

If the LDSHARED env variable overrides the linker command,
however, the commands may not match.

Return the best guess of the linker parameters by stripping
the linker command. If the compiler command does not
match the linker command, assume the linker command is
just the first element.

>>> _linker_params('gcc foo bar'.split(), ['gcc'])
['foo', 'bar']
>>> _linker_params('gcc foo bar'.split(), ['other'])
['foo', 'bar']
>>> _linker_params('ccache gcc foo bar'.split(), 'ccache gcc'.split())
['foo', 'bar']
>>> _linker_params(['gcc'], ['gcc'])
[]
Nr   )len)
linker_cmdcompiler_cmdc_lenr3   s       r   _linker_paramsr=   i   s.    . E'<7EQEfr*   c                    ^  \ rS rSr% SrSrSS/S/S/S/SS/SS/S/SS/SS	/SS
.rS\S'   \R                  SS S:X  a  S/\S'   / SQr
S\S'   SrSrSrSrSrS=r=rr\r\R                  S:X  a  SrSrSrSrS+S jrU 4S jr     S,           S-S  jjrS! r S.S" jr          S/         S0S# jjrS$ rS% rS1S& jrS' r\S( 5       r S2S) jr!S*r"U =r#$ )3Compiler   unixzstandard UNIX-style compilerNccc++z-sharedarz-cr)preprocessorcompilercompiler_socompiler_cxxcompiler_so_cxx	linker_solinker_so_cxx
linker_exelinker_exe_cxxarchiverranlibzClassVar[dict]executables   darwinrO   )z.cz.Cz.ccz.cxxz.cppz.mzClassVar[list[str] | None]src_extensionsz.oz.az.soz.dylibz.tbdzlib%s%scygwinz.exez.dll.az.dllzcyg%s%sc                b   [         R                  " [        R                  " 5       5        [	        SSSSSSSSS	5	      u	  nnnnnnnnn	Un
S[
        R                  ;   aO  [
        R                  S   nS[
        R                  ;  a&  UR                  U5      (       a  X[        U5      S
 -   nUn[
        R                  R                  SU5      n[
        R                  R                  SU5      n[
        R                  R                  SU5      n[
        R                  R                  SUS-   5      n[        US5      n[        US5      n[
        R                  R                  SU5      n[        US5      n[
        R                  R                  SU
5      n
[        US5      n[        US5      n[        US5      n[        U
S5      n
[        US5      n[        US5      n[
        R                  R                  SU5      nUS-   [
        R                  R                  S	U	5      -   nUS-   U-   nUS-   U
-   nU R                  UUUS-   U-   UUS-   U-   UUUUUS9
  S[
        R                  ;   aA  U R                  R                  SS
5      (       a   U R                  [
        R                  S   S9  Xpl        g
)uC  Configure this compiler from the interpreter's build configuration.

Applies the compiler, flag, and archiver settings CPython recorded in
sysconfig when it was built -- honoring the usual environment-variable
overrides (CC, CXX, CFLAGS, LDSHARED, AR, RANLIB, …) -- so extensions
build consistently with the interpreter.
CCCXXCFLAGSCCSHAREDLDSHAREDLDCXXSHAREDSHLIB_SUFFIXARARFLAGSNCPPz -ELDCCXXFLAGSr#   )
rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   RANLIBrO   )rO   )r   customize_compilerr   r   r    r$   r%   
startswithr9   r&   r)   set_executablesrP   shared_lib_extension)selfrB   cxxcflagsccsharedldsharedldcxxsharedshlib_suffixrD   ar_flagscxxflagsnewcccpprN   cc_cmdcxx_cmds                   r   configure_systemCompiler.configure_system   su    	  !:!:!<= !


	
 2::JJt$E+0C0CB0G0G !CGI#66BjjnnUC(::>>*h7jjnn]K@jjnnUBJ/h- d3&1h,::>>*h7 e4e$FE*h.h. e4ZZ^^D"%8bjjnnYAAcF")h&x/ #cMH4% 	 	
 rzz!d&6&6&:&:8T&J&J  

8(< =$0!r*   c                   > [         TU ]  XU5      u  pn[        R                  " S5      nU(       a,  UR	                  S5      (       a  XC;   a  UR                  U5        XU4$ )z'Remove standard library path from rpathLIBDIRz/usr/lib)super_fix_lib_argsr   get_config_varre   remove)rh   	librarieslibrary_dirsruntime_library_dirslibdir	__class__s        r   rz   Compiler._fix_lib_args  sd    8=8M%99
5	!5 ))(3 !!*--/ ''/(<<<r*   c                L   U R                  S X45      nUu  pn[        X45      n	U R                  U	-   n
U(       a  U
R                  SU/5        U(       a  XZS S& U(       a  U
R                  U5        U
R	                  U5        U R
                  =(       d    US L =(       d    [        X5      nU(       d  g U(       a.  U R                  [        R                  R                  U5      5         U R                  U
5        g ! [        R                  [        4 a  n[        U5      eS nAff = f)N-or   )_fix_compile_argsr   rE   extendappendforcer   mkpathr$   r/   dirnamecall
subprocessCalledProcessErrorOSErrorr   )rh   sourceoutput_filemacrosinclude_dirsextra_preargsextra_postargs
fixed_args_ignorepp_optspp_args
preprocessmsgs                r   r   Compiler.preprocess  s     ++D&G
(2%(>##g-NND+./'BQKNN>*v ZZT;$#6T%:T
KK45	$IIg--w7 	$s##	$s   'C9 9D#DD#c                \   [        U R                  XE-   5      n[        U R                  XE-   5      n U R                  U5      S:X  a  U R	                  X-   USU/-   U-   5        g U R	                  Xt-   USU/-   U-   5        g ! [
        R                  [        4 a  n	[        U	5      eS n	A	ff = f)NrC   r   )	r   rG   rI   detect_languager   r   r   r   r   )
rh   objsrcextcc_argsr   r   rG   rI   r   s
             r   _compileCompiler._compile@  s    $T%5%5w7OP()=)=w?WX	$##C(E1		/3sD#6FFWX		+/3c2BB^ST--w7 	$s##	$s   1B $B B+B&&B+c                   U R                  X5      u  pU R                  X#S9nU R                  X5      (       a  U R                  [        R
                  R                  U5      5        U R                  U R                  U/-   U-   U R                  -   5        U R                  (       a!   U R                  U R                  U/-   5        g g [        R!                  SU5        g ! [        R                  [        4 a  n[        U5      eS nAff = f)N)
output_dirskipping %s (up-to-date))_fix_object_argslibrary_filename
_need_linkr   r$   r/   r   r   rN   objectsrO   r   r   r   r   logdebug)rh   r   output_libnamer   r   target_langoutput_filenamer   s           r   create_static_libCompiler.create_static_libK  s     #33GH///V??744KK89IIdmm&77'ADLLPQ {{(IIdkk_,==>  II0/B #55w? ("3-'(s   (C   D
:DD
c                   U R                  X$5      u  p$U R                  XVU5      nUu  pVn[        XXu5      n[        U[        [        S 5      45      (       d  [        S5      eUb  [        R                  R                  XC5      nU R                  X#5      (       Ga|  X R                  -   U-   SU/-   nU	(       a  S/US S& U
(       a  U
US S& U(       a  UR                  U5        U R                  [        R                  R                  U5      5         U[        R                   R"                  :H  nUS:H  nU(       a  U(       a  U R$                  O*U R&                  OU(       a  U R(                  OU R*                  S S  nU(       at  U R,                  (       ac  [/        U5      u  nn[1        U5      u  nn[/        U R,                  5      u  nn[/        U R$                  5      u  nn[3        UU5      nUU-   U-   U-   n[5        UU5      nU R7                  UU-   5        g [@        RC                  SU5        g ! [8        R:                  [<        4 a  n[?        U5      eS nAff = f)Nz%'output_dir' must be a string or Noner   z-gr   rC   r   )"r   rz   r   
isinstancestrtype	TypeErrorr$   r/   joinr   r   r   r   r   r   r?   
EXECUTABLErM   rL   rK   rJ   rH   r4   r7   r=   r   r   r   r   r   r   r   r   )rh   target_descr   r   r   r}   r~   r   export_symbolsr   r   r   
build_tempr   r   lib_optsld_argsbuilding_exe
target_cxxlinkerr,   	linker_neaix	linker_na_compiler_cxx_nelinker_exe_neparamsr   s                                r   linkCompiler.linkc  s     #33GH''	AUV
8B5	!5"47KW*sDJ&788CDD! ggll:GO??744,x74:QQG#f+~.KK89%  +dmm.F.FF(E1
 $ -7T((DOO0:$,,	 $"3"3%/%7NC%/	%:NC)3D4E4E)F&A'1$2E2E'F$A}+I}EF 3Y86AF'8		&7*+ II0/B 117; %n$%s   DH. .IIIc                    SU-   $ )N-L )rh   dirs     r   library_dir_optionCompiler.library_dir_option      czr*   c                    [         R                  " S5      n[        R                  R	                  [
        R                  " U5      S   5      nSU;   =(       d    SU;   $ )NrV   r   gcczg++)r   r{   r$   r/   r0   shlexsplit)rh   cc_varrF   s      r   _is_gccCompiler._is_gcc  sI    ))$/77##EKK$7$:; 5EX$55r*   c                   [         R                  S S S:X  aY  SSKJn  UR                  " 5       nU(       a6  UR	                  S5       Vs/ s H  n[        U5      PM     snSS/:  a  SU-   $ S	U-   $ [         R                  S S
 S:X  a  SU-   $ [         R                  S S S:X  a  U R                  5       (       a  SOSS	U-   /$ [        R                  " S5      S:X  a  SSU-   /$ SU-   $ s  snf )NrQ   rR   r   r
   .
      z-Wl,-rpath,r      freebsdz-Wl,-rpath=zhp-uxz-Wl,+sz+sGNULDyesz-Wl,--enable-new-dtagsz-Wl,-R)	sysplatformr   
target_verr   intr   r   r{   )rh   r   r   r   ns        r   runtime_library_dir_option#Compiler.runtime_library_dir_option  s     <<x'())+Jz/?/?/DE/D!s1v/DE"aP$s**cz!\\"1* 3&&\\"1( LLNNs
  ##G,5 )#  c>!+ Fs   	C(c                    SU-   $ )Nz-lr   )rh   libs     r   library_optionCompiler.library_option  r   r*   c                   [         R                  " S5      n[        R                  " SU5      n[        R
                  S:H  =(       aO    U=(       aF    U R                  S5      =(       d.    U R                  S5      =(       a    U R                  S5      (       + nU(       a2  [        R                  R                  UR                  S5      U SS 5      $ U $ )	a(  
macOS users can specify an alternate SDK using'-isysroot'.
Calculate the SDK root if it is specified.

Note that, as of Xcode 7, Apple SDKs may contain textual stub
libraries with .tbd extensions rather than the normal .dylib
shared libraries installed in /.  The Apple compiler tool
chain handles this transparently but it can cause problems
for programs that are being built with an SDK and searching
for specific libraries.  Callers of find_library_file need to
keep in mind that the base filename of the returned SDK library
file might have a different extension from that of the library
file installed on the running system, for example:
  /Applications/Xcode.app/Contents/Developer/Platforms/
      MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/
      usr/lib/libedit.tbd
vs
  /usr/lib/libedit.dylib
rX   z-isysroot\s*(\S+)rR   z/System/z/usr/z/usr/local/r   N)r   r{   researchr   r   re   r$   r/   r   group)r   rj   match
apply_roots       r   _library_rootCompiler._library_root  s    * ))(3		.7 LLH$  z* SNN7+QCNN=4Q0Q 	 9Crww||EKKNCG4KKr*   c                2  ^ ^ UU 4S jS 5       n[        T R                  U5      n[        R                  " [        R
                  R                  [        R                  " XT5      5      n[        [        R
                  R                  U5      n[        US5      $ )z
Second-guess the linker with not much hard
data to go on: GCC seems to prefer the shared library, so
assume that *all* Unix C compilers do,
ignoring even GCC's "-static" option.
c              3  D   >#    U  H  nTR                  TUS 9v   M     g7f))lib_typeN)r   ).0r   r   rh   s     r   	<genexpr>-Compiler.find_library_file.<locals>.<genexpr>  s(      
C !!#!5Cs    )dylib
xcode_stubsharedstaticN)mapr   	itertoolsstarmapr$   r/   r   productfilterexistsnext)rh   dirsr   r   	lib_namesrootssearchedfounds   ` `     r   find_library_fileCompiler.find_library_file  sn    
C
	
 D&&-$$RWW\\93D3DU3VWrww~~x0 E4  r*   )rg   )returnNone)NNNNN)r   zstr | os.PathLike[str]r   zstr | os.PathLike[str] | Noner   zlist[_Macro] | Noner   "list[str] | tuple[str, ...] | Noner   zlist[str] | Noner   zIterable[str] | None)NFN)
NNNNNFNNNN)
r   zlist[str] | tuple[str, ...]r   z
str | Noner}   r  r~   r  r   r  )r   r   r  zstr | list[str])F)$__name__
__module____qualname____firstlineno__compiler_typedescriptionrP   __annotations__r   r   rS   obj_extensionstatic_lib_extensionrg   dylib_lib_extensionxcode_stub_lib_extensionstatic_lib_formatshared_lib_formatdylib_lib_formatxcode_stub_lib_formatexe_extensionru   rz   r   r   r   r   r   r   r   r   staticmethodr   r	  __static_attributes____classcell__)r   s   @r   r?   r?      s   M0K Fv!7I&+f ),5M#K  ||BQ8#!)
H2N.  M "%?HHH),<,
||x'$$P1d=" 6:&*;?*./3#$&#$ 3#$ $	#$
 9#$ (#$ -#$J	$ RVC: "&8<;?CG>C ->C
 >C 6>C 9>C A>CH6
&"P  L  LD! !r*   r?   )r   r   r'   r   r  r   ))__doc__
__future__r   r   r$   r   r   r   r   r   collections.abcr   typingr   jaraco.functoolsr   	_modifiedr   loggingr	   r   r   platform.macosr    r   r   r   r   errorsr   r   r   r  r   r    r)   r4   r7   r=   r?   r   r*   r   <module>r+     s    #  	 	   
  $  &     +  A A 5 5 2 2,$$$8K!t}} K!r*   