
    n&phs'                        S SK Jr  S SKrS SKrS SKJr  S SKrS SKJ	r	  S SK
Jr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s  Jr  S SKJr  S\R8                  ;   r " S S5      r " S S5      rS r g)    )annotationsN)cache_from_source)path)	build_extget_abi3_suffix)Distribution)CompileError)	Extension   )environment)DALS)get_config_var__pypy__c                  8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
TestBuildExt   c                    [        5       n[        U5      nSUR                  S'   UR                  S5      n[        R                  R                  US5      nX4:X  d   eg)ze
Setuptools needs to give back the same
result as distutils, even if the fullname
is not in ext_map.
 zfoo/barfooN)r   r   ext_mapget_ext_filenameorig)selfdistcmdreswanteds        R/var/www/html/venv/lib/python3.13/site-packages/setuptools/tests/test_build_ext.pytest_get_ext_filename"TestBuildExt.test_get_ext_filename   sR     ~o!#I""5)00e<}}    c                   [        [        5       5        [        SS/SS9n[        [	        U/S95      n[        U5      nUR                  5         SUR                  ;   d   eUR                  S5      n[        5       (       d"  UR                  [        S5      5      (       d   eg
[        R                  S:X  a  UR                  S5      (       d   eg
S	U;   d   eg
)ze
Filename needs to be loadable by several versions
of Python 3 if 'is_abi3' is truthy on Extension()
	spam.eggseggs.cTpy_limited_apiext_modules
EXT_SUFFIXwin32zeggs.pydabi3N)printr   r
   r   dictr   finalize_optionsr   r   endswithr   sysplatform)r   	extensionr   r   r   s        r   test_abi3_filenameTestBuildExt.test_abi3_filename&   s    
 	o kH:dK	Di[9:ockk)))"";/  <<| <====\\W$<<
