Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/distutils/tests/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/distutils/tests/__pycache__/test_build_ext.cpython-39.pyc

a

��g�P�@s�ddlZddlZddlmZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZddlmZddlmZmZmZmZddlZdd	lmZdd
lmZdaGdd
�d
ee
ej�ZGdd�de�Zdd�Z e!dkr�e�"e!�dS)�N)�StringIO)�Distribution��	build_ext)�	sysconfig)�TempdirManager�LoggingSilencer�copy_xxmodule_c�fixup_build_ext)�	Extension)�CompileError�DistutilsPlatformError�DistutilsSetupError�UnknownFileError)�support)�assert_python_okFcs�eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Ze�ejdkd�dd ��Ze�ejdkd�d!d"��Ze�ejdkd�d#d$��Zd%d&�Z�ZS)'�BuildExtTestCasecsptt|���|��|_ddl}|j|_|��|_ddlm	}|j|_t
�|j�}|��|�
|jddd�dS�Nrr)�superr�setUp�mkdtemp�tmp_dir�site�	USER_BASE�
old_user_base�distutils.commandrr�
change_cwd�	__enter__�
addCleanup�__exit__)�selfrrr��	__class__��:/usr/local/lib/python3.9/distutils/tests/test_build_ext.pyrs

zBuildExtTestCase.setUpcs6ddl}|j|_ddlm}|j|_tt|���dSr)rrrrrrr�tearDown)r rrr!r#r$r%-s
zBuildExtTestCase.tearDowncOst|i|��S�Nr)r �args�kwargsr#r#r$r4szBuildExtTestCase.build_extcCs�t��}|dur|�d|�t|j�tj�|jd�}td|g�}t	d|gd��}|j|_
|�|�}t|�|j|_
|j|_tj}tjs�t�t_z|��|��W|t_n|t_0tr�|�dt�n
t|�jat�d|j�d��}td|�dS)	N�The %r command is not foundz
xxmodule.c�xx��nameZext_moduleszAlready tested in %sz
            tmp_dir = ai

            import sys
            import unittest
            from test import support

            sys.path.insert(0, tmp_dir)
            import xx

            class Tests(unittest.TestCase):
                def test_xx(self):
                    for attr in ('error', 'foo', 'new', 'roj'):
                        self.assertTrue(hasattr(xx, attr))

                    self.assertEqual(xx.foo(2, 5), 7)
                    self.assertEqual(xx.foo(13,15), 28)
                    self.assertEqual(xx.new().demo(), None)
                    if support.HAVE_DOCSTRINGS:
                        doc = 'This is a template module just for instruction.'
                        self.assertEqual(xx.__doc__, doc)
                    self.assertIsInstance(xx.Null(), xx.Null)
                    self.assertIsInstance(xx.Str(), xx.Str)


            unittest.main()
        z-c)r�missing_compiler_executable�skipTestr	r�os�path�joinrr�package_dirrr
�	build_lib�
build_temp�sys�stdout�verboser�ensure_finalized�run�ALREADY_TESTED�type�__name__�textwrap�dedentr)r �cmdZxx_cZxx_ext�dist�
old_stdout�coder#r#r$�test_build_ext7s4



�
zBuildExtTestCase.test_build_extc	Cs�tddi�}|�|�}tj}dt_ddlm}|�d�}d|d<z*|��W|t_|durb|d=q�||d<n |t_|dur�|d=n||d<0|�t	|j
�d�dS)Nr,r*Zsunosr)�_config_varsZPy_ENABLE_SHARED�)rrr5�platformZdistutils.sysconfigrD�getr8Z
assertGreater�len�library_dirs)r r@r?�oldrDZold_varr#r#r$�test_solaris_enable_sharedrs$



�
z+BuildExtTestCase.test_solaris_enable_sharedcCs�ddl}tddi�}|�|�}dd�|jD�}|�d|�d|_tj�|j	d�}tj�|j	d	�}t�
|�t�
|�|��|�||j�|�||j
�|�||j�dS)
Nrr,r*cSsg|]\}}}|�qSr#r#)�.0r,ZshortZlabler#r#r$�
<listcomp>��z3BuildExtTestCase.test_user_site.<locals>.<listcomp>�userrE�libZinclude)rrrZuser_options�assertInrOr/r0r1r�mkdirr8rI�rpath�include_dirs)r rr@r?�optionsrPZinclr#r#r$�test_user_site�s 
�

