zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
U
O±df)ã@s®dZddgZddlZddlZddlZddlZddlZddlmZm    Z    ddl
m Z dd„Z d    d
„Z d d „Zd d„Zdifdd„Zdd„Zdd„Zddd„Zddd„Zdd„ZdS)a0
exec_command
 
Implements exec_command function that is (almost) equivalent to
commands.getstatusoutput function but on NT, DOS systems the
returned status is actually correct (though, the returned status
values may be different by a factor). In addition, exec_command
takes keyword arguments for (re-)defining environment variables.
 
Provides functions:
 
  exec_command  --- execute command in a specified directory and
                    in the modified environment.
  find_executable --- locate a command using info from environment
                    variable PATH. Equivalent to posix `which`
                    command.
 
Author: Pearu Peterson <pearu@cens.ioc.ee>
Created: 11 January 2003
 
Requires: Python 2.x
 
Successfully tested on:
 
========  ============  =================================================
os.name   sys.platform  comments
========  ============  =================================================
posix     linux2        Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3
                        PyCrust 0.9.3, Idle 1.0.2
posix     linux2        Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2
posix     sunos5        SunOS 5.9, Python 2.2, 2.3.2
posix     darwin        Darwin 7.2.0, Python 2.3
nt        win32         Windows Me
                        Python 2.3(EE), Idle 1.0, PyCrust 0.7.2
                        Python 2.1.1 Idle 0.8
nt        win32         Windows 98, Python 2.1.1. Idle 0.8
nt        win32         Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests
                        fail i.e. redefining environment variables may
                        not work. FIXED: don't use cygwin echo!
                        Comment: also `cmd /c echo` will not work
                        but redefining environment variables do work.
posix     cygwin        Cygwin 98-4.10, Python 2.3.3(cygming special)
nt        win32         Windows XP, Python 2.3.3
========  ============  =================================================
 
Known bugs:
 
* Tests, that send messages to stderr, fail when executed from MSYS prompt
  because the messages are lost at some point.
 
Ú exec_commandÚfind_executableéN)Ú is_sequenceÚmake_temp_file)ÚlogcCsPt d¡}|dkrd}|j|dd}| dd¡}|dd…dkrL|dd…}|S)    zŸ
    Convert `bytes` in the encoding used by a subprocess into a filesystem-appropriate `str`.
 
    Inherited from `exec_command`, and possibly incorrect.
    FNÚasciiÚreplace©Úerrorsú
Ú
éÿÿÿÿ)ÚlocaleÚgetpreferredencodingÚdecoder)ÚoutputÚmylocale©rúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/distutils/exec_command.pyÚfilepath_from_subprocess_output?s
  rcCsZttjdƒrtjj |¡n:ttjdƒr@tj | tjj¡¡ntj |jddd¡dS)zÈ
    Forward bytes from a subprocess call to the console, without attempting to
    decode them.
 
    The assumption is that the subprocess call already returned bytes in
    a suitable encoding.
    ÚbufferÚencodingÚutf8rr    N)ÚhasattrÚsysÚstdoutrÚwriterr)ÚvalrrrÚforward_bytes_to_stdoutPs
  rcCs&tjdtddtƒ\}}| ¡|S)NzLtemp_file_name is deprecated since NumPy v1.17, use tempfile.mkstemp insteadé©Ú
stacklevel)ÚwarningsÚwarnÚDeprecationWarningrÚclose)ÚfoÚnamerrrÚtemp_file_namecsÿ
r(cCs\tj}tjdkrXtj |¡\}}| ¡ dd¡}tj ||¡}tj     |¡sXt
d|fƒ‚|S)N)ÚntÚdosZPYTHONWZPYTHONz%r is not a file) rÚ
executableÚosr'ÚpathÚsplitÚupperrÚjoinÚisfileÚAssertionError)Z    pythonexeZfdirÚfnrrrÚ get_pythonexeks
r4c Cs|||f}z
||WStk
r&YnXt d|¡|}|dkrRtj dtj¡}tjdkrftjj    }ndd„}| 
d¡r„|dd    …}d
g}tjd kr¾tj  |¡\}}d d dg}    |  ¡|    kr¾|    }tj  |¡rÒd
g}
ndd„| tj¡Dƒ}
|
D]|}tj ||¡}|D]d} || } tj | ¡s$|| ƒ} tj | ¡rt | tj¡rt d| ¡| ||<| Sqqìt d|¡dS)zTReturn full path of a executable or None.
 
    Symbolic links are not followed.
    zfind_executable(%r)NÚPATHÚposixcSs|S©Nr)ÚarrrÚ<lambda>†óz!find_executable.<locals>.<lambda>ú"rr Ú)r)r*Zos2z.exez.comz.batcSsg|]}tj |¡‘qSr)r,r-Úabspath)Ú.0ÚprrrÚ