++++S= =r!   c                   [        5       n[        U5      n[        SS/SS9=UR                  S'   nSUl        [
        (       d  UR                  S5      nOSn S[        R                  S'   UR                  S	5      nS
U:X  d   eUR                  S5      nXE:X  d   e [        R                  S	 g! [        R                  S	 f = f)zL
SETUPTOOLS_EXT_SUFFIX variable always overrides
default extension options.
for_abi3zs.cTr%   Fzfor_abi3.test-suffixz.test-suffixSETUPTOOLS_EXT_SUFFIXnormalznormal.test-suffixN)	r   r   r
   r   _links_to_dynamicIS_PYPYr   osenviron)r   r   r   extexpectr   s         r   test_ext_suffix_override%TestBuildExt.test_ext_suffix_override;   s    
 ~o(1G	)
 	
J# !&w))*5F ,F	42@BJJ./&&x0C'3...&&z2C= =

23

23s   AB/ /Cc                    SSSS000SSS00S.n[        SS	/5      n[        S
S/5      n[        SS/5      n[        R                  " U5        [        SX#U/SS0S.5      $ )Nmypkgsubpkgzext2.cr   ext1zmain.c)srczc-extensionsz
mypkg.ext1zc-extensions/ext1/main.czmypkg.subpkg.ext2zsrc/mypkg/subpkg/ext2.cext3zc-extension/ext3.cz%test%rE   )script_namer(   package_dir)r
   r   buildr   )r   filesrD   ext2rF   s        r   dist_with_exampleTestBuildExt.dist_with_example[   s    h278#h^4

 (B'CD,/H.IJ"6!78

5# -;
  	r!   c           	     Z   UR                  SS5        UR                  SS5        U R                  5       nUR                  S5      nSUl        UR
                  " 5         UR                  R                  [        R                  S5      nUR                  " 5        Vs/ s H"  ofR                  [        R                  S5      PM$     nnUU S3U S3U S	3/:X  d   eUR                  " 5       0 :X  d   eUR                  S5        S
Ul        UR
                  " 5         UR                  " 5       R                  5        VV	s0 s HD  u  pUR                  [        R                  S5      U	R                  [        R                  S5      _MF     n
nn	U
U S3SU S3SU S	3S0:X  d   eg s  snf s  sn	nf )Nr7   .mp3&setuptools.command.build_ext.use_stubsFr   /	/ext3.mp3/mypkg/ext1.mp3/mypkg/subpkg/ext2.mp3Tsrc/ext3.mp3src/mypkg/ext1.mp3src/mypkg/subpkg/ext2.mp3)setenvsetattrrL   get_command_objeditable_modeensure_finalized	build_libreplacer;   sepget_outputsget_output_mappingreinitialize_commanditems)r   
tmpdir_cwdmonkeypatchr   r   r]   xoutputskvmappings              r   test_get_outputsTestBuildExt.test_get_outputsl   s   2F;DeL%%' ((5	"'	""$''//<	3<3H3H3JK3Ja99RVVS)3JKk#k)k/0
 
 	
 

 ++-333 	!!+."&	""$ "446<<>
> IIbffc"AIIbffc$::> 	 
 k#^k)+?k/02M
 
 	
 
! L
s   )F"<AF'c                   UR                  SS5        UR                  SS5        U R                  5       nUR                  S5      nSUl        UR
                  " 5         UR                   H  nUR                  USS5        M     UR                  R                  [        R                  S5      nUR                  " 5       R                  5        VVs0 s HD  u  pxUR                  [        R                  S5      UR                  [        R                  S5      _MF     n	nnS n
U	U
" U S	35      U
" S
5      U S3SU
" U S35      U
" S5      U S3SU
" U S35      U
" S5      U S3S0:X  d   eU S3U	;  d   eU S3U	;  d   eU
" U S35      nX;   d   eUR                  U S35      (       d   eUR                  S5      (       d   eg s  snnf )Nr7   rO   rP   Tr   _needs_stubrQ   c                T    [        U 5      R                  [        R                  S5      $ )zDMake it possible to do comparisons and tests in a OS-independent wayrQ   )_compiled_file_namer^   r;   r_   )files    r   C9TestBuildExt.test_get_output_mapping_with_stub.<locals>.C   s    &t,44RVVSAAr!   z/ext3.pyzsrc/ext3.pyrR   rU   z/mypkg/ext1.pyzsrc/mypkg/ext1.pyrS   rV   z/mypkg/subpkg/ext2.pyzsrc/mypkg/subpkg/ext2.pyrT   rW   z/mypkg/__pycache__/ext1z.pyc)rX   rY   rL   rZ   r[   r\   
extensionsr]   r^   r;   r_   ra   rc   
startswithr/   )r   rd   re   r   r   r=   r]   rh   ri   rj   rr   example_stubs               r   !test_get_output_mapping_with_stub.TestBuildExt.test_get_output_mapping_with_stub   s   2F;DdK%%' ((5	"&	""$''C]D9 ( ''//<	 "446<<>
> IIbffc"AIIbffc$::> 	 

	B 8$%q'7k#^>*+Q/B-Ck)+?012A6P4Qk/02M
 
 	
 
 N+7:::12'AAA I;n56&&&&&)4K'LMMMM$$V,,,,5
s   AG N)__name__
__module____qualname____firstlineno__r   r3   r?   rL   rk   rw   __static_attributes__ry   r!   r   r   r      s"    !*4@"
@'-r!   r   c                  0    \ rS rSrSS jrS rS rS rSrg)	TestBuildExtInplace   c                    S0 0 S.S.n[         R                  " U5        [        SS/US9n[        [	        U/S95      nSUl        [        U5      n[        U5      R                  " SS	S
S.UD6  UR                  5         U$ )Nz#include missingheader.h
)libtmp)r$   z.buildr#   r$   )optionalr'   setup.pyz
.build/libz
.build/tmp)r]   
build_tempry   )
r   rI   r
   r   r-   rG   r   varsupdater\   )r   r   optsrJ   r2   r   r   s          r   get_build_ext_cmd%TestBuildExtInplace.get_build_ext_cmd   s    2 ,=
 	