zBuildExtTestCase.test_user_sitecCs�tddgdd�g}td|d��}|�|�}|��|�ttf|j�tddgdd�g}td|d��}|�|�}|��|��dS)N�foo�xxxF�Zoptionalr*r+T)rrrr8�assertRaisesrrr9�r �modulesr@r?r#r#r$�test_optional_extension�s

�
z(BuildExtTestCase.test_optional_extensioncCs�tddgdd�g}td|d��}|�|�}|��t��}|�tjj	�D]}|�
||j�qHtjdd�}|�tjj	�D]}|�
||j�qv|�|�}d	|_|��|�
|jgd
��|�|�}dtj	|_|��|�
d|j�|�
d
|j�|�|�}dtj	|_|��|�
|jddg�t|�}d|_|��|�
|jgd��|�|�}d|_|��|�
|jddg�|�|�}d|_|��|�
|jddg�|�|�}d|_|��|�
|jg�|�|�}d|_|��|�
|jddg�dS)NrWrXFrYr*r+rE)Z
plat_specificzmy_lib, other_lib lastlib)Zmy_libZ	other_libZlastlibzmy_lib_dir%sother_lib_dirZ
my_lib_dirZ
other_lib_dirzone%stwo�one�twoz
one two,three)r^r_Zthreezone,two)r^�1)r_r`z1 2r`�2)rrr�finalize_optionsrZget_python_inc�splitr/r0�pathseprQrT�	libraries�assertEqualrIrSZlink_objectsZdefineZundefZ	swig_opts)r r\r@r?Z
py_include�pZplat_py_includer#r#r$�test_finalize_options�sV







z&BuildExtTestCase.test_finalize_optionscCs0t�}|�|�}|��|�t|jd�ddg}|�t|j|�dg}|�t|j|�dg}|�t|j|�ddgddd�fg}|�|�|d	}|�|t�|�|j	d�|�
t|d
��ddgddddgd�fg}|�t|j|�d
dg|d	dd<|�|�|�|d	jdg�|�|d	j
d
g�dS)NrW)�barrWri)zfoo-bar�)�foo.barrjrkrjri)�sourcesre�somerrm)r`ra�3)rlrerm�macros)r`ra)rnrErorn)rrrbrZrZcheck_extensions_listZassertIsInstancerrfreZassertFalse�hasattrZundef_macrosZ
define_macros)r r@r?Zexts�extr#r#r$�test_check_extensions_list�s8
��

�

z+BuildExtTestCase.test_check_extensions_listcCsHtddgdd�g}td|d��}|�|�}|��|�|��dg�dS)NrWrXFrYr*r+)rrrr8rfZget_source_filesr[r#r#r$�test_get_source_files,s

z&BuildExtTestCase.test_get_source_filescCs�tddgdd�tddgdd�g}td|d��}|�|�}|��|�|�|d	j�d
�|�|�|dj�d�|�|�|d	�d
g�|�|�|d�dg�dS)NrWZaaaFrYufööZuuur*r+rzfoo(_d)?\..*rEuföö(_d)?\..*Z
PyInit_fooZPyInitU_f_gkaa)	rrrr8ZassertRegexZget_ext_filenamer,rfZget_export_symbolsr[r#r#r$�test_unicode_module_names3s�
z*BuildExtTestCase.test_unicode_module_namescCs8t�}|�|�}d|_|��|��|�|jd�dS)NZunix)rr�compilerr8r9rf)r r@r?r#r#r$�test_compiler_option@s
z%BuildExtTestCase.test_compiler_optionc	Csdt��}|dur|�d|�|��}tj�|d�}|�|d�td|gdd�}t	d|gd��}|�
|�}t|�|��|�
t|���d	�tj�|jd
�|_tj�|jd�|_tj�|���}t��}t�|�z(d	|_|��|��d}Wt�|�nt�|�0|�tj�|��t�d
�}	|�|�|	��tj�|�}
|�
|
|�d|_d|_|��|��d}|�tj�|��|�|�|	��tj�|�}
|�
|
|j�|�d�}ddi|_ |�!d�}tj�"|�d}|�
||j�d	|_tj�|���}t��}t�|�z|�!d�}Wt�|�nt�|�0tj�"|�d}tj�"|�d}
|�
|
d�dS)Nr)zfoo.czvoid PyInit_foo(void) {}
rWFrYr*r+rEZbuildZtemptr�
EXT_SUFFIX�build_pyrjri���)#rr-r.rr/r0r1Z
write_filerrrr
r8rfrHZget_outputsrr3r4�realpath�getcwd�chdir�inplacer9Z
assertTrue�existsr�get_config_var�endswith�dirnameru�get_finalized_commandr2�get_ext_fullpathrc)r r?rZc_filerqr@Z
other_tmp_dirZold_wdZso_fileZ
ext_suffixZso_dirrxr0Zlastdirr#r#r$�test_get_outputsKsh�






