hyb
2026-01-09 4cb426cb3ae31e772a09d4ade5b2f0242aaeefa0
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
Ë
Añúh¼ãóޗdZddlZddlZddlZddlZddlZddlZddlmZejjejdk7d¬«Z Gd„d«Z d    „Z Gd
„d e «ZGd „d e «Zy)a1
Python Script Wrapper for Windows
=================================
 
setuptools includes wrappers for Python scripts that allows them to be
executed like regular windows programs.  There are 2 wrappers, one
for command-line programs, cli.exe, and one for graphical programs,
gui.exe.  These programs are almost identical, function pretty much
the same way, and are generated from the same source file.  The
wrapper programs are used by copying them to the directory containing
the script they are to wrap and with the same name as the script they
are to wrap.
éN)Ú    resourcesÚwin32z Windows only)Úreasoncó,—eZdZed„«Zed„«Zy)Ú WrapperTestercód—tjtjg«}|t    «zS)N)Ú
subprocessÚ list2cmdlineÚsysÚ
executableÚlocals)ÚclsÚtemplateÚ
python_exes   úYH:\Change_password\venv_build\Lib\site-packages\setuptools/tests/test_windows_wrappers.pyÚ prep_scriptzWrapperTester.prep_scripts&€ä×,Ñ,¬c¯n©nÐ-=Ó>ˆ
Øœ&›(Ñ"Ð"ócó—|j|j«}||jz jd«5}|j    |«ddd«||j
z jd«5}t jd«j|j«j«}|j    |«ddd«y#1swYŒ~xYw#1swYyxYw)zö
        Create a simple script, foo-script.py
 
        Note that the script starts with a Unix-style '#!' line saying which
        Python executable to run.  The wrapper will use this line to find the
        correct Python executable.
        ÚwNÚwbÚ
setuptools) rÚ script_tmplÚ script_nameÚopenÚwriteÚ wrapper_namerÚfilesÚjoinpathÚwrapper_sourceÚ
read_bytes)rÚtmpdirÚscriptÚfrs     rÚ create_scriptzWrapperTester.create_script"s¹€ð—‘ §¡Ó1ˆàs—‘Ñ&× ,Ñ ,¨SÓ 1ð    °QØ G‰GFŒO÷    ðs×'Ñ'Ñ'× -Ñ -¨dÓ 3ð    °qÜ—‘  Ó-×6Ñ6°s×7IÑ7IÓJ×UÑUÓWˆAØ G‰GAŒJ÷    ð    ÷        ð    ú÷    ð    úsºC    Á2ACà   CÃCN)Ú__name__Ú
__module__Ú __qualname__Ú classmethodrr$©rrrrs(„Øñ#óð#ðñóñrrcóP—|dvsJ‚tj«dk(r|›dS|›dS)z=A simple routine to select launcher script based on platform.)ÚcliÚguiÚARM64z
-arm64.exez-32.exe)ÚplatformÚmachine)Úprefixs rÚwin_launcher_exer17s;€à ^Ñ #Ð#Ð #Ü×ÑÓ˜WÒ$ؐ˜Ð$Ð$à˜Ð!Ð!rcóv—eZdZdZdZed«Zejd«j«Z
d„Z d„Z d„Z y)    ÚTestCLIú foo-script.pyúfoo.exer+zç
        #!%(python_exe)s
        import sys
        input = repr(sys.stdin.read())
        print(sys.argv[0][-14:])
        print(sys.argv[1:])
        print(input)
        if __debug__:
            print('non-optimized')
        cóZ—|j|«t|dz «dddddg}tj|tjtjdd¬    «}|j d
«\}}|j d d «}tjd «j«}||k(sJ‚y)aD
        When the copy of cli.exe, foo.exe in this example, runs, it examines
        the path name it was run with and computes a Python script path name
        by removing the '.exe' suffix and adding the '-script.py' suffix. (For
        GUI programs, the suffix '-script.pyw' is added.)  This is why we
        named out script the way we did.  Now we can run out script by running
        the wrapper:
 
        This example was a little pathological in that it exercised windows
        (MS C runtime) quoting rules:
 
        - Strings containing spaces are surrounded by double quotes.
 
        - Double quotes in strings need to be escaped by preceding them with
          back slashes.
 
        - One or more backslashes preceding double quotes need to be escaped
          by preceding each of them with back slashes.
        r5Úarg1úarg 2úarg "2\"úarg 4\ú    arg5 a\\bTúutf-8©ÚstdoutÚstdinÚtextÚencodingú hello
world
ú
ú
ú¤
            \foo-script.py
            ['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b']
            'hello\nworld\n'
            non-optimized
            N)
r$Ústrr    ÚPopenÚPIPEÚ communicateÚreplaceÚtextwrapÚdedentÚlstrip)Úselfr!ÚcmdÚprocr>Ú_stderrÚactualÚexpecteds        rÚ
test_basiczTestCLI.test_basicRs´€ð(     ×ј6Ô"ä ˜Ñ"Ó #Ø Ø Ø Ø Ø ð 
ˆô×ÑØ Ü—?‘?Ü—/‘/ØØô 
ˆð×*Ñ*Ð+;Ó<‰ˆØ—‘ ¨Ó-ˆÜ—?‘?ð ó
÷ ‰&‹(ð    ð˜Ò!Ð!Ñ!rcóÜ—|dz }|j«|j|«tj|dz «}|j    |dz «t |dz «dddddg}t j|t jt jdd    ¬
«}|jd «\}}|jd d «}tjd«j«}    ||    k(sJ‚y)zK
        Ensure that symlink for the foo.exe is working correctly.
        Ú