<listcomp>•sz#find_executable.<locals>.<listcomp>zFound executable %szCould not locate executable %s)ÚKeyErrorrÚdebugr,ÚenvironÚgetÚdefpathr'r-ÚrealpathÚ
startswithÚsplitextÚlowerÚisabsr.Úpathsepr0Úislinkr1ÚaccessÚX_OKÚinfor#) Zexer-Ú_cacheÚkeyZorig_exerFÚsuffixesr3ÚextZextra_suffixesÚpathsÚsZf_extrrrrtsF
 
 
 
 
 
  cCs t d|¡dd„|Dƒ}|S)Nz_preserve_environment(%r)cSsi|]}|tj |¡“qSr)r,rCrD)r>r'rrrÚ
<dictcomp>©sz)_preserve_environment.<locals>.<dictcomp>)rrB)ÚnamesÚenvrrrÚ_preserve_environment§srYcKs.t d¡| ¡D]\}}|p dtj|<qdS)Nz_update_environment(...)r<)rrBÚitemsr,rC)rXr'ÚvaluerrrÚ_update_environment¬s
r\r<rc
 
Ksztjdtddt d|d dd„| ¡Dƒ¡f¡|dkrHtjd    k}|dkrZtjd    k}tj     
|¡}tj     
t  ¡¡}t d
d…d krœtj      tj     
t¡¡}nDtj     d ¡r¶tj     
d ¡}n*tj     
tjd¡}tj     |¡ràtj      |¡}||krt |¡t d|¡nt d|¡tt| ¡ƒƒ}tf|Žzt|f||dœ|—Ž}    W5||krjt |¡t d|¡tf|ŽX|    S)aï
    Return (status,output) of executed command.
 
    .. deprecated:: 1.17
        Use subprocess.Popen instead
 
    Parameters
    ----------
    command : str
        A concatenated string of executable and arguments.
    execute_in : str
        Before running command ``cd execute_in`` and after ``cd -``.
    use_shell : {bool, None}, optional
        If True, execute ``sh -c command``. Default None (True)
    use_tee : {bool, None}, optional
        If True use tee. Default None (True)
 
 
    Returns
    -------
    res : str
        Both stdout and stderr messages.
 
    Notes
    -----
    On NT, DOS systems the returned status is correct for external commands.
    Wild cards will not work for non-posix systems or when use_shell=0.
 
    zJexec_command is deprecated since NumPy v1.17, use subprocess.Popen insteadrr zexec_command(%r,%s)ú,cSsg|] }d|‘qS)z%s=%rr)r>Úkvrrrr@Ôsz exec_command.<locals>.<listcomp>Nr6iôÿÿÿrzexec_command.pyÚ.rz New cwd: %szRetaining cwd: %szRestored cwd to %s)Ú    use_shellÚuse_tee)r"r#r$rrBr0rZr,r'r-r=ÚgetcwdÚ__name__ÚdirnameÚ__file__r1rÚargvÚchdirrYÚlistÚkeysr\Ú _exec_command)
ÚcommandZ
execute_inr`raZ _with_pythonrXZoldcwdZexec_dirZoldenvÚstrrrr±sL ÿÿ
 
 
 
 
þý
 
 
 c    KsF|dkrtjdk}|dkr$tjdk}tjdkrj|rjtj dd¡}t|ƒrZ|dd |¡g}n
|d|g}d}n&tjdkrt|ƒrd d    d
„|Dƒ¡}|p–d}ztj|||dtjtj    d }Wnt
k
rÌYd SX|  ¡\}}t   d¡}|dkrðd }|j|dd}| dd¡}|dd…dkr(|dd…}|r<|r<t|ƒ|j|fS)z0
    Internal workhorse for exec_command().
    Nr6ZSHELLz/bin/shz-cú Fr)css|]}t|ƒVqdSr7)Ú
_quote_arg)r>ÚargrrrÚ    <genexpr>sz _exec_command.<locals>.<genexpr>)ÚshellrXÚtextrÚstderr)ér<rrr    r r r )r,r'rCrDrr0Ú
subprocessÚPopenÚPIPEÚSTDOUTÚOSErrorÚ communicaterrrrÚprintÚ
returncode)    rkr`rarXÚshÚprocrrÚerrrrrrrjýs>
 
 
 þ
 
   rjcCsd|krd|krd|S|S)zB
    Quote the argument for safe use in a shell command line.
    r;rmz"%s"r)rorrrrn1srn)r<NNr)NN)Ú__doc__Ú__all__r,rrurr"Znumpy.distutils.misc_utilrrZnumpy.distutilsrrrr(r4rrYr\rrjrnrrrrÚ<module>s(3     3ÿ
L
4