blob: 3c78eb536146c37d9f771a4ae190b92bf69811e6 [file] [log] [blame]
Brett Cannon4fc38552003-10-14 21:45:59 +00001\section{\module{platform} ---
2 Access to underlying platform's identifying data.}
3
4\declaremodule{standard}{platform}
5\modulesynopsis{Retrieves as much platform identifying data as possible.}
6\moduleauthor{Marc-Andre Lemburg}{mal@egenix.com}
7\sectionauthor{Bjorn Pettersen}{bpettersen@corp.fairisaac.com}
8
9\versionadded{2.3}
10
11\begin{notice}[note]
12 Specific platforms listed alphabetically, with Linux included in the \UNIX
13 section.
14\end{notice}
15
16\subsection{Cross Platform}
17
18\begin{funcdesc}{architecture}{executable=sys.executable, bits='', linkage=''}
19 Queries the given executable (defaults to the Python interpreter
20 binary) for various architecture informations.
21
22 Returns a tuple \code{(bits, linkage)} which contain information about
23 the bit architecture and the linkage format used for the
24 executable. Both values are returned as strings.
25
26 Values that cannot be determined are returned as given by the
27 parameter presets. If bits is given as \code{''}, the
28 \cfunction{sizeof(pointer)}
29 (or \cfunction{sizeof(long)} on Python version < 1.5.2) is used as
30 indicator for the supported pointer size.
31
32 The function relies on the system's \file{file} command to do the
33 actual work. This is available on most if not all \UNIX{}
34 platforms and some non-\UNIX{} platforms and then only if the
35 executable points to the Python interpreter. Reasonable defaults
36 are used when the above needs are not met.
37\end{funcdesc}
38
39\begin{funcdesc}{machine}{}
40 Returns the machine type, e.g. \code{'i386'}.
41
42 An empty string is returned if the value cannot be determined.
43\end{funcdesc}
44
45\begin{funcdesc}{node}{}
46 Returns the computer's network name (may not be fully qualified!)
47
48 An empty string is returned if the value cannot be determined.
49\end{funcdesc}
50
51\begin{funcdesc}{platform}{aliased=0, terse=0}
52 Returns a single string identifying the underlying platform
53 with as much useful information as possible.
54
55 The output is intended to be \emph{human readable} rather than
56 machine parseable. It may look different on different
57 platforms and this is intended.
58
59 If \code{aliased} is true, the function will use aliases for
60 various platforms that report system names which differ from
61 their common names, e.g. SunOS will be reported as
62 Solaris. The \function{system_alias()} function is used to implement
63 this.
64
65 Setting terse to true causes the function to return only the
66 absolute minimum information needed to identify the platform.
67\end{funcdesc}
68
69
70\begin{funcdesc}{processor}{}
71 Returns the (real) processor name, e.g. 'amdk6'
72
73 An empty string is returned if the value cannot be
74 determined. Note that many platforms do not provide this
75 information or simply return the same value as for \function{machine()},
76 e.g. NetBSD does this.
77\end{funcdesc}
78
79\begin{funcdesc}{python_build}{}
80 Returns a tuple \code{(buildno, builddate)} stating the Python
81 build number and date as strings.
82\end{funcdesc}
83
84\begin{funcdesc}{python_compiler}{}
85 Returns a string identifying the compiler used for compiling
86 Python.
87\end{funcdesc}
88
89\begin{funcdesc}{python_version}{}
90 Returns the Python version as string \code{'major.minor.patchlevel'}
91
92 Note that unlike the Python \code{sys.version}, the returned value
93 will always include the patchlevel (it defaults to 0).
94\end{funcdesc}
95
96\begin{funcdesc}{python_version_tuple}{}
97 Returns the Python version as tuple \code{(major, minor, patchlevel)}
98 of strings.
99
100 Note that unlike the Python \code{sys.version}, the returned value
101 will always include the patchlevel (it defaults to 0).
102\end{funcdesc}
103
104\begin{funcdesc}{release}{}
105 Returns the system's release, e.g. \code{'2.2.0'} or \code{'NT'}
106
107 An empty string is returned if the value cannot be determined.
108\end{funcdesc}
109
110\begin{funcdesc}{system}{}
111 Returns the system/OS name, e.g. \code{'Linux'}, \code{'Windows'}, or \code{'Java'}.
112
113 An empty string is returned if the value cannot be determined.
114\end{funcdesc}
115
116\begin{funcdesc}{system_alias}{system, release, version}
117 Returns \code{(system, release, version)} aliased to common
118 marketing names used for some systems.
119
120 It also does some reordering of the information in some cases
121 where it would otherwise cause confusion.
122\end{funcdesc}
123
124\begin{funcdesc}{version}{}
125 Returns the system's release version, e.g. \code{'#3 on degas'}.
126
127 An empty string is returned if the value cannot be determined.
128\end{funcdesc}
129
130\begin{funcdesc}{uname}{}
131 Fairly portable uname interface. Returns a tuple
132 of strings \code{(system, node, release, version, machine, processor)}
133 identifying the underlying platform.
134
135 Note that unlike the \function{os.uname()} function this also returns
136 possible processor information as additional tuple entry.
137
138 Entries which cannot be determined are set to \code{''}.
139\end{funcdesc}
140
141\subsection{Java Platform}
142
143\begin{funcdesc}{java_ver}{release='', vendor='', vminfo=('','',''), osinfo=('','','')}
144 Version interface for JPython.
145
146 Returns a tuple \code{(release, vendor, vminfo, osinfo)} with vminfo being
147 a tuple \code{(vm_name, vm_release, vm_vendor)} and osinfo being a
148 tuple \code{(os_name, os_version, os_arch)}.
149
150 Values which cannot be determined are set to the defaults
151 given as parameters (which all default to \code{''}).
152\end{funcdesc}
153
154\subsection{Windows Platform}
155
156\begin{funcdesc}{win32_ver}{release='', version='', csd='', ptype=''}
157 Get additional version information from the Windows Registry
158 and return a tuple \code{(version, csd, ptype)} referring to version
159 number, CSD level and OS type (multi/single processor).
160
161 As a hint: ptype returns \code{'Uniprocessor Free'} on single
162 processor NT machines and \code{'Multiprocessor Free'} on multi
163 processor machines. The \emph{'Free'} refers to the OS version being
164 free of debugging code. It could also state \emph{'Checked'} which
165 means the OS version uses debugging code, i.e. code that
166 checks arguments, ranges, etc.
167
168\begin{notice}[note]
169 This function only works if Mark Hammond's \module{win32all}
170 package is installed and (obviously) only runs on Win32
171 compatible platforms.
172\end{notice}
173
174\end{funcdesc}
175
176\subsubsection{Win95/98 specific}
177
178\begin{funcdesc}{popen}{cmd, mode='r', bufsize=None}
179 Portable \function{popen()} interface.
180 Find a working popen implementation preferring \function{win32pipe.popen}.
181 On NT \function{win32pipe} should work; on Win9x
182 it hangs due to bugs in the MS C lib.
183 \seetext{MS KnowledgeBase article Q150956.}
184\end{funcdesc}
185
186
187\subsection{Mac Platform}
188
189\begin{funcdesc}{mac_ver}{release='', versioninfo=('','',''), machine=''}
190 Get MacOS version information and return it as tuple \code{(release,
191 versioninfo, machine)} with versioninfo being a tuple \code{(version,
192 dev_stage, non_release_version)}.
193
194 Entries which cannot be determined are set to \code{''}. All tuple
195 entries are strings.
196
197 Documentation for the underlying gestalt() API is available online
198 at \url{http://www.rgaros.nl/gestalt/}
199\end{funcdesc}
200
201\subsection{\UNIX{} Platforms}
202
203\begin{funcdesc}{dist}{distname='',version='',id='',supported_dists=('SuSE','debian','redhat','mandrake')}
204 Tries to determine the name of the OS distribution name
205
206 Returns a tuple \code{(distname, version, id)} which defaults to the
207 args given as parameters.
208\end{funcdesc}
209
210
211\begin{funcdesc}{libc_ver}{executable=sys.executable, lib='', version='', chunksize=2048}
212 Tries to determine the libc version against which the
213 file executable (defaults to the Python interpreter) is linked.
214
215 Returns a tuple of strings \code{(lib, version)} which default to the
216 given parameters in case the lookup fails.
217
218 Note that the function has intimate knowledge of how different
219 libc versions add symbols to the executable is probably only
220 useable for executables compiled using \emph{gcc}.
221
222 The file is read and scanned in chunks of chunksize bytes.
223\end{funcdesc}