script_dirr5r7r8r9r:r;Tr<r=rBrCrDrEN)Úmkdirr$ÚpathlibÚPathÚ
symlink_torFr    rGrHrIrJrKrLrM)
rNr!rVÚsymlinkrOrPr>rQrRrSs
          rÚ test_symlinkzTestCLI.test_symlink‚sò€ð˜lÑ*ˆ
Ø×ÑÔØ ×ј:Ô&Ü—,‘,˜v¨    Ñ1Ó2ˆØ×ј:¨    Ñ1Ô2ô ˜Ñ"Ó #Ø Ø Ø Ø Ø ð 
ˆô×ÑØ Ü—?‘?Ü—/‘/ØØô 
ˆð×*Ñ*Ð+;Ó<‰ˆØ—‘ ¨Ó-ˆÜ—?‘?ð ó
÷ ‰&‹(ð    ð˜Ò!Ð!Ñ!rcóD—|j|«tjd«j«}|dz j    d«5}|j |j |««ddd«t|dz «g}tj|tjtjtjdd¬«}|j«\}}|jd    d
«}tjd «j«}    ||    k(sJ‚y#1swYŒ­xYw) a×
        Specifying Python Command-line Options
        --------------------------------------
 
        You can specify a single argument on the '#!' line.  This can be used
        to specify Python options like -O, to run in optimized mode or -i
        to start the interactive interpreter.  You can combine multiple
        options as usual. For example, to run in optimized mode and
        enter the interpreter after running the script, you could use -Oi:
        a,
            #!%(python_exe)s  -Oi
            import sys
            input = repr(sys.stdin.read())
            print(sys.argv[0][-14:])
            print(sys.argv[1:])
            print(input)
            if __debug__:
                print('non-optimized')
            sys.ps1 = '---'
            r4rNr5Tr<©r>r?Ústderrr@rArCrDzV
            \foo-script.py
            []
            ''
            ---
            )r$rKrLrMrrrrFr    rGrHÚSTDOUTrIrJ)
rNr!Útmplr#rOrPr>rQrRrSs
          rÚtest_with_optionszTestCLI.test_with_options§s    €ð     ×ј6Ô"܏‰ð
ó 
÷ ‰&‹(ð     ðÑ&× ,Ñ ,¨SÓ 1ð    ,°QØ G‰GD×$Ñ$ TÓ*Ô +÷    ,ä6˜IÑ%Ó&Ð'ˆÜ×ÑØ Ü—?‘?Ü—/‘/Ü×$Ñ$ØØô 
ˆð×*Ñ*Ó,‰ˆØ—‘ ¨Ó-ˆÜ—?‘?ð ó
÷ ‰&‹(ð    ð˜Ò!Ð!Ñ!÷+    ,ð    ,ús Á    !DÄDN)r%r&r'rrr1rrKrLrMrrTr\rbr)rrr3r3@sH„Ø!€KØ€LÙ% eÓ,€Nà!(—/‘/ð         ó ÷ fƒhðò."ò`#"óJ."rr3cón—eZdZdZdZed«ZdZejd«j«Z d„Z y)ÚTestGUIz=
    Testing the GUI Version
    -----------------------
    zbar-script.pywr,úbar.exez®
        #!%(python_exe)s
        import sys
        f = open(sys.argv[1], 'wb')
        bytes_written = f.write(repr(sys.argv[2]).encode('utf-8'))
        f.close()
        cóЗ|j|«t|dz «t|dz «dg}tj|tjtjtj
dd¬«}|j «\}}|rJ‚|rJ‚|dz jd«5}|j«jd«}d    d    d    «td«k(sJ‚y    #1swYŒxYw)
z:Test the GUI version with the simple script, bar-script.pyreztest_output.txtz Test ArgumentTr<r^ÚrbÚasciiN) r$rFr    rGrHr`rIrÚreadÚdecodeÚrepr)rNr!rOrPr>r_Úf_outrRs        rrTzTestGUI.test_basicìsá€à ×ј6Ô"ô ˜Ñ"Ó #Ü Ð*Ñ*Ó +Ø ð
ˆô
×ÑØ Ü—?‘?Ü—/‘/Ü×$Ñ$ØØô 
ˆð×)Ñ)Ó+‰ˆÙЈzÙЈzØÐ(Ñ(× .Ñ .¨tÓ 4ð    2¸Ø—Z‘Z“\×(Ñ(¨Ó1ˆF÷    2àœ˜oÓ.Ò.Ð.Ñ.÷    2ð    2ús Â# CÃC%N) r%r&r'Ú__doc__rr1rrrKrLÚstriprrTr)rrrdrdØsC„ñð
#€KÙ% eÓ,€NØ€Là!(—/‘/ð     ó÷ eƒgðó/rrd)rmrXr.r    r rKÚpytestÚsetuptools._importlibrÚmarkÚskipifÚ
pytestmarkrr1r3rdr)rrú<module>rtsmðñ óÛÛÛ
Ûã å+à [‰[× Ñ  § ¡ °Ñ 7ÀÐ Ó O€
÷ñò6"ôU"ˆmôU"ôp*/ˆmõ*/r