HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/distutils/tests/__pycache__/support.cpython-310.pyc
o

�iZ�@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZmZmZmZddlmZGdd	�d	e�ZGd
d�de�ZGdd
�d
�ZGdd�de�Zdd�Zdd�Zdd�ZdS)z&Support code for distutils test cases.�N)�deepcopy)�	os_helper)�log)�DEBUG�INFO�WARN�ERROR�FATAL)�Distributioncs@eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Z�ZS)�LoggingSilencercs6t���t�tj�|_tjj|_|jtj_g|_	dS�N)
�super�setUpr�
set_thresholdr	�	threshold�Log�_log�_old_log�logs��self��	__class__��4/usr/local/lib/python3.10/distutils/tests/support.pyrs




zLoggingSilencer.setUpcs$t�|j�|jtj_t���dSr)rrrrrrr
�tearDownrrrrrs
zLoggingSilencer.tearDowncCsT|tttttfvrtdt|���t|t�stdt	|�j
��|j�|||f�dS)Nz%s wrong log levelzmsg should be str, not '%.200s')
rrrrr	�
ValueError�str�
isinstance�	TypeError�type�__name__r�append)r�level�msg�argsrrrr!s
�zLoggingSilencer._logcs�fdd�|jD�S)Ncs"g|]
\}}}|�vr||�qSrr)�.0r#r$r%��levelsrr�
<listcomp>*s�z,LoggingSilencer.get_logs.<locals>.<listcomp>�r)rr(rr'r�get_logs)s
�zLoggingSilencer.get_logscCs
g|_dSrr*rrrr�
clear_logs-s
zLoggingSilencer.clear_logs)	r!�
__module__�__qualname__rrrr+r,�
__classcell__rrrrrs
rcsHeZdZdZ�fdd�Z�fdd�Zdd�Zdd	d
�Zddd
�Z�Z	S)�TempdirManagerz}Mix-in class that handles temporary directories for test cases.

    This is intended to be used with unittest.TestCase.
    cst���t��|_g|_dSr)r
r�os�getcwd�old_cwd�tempdirsrrrrr7s


zTempdirManager.setUpcs>t�|j�t���|jr|j��}t�|�|jsdSdSr)	r1�chdirr3r
rr4�popr�rmtree)rZtmpdirrrrr<s


�zTempdirManager.tearDowncCst��}|j�|�|S)zjCreate a temporary directory that will be cleaned up.

        Returns the path of the directory.
        )�tempfile�mkdtempr4r")r�drrrr9EszTempdirManager.mkdtemp�xxxcCsHt|ttf�r
tjj|�}t|d�}z|�|�W|��dS|��w)zWWrites a file in the given path.


        path can be a string or a sequence.
        �wN)	r�list�tupler1�path�join�open�write�close)rr?Zcontent�frrr�
write_fileNs
zTempdirManager.write_file�foocKs2|��}tj�||�}t�|�t|d�}||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.
        )Zattrs)r9r1r?r@�mkdirr
)rZpkg_name�kwZtmp_dirZpkg_dir�distrrr�create_dist\s



zTempdirManager.create_dist)r;)rF)
r!r-r.�__doc__rrr9rErJr/rrrrr01s	
	r0c@s eZdZdZdd�Zdd�ZdS)�DummyCommandzAClass to store options for retrieval via set_undefined_options().cKs"|��D]
\}}t|||�qdSr)�items�setattr)r�kwargsrH�valrrr�__init__qs�zDummyCommand.__init__cCsdSrrrrrr�ensure_finalizeduszDummyCommand.ensure_finalizedN)r!r-r.rKrQrRrrrrrLnsrLcs(eZdZ�fdd�Z�fdd�Z�ZS)�EnvironGuardcstt|���ttj�|_dSr)r
rSrrr1�environ�old_environrrrrr{szEnvironGuard.setUpcsf|j��D]\}}tj�|�|kr|tj|<qttj���D]}||jvr)tj|=qtt|��	�dSr)
rUrMr1rT�getr>�keysr
rSr)r�key�valuerrrrs
�
�zEnvironGuard.tearDown)r!r-r.rrr/rrrrrSysrScCs(t�}|durt�d��t�||�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�unittestZSkipTest�shutil�copy)Z	directory�filenamerrr�copy_xxmodule_c�s
r_c
Csft�d�}tj�tj�t�d�tj�|dd�tj�|ddddd�g}|D]}tj�|�r0|Sq$dS)N�srcdirz
xxmodule.cZModulesz..)�	sysconfig�get_config_varr1r?r@�dirname�__file__�exists)r`Z
candidatesr?rrrrZ�s
�
��rZcCs�tjdkrtj�d�|_dSt�d�rBt�d�}|dur"dg|_dStj	dkr,g|_dS|�
d�\}}}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.exeZPy_ENABLE_SHAREDZ	RUNSHAREDN�.�darwin�=cSsg|]}|r|�qSrr)r&r:rrrr)�sz#fixup_build_ext.<locals>.<listcomp>)
r1�name�sys�
executable�endswith�debugrarbZlibrary_dirs�platform�	partition�split�pathsep)�cmdZ	runsharedrjZequalsrYrrr�fixup_build_ext�s




�rt)rKr1rkr\r8r[rar]rZtest.supportrZ	distutilsrZ
distutils.logrrrrr	Zdistutils.corer
�objectrr0rLrSr_rZrtrrrr�<module>s&!=