5kH:I	Di[9:%oS	Q<LQDQ
r!   c                    UR                  5       nUR                  R                  5       UR                  R                  5       -   UR                  -   $ )z
Historically, distutils "logged" by printing to sys.std*.
Later versions adopted the logging framework. Grab
messages regardless of how they were captured.
)
readouterrout
splitlineserrmessages)r   caplogcapsysstds       r   get_log_messages$TestBuildExtInplace.get_log_messages   s@     !ww!!#cgg&8&8&::V__LLr!   c                    U R                  SSS9nUR                  5         [        S U R                  X#5       5       5      (       d   eg)zj
If optional extensions fail to build, setuptools should show the error
in the logs but not fail to build
Tr   inplacec              3  &   #    U  H  nS v   M	     g7f)z0build_ext: building extension "spam.eggs" failedNry   ).0msgs     r   	<genexpr>4TestBuildExtInplace.test_optional.<locals>.<genexpr>   s      
< ?<s   N)r   runanyr   )r   rd   r   r   r   s        r   test_optional!TestBuildExtInplace.test_optional   sQ    
 $$dD$A	 
,,V<
 
 
 	
 
r!   c                    U R                  SSS9n[        R                  " [        5         UR	                  5         S S S 5        g ! , (       d  f       g = f)NFTr   )r   pytestraisesr	   r   )r   rd   r   s      r   test_non_optional%TestBuildExtInplace.test_non_optional   s8    $$eT$B]]<(GGI )((s   A
Ary   N)r   boolreturnr   )	rz   r{   r|   r}   r   r   r   r   r~   ry   r!   r   r   r      s    M

r!   r   c                    [        S5      [        S5      [        S5      S.n[        R                  " U5        [        R                  " S/SS9u  nu  p4US:X  d   S	U S
U 35       eg )Nz
            from setuptools import Extension, setup
            setup(
                name='foo',
                version='0.0.0',
                ext_modules=[Extension('foo', ['foo.c'])],
            )
            a  
            #include "Python.h"

            #if PY_MAJOR_VERSION >= 3

            static struct PyModuleDef moduledef = {
                    PyModuleDef_HEAD_INIT,
                    "foo",
                    NULL,
                    0,
                    NULL,
                    NULL,
                    NULL,
                    NULL,
                    NULL
            };

            #define INITERROR return NULL

            PyMODINIT_FUNC PyInit_foo(void)

            #else

            #define INITERROR return

            void initfoo(void)

            #endif
            {
            #if PY_MAJOR_VERSION >= 3
                PyObject *module = PyModule_Create(&moduledef);
            #else
                PyObject *module = Py_InitModule("extension", NULL);
            #endif
                if (module == NULL)
                    INITERROR;
            #if PY_MAJOR_VERSION >= 3
                return module;
            #endif
            }
            zD
            [build]
            build_base = foo_build
            )r   zfoo.cz	setup.cfgrI   )r      )r   data_streamr   z	
STDOUT:
z	
STDERR:
)r   r   rI   r   run_setup_py)rd   rJ   codestdoutstderrs        r   test_build_ext_config_handlingr      s    	
 (*
V 
m<Ez 	JJu(55ID
6 19?F8;vh??9r!   )!
__future__r   r;   r0   importlib.utilr   rp   r   jaracor   setuptools.command.build_extr   r   setuptools.distr   setuptools.errorsr	   setuptools.extensionr
   r   r   textwrapr   distutils.command.build_extcommandr   distutils.sysconfigr   builtin_module_namesr:   r   r   r   ry   r!   r   <module>r      sa    " 	 
 C   C ( * *   * * .
00
0[- [-|) )XC@r!   