z!BuildExtTestCase.test_get_outputscCs.t�d�}t�}|�|�}d|_ddi|j_ddg|j_t�	�}tj
�|ddd|�}|�d�}|�
||�d	|_tj
�|d
�|_tj
�|d
dd|�}|�d�}|�
||�|�d�}i|_dd
g|j_|�d
�}tj
�|d
ddd|�}|�
||�d|_|�d
�}tj
�|ddd|�}|�
||�dS)NrwrErj�srcZlxmlz	lxml.htmlZetreez
lxml.etreerZtmpdirrxZtwistedztwisted.runner.portmapZrunnerZportmap)rrrrr}Zdistributionr2Zpackagesr/r{r0r1r�rfr3r�)r rqr@r?�curdirZwantedr0rxr#r#r$�test_ext_fullpath�s6





�
z"BuildExtTestCase.test_ext_fullpath�darwinztest only relevant for MacOSXcCs|�dd�dS)Nz==)�_try_compile_deployment_target�r r#r#r$�test_deployment_target_default�sz/BuildExtTestCase.test_deployment_target_defaultcCs|�t|jdd�dS)N�>z10.1)rZr
r�r�r#r#r$�test_deployment_target_too_low�s�z/BuildExtTestCase.test_deployment_target_too_lowcCsVt�d�}|rRdd�|�d�D�}|dd7<d�dd�|D��}|�d	|�dS)
N�MACOSX_DEPLOYMENT_TARGETcSsg|]}t|��qSr#)�int)rL�xr#r#r$rM�rNzEBuildExtTestCase.test_deployment_target_higher_ok.<locals>.<listcomp>�.ryrEcss|]}t|�VqdSr&)�str)rL�ir#r#r$�	<genexpr>�rNzDBuildExtTestCase.test_deployment_target_higher_ok.<locals>.<genexpr>�<)rrrcr1r�)r �	deptargetr#r#r$� test_deployment_target_higher_ok�s
z1BuildExtTestCase.test_deployment_target_higher_okc
Cs�tj}|��t_|�ttd|�|dur>tj�d�rHtjd=n
|tjd<tj�|jd�}t	|d��$}|�
t�d|��Wd�n1s�0Yt
�d�}ttt|�d�dd���}|dd�d	kr�d
|}nt|�dkr�d|}nd|}td
|gd|fgd�}td
|gd��}|j|_|�|�}|j|_|j|_z>tj}	tj�sVt�t_z|��|� �W|	t_n|	t_0Wnt!�y�|�"d�Yn0dS)N�environr�zdeptargetmodule.c�wz�                #include <AvailabilityMacros.h>

                int dummy;

                #if TARGET %s MAC_OS_X_VERSION_MIN_REQUIRED
                #else
                #error "Unexpected target"
                #endif

            r�r�)�
r�z	%02d%01d0z
%02d%02d00z%02d0000r�z-DTARGET=%s)Zextra_compile_argsr+z*Wrong deployment target during compilation)#r/r��copyr�setattrrGr0r1r�open�writer=r>rr�tuple�mapr�rcrHrrr2rr3r4r5r6rr7rr8r9rZfail)
r �operator�targetZorig_environZdeptarget_c�fpZ
deptarget_extr@r?rAr#r#r$r��sT




�&



��

z/BuildExtTestCase._try_compile_deployment_target)r<�
__module__�__qualname__rr%rrCrKrVr]rhrrrsrtrvr�r��unittestZ
skipUnlessr5rFr�r�r�r��
__classcell__r#r#r!r$rs*;H0
B'


rcseZdZ�fdd�Z�ZS)�ParallelBuildExtTestCasecst�j|i|��}d|_|S)NT)rrZparallel)r r'r(rr!r#r$rsz"ParallelBuildExtTestCase.build_ext)r<r�r�rr�r#r#r!r$r�sr�cCs,t��}|�t�t��|�t�t��|Sr&)r�Z	TestSuiteZaddTestZ	makeSuiterr�)Zsuiter#r#r$�
test_suitesr��__main__)#r5r/�iorr=Zdistutils.corerZdistutils.command.build_extrZ	distutilsrZdistutils.tests.supportrrr	r
Zdistutils.extensionrZdistutils.errorsrr
rrr��testrZtest.support.script_helperrr:ZTestCaserr�r�r<Zrun_unittestr#r#r#r$�<module>s2�

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists