zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
U
X±d†ã@s¼dZddlZddlZddlZddlZddlZddlZddlZddl    m
Z
ej j Z ej j Z ej jZdd„ZeƒZe e ddZej jZedœd    d
„Zedœd d „Zed œdd„Zddd„ZdS)zS
Decorators for skipping PyInstaller tests when specific requirements are not met.
éN)Úis_wincCsˆddl}t ¡}| ¡}t |¡tj ¡}tr`z|     ¡d}Wqptj
j k
r\d}YqpXn|j ddgd}t |¡t  |¡|S)NrTFZclockztime.h)Zincludes)ÚtempfileÚosÚgetcwdÚmkdtempÚchdirÚ    distutilsZ    ccompilerZ new_compilerrZ
initializeÚerrorsÚDistutilsPlatformErrorZ has_functionÚshutilÚrmtree)rZold_wdÚtmpÚccÚ has_compiler©rúNd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/utils/tests.pyÚ_check_for_compiler s
 
 
 
rzRequires a C compiler©Úreason©ÚpackagecCs4t|ƒstj d|›d¡Stjjdd|›ddS)aÛ
    Skip a decorated test if **package** is not importable.
 
    Arguments:
        package:
            The name of the module. May be anything that is allowed after the ``import`` keyword. e.g. 'numpy' or
            'PIL.Image'.
    Returns:
        A pytest marker which either skips the test or does nothing.
 
    This function intentionally does not import the module. Doing so can lead to `sys.path` and `PATH` being
    polluted, which then breaks later builds.
    zCan't import 'z'.Fú Don't skip: 'z' is importable.r)Ú
importableÚpytestÚmarkÚskipÚskipifrrrrÚ importorskipDsrcCsfddlm}d|krZt| d¡dƒs*dSddlm}m}|tjdd|g||dj    dkS||ƒdk    S)    Nr)Ú    find_specÚ.F)ÚDEVNULLÚrunz-czimport )ÚstdoutÚstderr)
Zimportlib.utilrrÚsplitÚ
subprocessr r!ÚsysÚ
executableÚ
returncode)rrr r!rrrrWs  r)Ú requirementcCsXddl}z$| |¡tjjdd|›ddWS|jk
rRtj d|¡YSXdS)aÎ
    Mark a test to be skipped if **requirement** is not satisfied.
 
    Args:
        requirement:
            A distribution name and optionally a version. See :func:`pkg_resources.require` which this argument is
            forwarded to.
    Returns:
        Either a skip marker or a dummy marker.
 
    This function intentionally does not import the module. Doing so can lead to `sys.path` and `PATH` being
    polluted, which then breaks later builds.
    rNFrz' is satisfied.rz    Requires )Ú pkg_resourcesÚrequirerrrÚResolutionErrorr)r)r*rrrÚrequiresgs 
r-c    Csxt ¡dd}|r |d|}| dd¡}||d}t |¡}|jddd    }td
|d t||d W5QRX|S) a
    Generate a source file for testing.
 
    The source will be written into a file named like the test-function. This file will then be passed to
    `test_script`. If you need other related file, e.g. as `.toc`-file for testing the content, put it at at the
    normal place. Just mind to take the basnename from the test-function's name.
 
    :param script: Source code to create executable from. This will be saved into a temporary file which is then
                   passed on to `test_script`.
 
    :param test_id: Test-id for parametrized tests. If given, it will be appended to the script filename,
                    separated by two underscores.
 
    Ensure that the caller of `test_source` is in a UTF-8 encoded file with the correct '# -*- coding: utf-8 -*-'
    marker.
    ééÚ__rÚ_z.pyÚwzutf-8)Úencodingz# -*- coding: utf-8 -*-)Úfile)ÚinspectÚstackÚreplaceÚtextwrapÚdedentÚopenÚprint)ZtmpdirÚsourceZtest_idZtestnameZ
scriptfileZofhrrrÚgen_sourcefile}s   
 r=)N)Ú__doc__Údistutils.ccompilerrr5rr r8rr&ZPyInstaller.compatrrZ parametrizerZxfailrrZskipif_no_compilerrÚstrrrr-r=rrrrÚ<module> s&