Current File : //usr/local/apps/python3/lib/python3.11/distutils/tests/__pycache__/support.cpython-311.opt-1.pyc
�

�KeZ���dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZmZmZddlmZGd�d	e��ZGd
�de��ZGd�d
��ZGd�de��Zd�Zd�Zd�ZdS)z&Support code for distutils test cases.�N)�deepcopy)�	os_helper)�log)�DEBUG�INFO�WARN�ERROR�FATAL)�Distributionc�:��eZdZ�fd�Z�fd�Zd�Zd�Zd�Z�xZS)�LoggingSilencerc����t�����tjtj��|_tjj|_|jtj_g|_	dS�N)
�super�setUpr�
set_thresholdr
�	threshold�Log�_log�_old_log�logs��self�	__class__s ��A/usr/local/apps/python3/lib/python3.11/distutils/tests/support.pyrzLoggingSilencer.setUpsK���
���
�
�����*�3�9�5�5�������
��y������	�	�	�c���tj|j��|jtj_t
�����dSr)rrrrrrr�tearDownrs �rrzLoggingSilencer.tearDowns=�����$�.�)�)�)��}����
���������rc�4�|tttttfvrtdt
|��z���t|t��s$tdt|��j
z���|j�|||f��dS)Nz%s wrong log levelzmsg should be str, not '%.200s')
rrrr	r
�
ValueError�str�
isinstance�	TypeError�type�__name__r�append)r�level�msg�argss    rrzLoggingSilencer._log!s������d�E�5�9�9�9��1�C��J�J�>�?�?�?��#�s�#�#�	4��=�#�C�y�y�1�3�4�4�
4��	���%��d�+�,�,�,�,�,rc�*���fd�|jD��S)Nc�*��g|]\}}}|�v�
||z��S�r,)�.0r'r(r)�levelss    �r�
<listcomp>z,LoggingSilencer.get_logs.<locals>.<listcomp>*s4���1�1�1�/�u�c�4� %�����d�
� /��r�r)rr.s `r�get_logszLoggingSilencer.get_logs)s0���1�1�1�1��9�1�1�1�	1rc��g|_dSrr0�rs r�
clear_logszLoggingSilencer.clear_logs-s
����	�	�	r)	r%�
__module__�__qualname__rrrr1r4�
__classcell__�rs@rr
r
s~�����������������
-�-�-�1�1�1�������rr
c�B��eZdZdZ�fd�Z�fd�Zd�Zd	d�Zd
d�Z�xZ	S)�TempdirManagerz}Mix-in class that handles temporary directories for test cases.

    This is intended to be used with unittest.TestCase.
    c���t�����tj��|_g|_dSr)rr�os�getcwd�old_cwd�tempdirsrs �rrzTempdirManager.setUp7s,���
���
�
�����y�{�{�����
�
�
rc����tj|j��t�����|jr6|j���}tj|��|j�4dSdSr)	r<�chdirr>rrr?�popr�rmtree)r�tmpdirrs  �rrzTempdirManager.tearDown<s{���	�������
���������m�	%��]�&�&�(�(�F���V�$�$�$��m�	%�	%�	%�	%�	%rc�`�tj��}|j�|��|S)zjCreate a temporary directory that will be cleaned up.

        Returns the path of the directory.
        )�tempfile�mkdtempr?r&)r�ds  rrGzTempdirManager.mkdtempEs-��

������
���Q�����r�xxxc�
�t|ttf��rtjj|�}t
|d��}	|�|��|���dS#|���wxYw)zWWrites a file in the given path.


        path can be a string or a sequence.
        �wN)	r"�list�tupler<�path�join�open�write�close)rrN�content�fs    r�
write_filezTempdirManager.write_fileNso���d�T�5�M�*�*�	'��7�<��&�D���s�O�O��	�
�G�G�G����
�G�G�I�I�I�I�I��A�G�G�I�I�I�I���s�A,�,B�fooc��|���}tj�||��}tj|��t|���}||fS)aWill generate a test environment.

        This function creates:
         - a Distribution instance using keywords
         - a temporary directory with a package structure

        It returns the package directory and the distribution
        instance.
        )�attrs)rGr<rNrO�mkdirr)r�pkg_name�kw�tmp_dir�pkg_dir�dists      r�create_distzTempdirManager.create_dist\sP���,�,�.�.���'�,�,�w��1�1��
�������"�%�%�%����}�r)rI)rV)
r%r5r6�__doc__rrrGrUr_r7r8s@rr:r:1s����������
�����
%�%�%�%�%���������������rr:c��eZdZdZd�Zd�ZdS)�DummyCommandzAClass to store options for retrieval via set_undefined_options().c�\�|���D]\}}t|||���dSr)�items�setattr)r�kwargsr[�vals    r�__init__zDummyCommand.__init__qs<���|�|�~�~�	#�	#�G�B���D�"�c�"�"�"�"�	#�	#rc��dSrr,r3s r�ensure_finalizedzDummyCommand.ensure_finalizedus���rN)r%r5r6r`rhrjr,rrrbrbns8������K�K�#�#�#�
�
�
�
�
rrbc�(��eZdZ�fd�Z�fd�Z�xZS)�EnvironGuardc���tt|�����ttj��|_dSr)rrlrrr<�environ�old_environrs �rrzEnvironGuard.setUp{s7���
�l�D�!�!�'�'�)�)�)�#�B�J�/�/����rc���|j���D]7\}}tj�|��|kr|tj|<�8ttj�����D]}||jvr
tj|=�tt|���	��dSr)
rordr<rn�getrM�keysrrlr)r�key�valuers   �rrzEnvironGuard.tearDowns�����*�0�0�2�2�	(�	(�J�C���z�~�~�c�"�"�e�+�+�"'��
�3��������*�*�+�+�	$�	$�C��$�*�*�*��J�s�O��
�l�D�!�!�*�*�,�,�,�,�,r)r%r5r6rrr7r8s@rrlrlysQ�������0�0�0�0�0�	-�	-�	-�	-�	-�	-�	-�	-�	-rrlc�x�t��}|�tjd���tj||��dS)akHelper for tests that need the xxmodule.c source file.

    Example use:

        def test_compile(self):
            copy_xxmodule_c(self.tmpdir)
            self.assertIn('xxmodule.c', os.listdir(self.tmpdir))

    If the source file can be found, it will be copied to *directory*.  If not,
    the test will be skipped.  Errors during copy are not caught.
    Nz>cannot find xxmodule.c (test must run in the python build dir))�_get_xxmodule_path�unittest�SkipTest�shutil�copy)�	directory�filenames  r�copy_xxmodule_cr}�sG��"�#�#�H�����!8�9�9�	9�
�K��)�$�$�$�$�$rc
��tjd��}tj�tj�t��d��tj�|dd��tj�|ddddd��g}|D]%}tj�|��r|cS�&dS)N�srcdirz
xxmodule.c�Modulesz..)�	sysconfig�get_config_varr<rNrO�dirname�__file__�exists)r�
candidatesrNs   rrvrv�s���
�
%�h�
/�
/�F�	����R�W�_�_�X�.�.��=�=�
����V�Y��5�5�	����V�T�4��y�,�G�G�	�J�����
�7�>�>�$���	��K�K�K�	��rc��tjdkr&tj�d��|_dSt
jd��r�t
jd��}|�
dg|_dStj	dkr	g|_dS|�
d��\}}}d	�|�tj��D��|_dSdS)
a�Function needed to make build_ext tests pass.

    When Python was built with --enable-shared on Unix, -L. is not enough to
    find libpython<blah>.so, because regrtest runs in a tempdir, not in the
    source directory where the .so lives.

    When Python was built with in debug mode on Windows, build_ext commands
    need their debug attribute set, and it is not done automatically for
    some reason.

    This function handles both of these things.  Example use:

        cmd = build_ext(dist)
        support.fixup_build_ext(cmd)
        cmd.ensure_finalized()

    Unlike most other Unix platforms, Mac OS X embeds absolute paths
    to shared libraries into executables, so the fixup is not needed there.
    �ntz_d.exe�Py_ENABLE_SHARED�	RUNSHAREDN�.�darwin�=c��g|]}|�|��Sr,r,)r-rHs  rr/z#fixup_build_ext.<locals>.<listcomp>�s��#L�#L�#L�!�!�#L�A�#L�#L�#Lr)
r<�name�sys�
executable�endswith�debugr�r��library_dirs�platform�	partition�split�pathsep)�cmd�	runsharedr��equalsrts     r�fixup_build_extr��s���(
�w�$����N�+�+�H�5�5��	�	�	�	�	!�"4�	5�	5�M��,�[�9�9�	��� #�u�C�����|�x�'�'�#%�� � � �&/�&9�&9�#�&>�&>�#��f�e�#L�#L�u�{�{�2�:�/F�/F�#L�#L�#L�� � � �M�Mr)r`r<r�ryrFrwr�rzr�test.supportr�	distutilsr�
distutils.logrrrr	r
�distutils.corer�objectr
r:rbrlr}rvr�r,rr�<module>r�s���,�,�	�	�	�	�
�
�
�
�
�
�
�
�������������������"�"�"�"�"�"�������9�9�9�9�9�9�9�9�9�9�9�9�9�9�'�'�'�'�'�'������f����B:�:�:�:�:�V�:�:�:�z
�
�
�
�
�
�
�
�-�-�-�-�-�6�-�-�-�$%�%�%�&���""M�"M�"M�"M�"Mr