
    vKg2                        S r SSKJ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S.r " S S\5      rSS jrg)a  distutils.command.config

Implements the Distutils 'config' command, a (mostly) empty command class
that exists mainly to be sub-classed by specific module distributions and
applications.  The idea is that while every "config" command is different,
at least they're all named the same, and users always see "config" in the
list of standard commands.  Also, this is a good place to put common
configure-like tasks: "try to compile this C code", or "figure out where
this header file lives".
    )annotationsN)Sequence)log   )Command)DistutilsExecError)customize_compilerz.cz.cxx)czc++c                      \ rS rSrSr/ SQrS rS rS rS r	S r
S	 rS
 rS rS rSS jrSS jrSS jr     SS jr     SS jr      SS jrSSS/ 4 SS jjrSS jrSrg)config   zprepare to build)	)z	compiler=Nzspecify the compiler type)zcc=Nzspecify the compiler executable)zinclude-dirs=Iz.list of directories to search for header files)zdefine=DzC preprocessor macros to define)zundef=Uz!C preprocessor macros to undefine)z
libraries=lz!external C libraries to link with)zlibrary-dirs=Lz.directories to search for external C libraries)noisyNz1show every action (compile, link, run, ...) taken)zdump-sourceNz=dump generated source files before attempting to compile themc                t    S U l         S U l        S U l        S U l        S U l        SU l        SU l        / U l        g )N   )compilerccinclude_dirs	librarieslibrary_dirsr   dump_source
temp_filesselfs    d/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/setuptools/_distutils/command/config.pyinitialize_optionsconfig.initialize_options1   sA       
     c                T   U R                   c%  U R                  R                   =(       d    / U l         OM[        U R                   [        5      (       a.  U R                   R	                  [
        R                  5      U l         U R                  c  / U l        O1[        U R                  [        5      (       a  U R                  /U l        U R                  c  / U l        g [        U R                  [        5      (       a/  U R                  R	                  [
        R                  5      U l        g g N)	r   distribution
isinstancestrsplitospathsepr   r   r   s    r   finalize_optionsconfig.finalize_options@   s    $ $ 1 1 > > D"D))3// $ 1 1 7 7

 CD>>!DN,,"nn-DN$ "D))3// $ 1 1 7 7

 CD 0r"   c                    g r$    r   s    r   run
config.runP   s    r"   c                   SSK JnJn  [        U R                  U5      (       d  U" U R                  U R
                  SS9U l        [        U R                  5        U R                  (       a%  U R                  R                  U R                  5        U R                  (       a%  U R                  R                  U R                  5        U R                  (       a&  U R                  R                  U R                  5        ggg)zNCheck that 'self.compiler' really is a CCompiler object;
if not, make it one.
r   )	CCompilernew_compilerT)r   dry_runforceN)	ccompilerr2   r3   r&   r   r4   r	   r   set_include_dirsr   set_librariesr   set_library_dirs)r   r2   r3   s      r   _check_compilerconfig._check_compilerW   s     	8$--33(DDM t}}-  ..t/@/@A~~++DNN;  ..t/@/@A ! 4r"   c                ,   S[         U   -   n[        USSS9 nU(       a/  U H  nUR                  SU S35        M     UR                  S5        UR                  U5        US   S:w  a  UR                  S5        S S S 5        U$ ! , (       d  f       U$ = f)	N_configtestwutf-8encodingz
#include <z>

)LANG_EXTopenwrite)r   bodyheaderslangfilenamefileheaders          r   _gen_temp_sourcefileconfig._gen_temp_sourcefilek   s     8D>1(C'2d%FJJF8378 &

4 JJtBx4

4  3  32 s   A"B
Bc                    U R                  XU5      nSnU R                  R                  XV/5        U R                  R	                  XVUS9  XV4$ )Nz_configtest.ir   )rM   r   extendr   
preprocess)r   rG   rH   r   rI   srcouts          r   _preprocessconfig._preprocessw   sL    ''t<z*   Ezr"   c                   U R                  XU5      nU R                  (       a  [        USU S35        U R                  R	                  U/5      u  nU R
                  R                  XV/5        U R                  R                  U/US9  XV4$ )Nzcompiling 'z':rP   )rM   r   	dump_filer   object_filenamesr   rQ   compile)r   rG   rH   r   rI   rS   objs          r   _compileconfig._compile~   s}    ''t<c[R01//6z*se,?zr"   c                   U R                  XX65      u  px[        R                  R                  [        R                  R	                  U5      5      S   n	U R
                  R                  U/U	UUUS9  U R
                  R                  b  XR
                  R                  -   n	U R                  R                  U	5        XxU	4$ )Nr   )r   r   target_lang)
r\   r)   pathsplitextbasenamer   link_executableexe_extensionr   append)
r   rG   rH   r   r   r   rI   rS   r[   progs
             r   _linkconfig._link   s    ]]4,E
ww 0 0 56q9%%E% 	& 	
 ==&&2--555Dt$$r"   c                    U(       d  U R                   n/ U l         [        R                  " SSR                  U5      5        U H  n [        R
                  " U5        M     g ! [         a     M,  f = f)Nzremoving: %s )r   r   infojoinr)   removeOSError)r   	filenamesrJ   s      r   _cleanconfig._clean   s[    I DO)!45!H		(# "  s   A""
A0/A0Nc                    SSK Jn  U R                  5         Sn U R                  XX45        U R	                  5         U$ ! U a    Sn Nf = f)a)  Construct a source file from 'body' (a string containing lines
of C/C++ code) and 'headers' (a list of header files to include)
and run it through the preprocessor.  Return true if the
preprocessor succeeded, false if there were any errors.
('body' probably isn't of much use, but what the heck.)
r   CompileErrorTF)r6   rt   r:   rU   rp   r   rG   rH   r   rI   rt   oks          r   try_cppconfig.try_cpp   sS     	-	TL? 			  	B	s   > A	A	c                8  ^ U R                  5         U R                  X#XE5      u  pg[        T[        5      (       a  [        R
                  " T5      m[        USS9 n[        U4S jU 5       5      n	SSS5        U R                  5         W	$ ! , (       d  f       N = f)a  Construct a source file (just like 'try_cpp()'), run it through
the preprocessor, and return true if any line of the output matches
'pattern'.  'pattern' should either be a compiled regex object or a
string containing a regex.  If both 'body' and 'headers' are None,
preprocesses an empty file -- which can be useful to determine the
symbols the preprocessor and compiler set by default.
r?   r@   c              3  D   >#    U H  nTR                  U5      v   M     g 7fr$   )search).0linepatterns     r   	<genexpr>$config.search_cpp.<locals>.<genexpr>   s     >t,,s    N)	r:   rU   r&   r'   rerZ   rE   anyrp   )
r   r~   rG   rH   r   rI   rS   rT   rK   matchs
    `        r   
search_cppconfig.search_cpp   sz     	##D<Fgs##jj)G#(D>>>E ) 		 )(s   B
Bc                    SSK Jn  U R                  5          U R                  XX45        Sn[        R
                  " U=(       a    S=(       d    S5        U R                  5         U$ ! U a    Sn NDf = f)zgTry to compile a source file built from 'body' and 'headers'.
Return true on success, false otherwise.
r   rs   TFsuccess!failure.)r6   rt   r:   r\   r   rk   rp   ru   s          r   try_compileconfig.try_compile   sg     	-	MM$<B 	"
0j1	  	B	s   A& &A10A1c                    SSK JnJn  U R                  5          U R	                  XX4XV5        Sn	[
        R                  " U	=(       a    S=(       d    S5        U R                  5         U	$ ! Xx4 a    Sn	 NEf = f)zTry to compile and link a source file, built from 'body' and
'headers', to executable form.  Return true on success, false
otherwise.
r   rt   	LinkErrorTFr   r   )r6   rt   r   r:   rg   r   rk   rp   )
r   rG   rH   r   r   r   rI   rt   r   rv   s
             r   try_linkconfig.try_link   sl     	8	JJtl|RB 	"
0j1	 ( 	B	s   A) )	A54A5c                $   SSK JnJn  U R                  5          U R	                  XX4XV5      u  pnU R                  U/5        Sn[        R                  " U=(       a    S=(       d    S5        U R                  5         U$ ! Xx[        4 a    Sn NJf = f)zTry to compile, link to an executable, and run a program
built from 'body' and 'headers'.  Return true on success, false
otherwise.
r   r   TFr   r   )
r6   rt   r   r:   rg   spawnr   r   rk   rp   )r   rG   rH   r   r   r   rI   rt   r   rS   r[   exerv   s                r   try_runconfig.try_run   s     	8	 JJ|MCc JJuB 	"
0j1	 );< 	B	s   *A> >BBc                T   U R                  5         / nU(       a  UR                  SU S35        UR                  S5        U(       a  UR                  SU S35        OUR                  SU S35        UR                  S5        SR                  U5      S-   nU R                  XX4U5      $ )	a  Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.

The constructed source file starts out by including the header
files listed in 'headers'.  If 'decl' is true, it then declares
'func' (as "int func()"); you probably shouldn't supply 'headers'
and set 'decl' true in the same call, or you might get errors about
a conflicting declarations for 'func'.  Finally, the constructed
'main()' function either references 'func' or (if 'call' is true)
calls it.  'libraries' and 'library_dirs' are used when
linking.
zint z ();zint main () {z  z();;}rB   )r:   re   rl   r   )	r   funcrH   r   r   r   declcallrG   s	            r   
check_funcconfig.check_func   s    . 	KK$tfD)*O$KK"TF#'KK"TF!%Cyy%}}TL\RRr"   c           	     f    U R                  5         U R                  SUUU/[        U5      -   U5      $ )a  Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it.  'headers' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available.  Any libraries listed in
'other_libraries' will be included in the link, in case 'library'
has symbols that depend on other libraries.
zint main (void) { })r:   r   list)r   libraryr   rH   r   other_librariess         r   	check_libconfig.check_libE  s<      	}}!I_--
 	
r"   c                &    U R                  SU/US9$ )zDetermine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
z/* No body */)rG   rH   r   )rw   )r   rL   r   r   rI   s        r   check_headerconfig.check_header^  s#    
 || 6(  
 	
r"   )r   r   r   r   r   r   r   r   )NNNr
   )NNr
   )NNNNr
   )NNNNFF)r   zSequence[str])__name__
__module____qualname____firstlineno__descriptionuser_optionsr    r+   r/   r:   rM   rU   r\   rg   rp   rw   r   r   r   r   r   r   r   __static_attributes__r.   r"   r   r   r      s    $KL&D B(
 "	*&(( : H #SP )+
 '
2
r"   r   c                    Uc  [         R                  " SU 5        O[         R                  " U5        [         R                  " [        R                  " U 5      R	                  SS95        g)zbDumps a file content into log.info.

If head is not None, will be dumped before the file content.
Nz%sr?   r@   )r   rk   pathlibPath	read_text)rJ   heads     r   rX   rX   h  sE    
 |x HHW\\(#--w-?@r"   r$   )__doc__
__future__r   r)   r   r   collections.abcr   distutils._logr   corer   errorsr   	sysconfigr	   rD   r   rX   r.   r"   r   <module>r      sF   	 # 	  	 $   ' *f%J
W J
Z
	Ar"   