source: chapter08/python.xml

trunk
Last change on this file was 6a75210, checked in by Xi Ruoyao <xry111@…>, 3 weeks ago

python: Document test failures with recent expat

I didn't see them because I misconfigured Python to use internal expat.
With system expat they just fail as we've documented in BLFS.

  • Property mode set to 100644
File size: 10.5 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
6]>
7
8<sect1 id="ch-system-Python" role="wrap">
9 <?dbhtml filename="Python.html"?>
10
11 <sect1info condition="script">
12 <productname>Python</productname>
13 <productnumber>&python-version;</productnumber>
14 <address>&python-url;</address>
15 </sect1info>
16
17 <title>Python-&python-version;</title>
18
19 <indexterm zone="ch-system-Python">
20 <primary sortas="a-Python">Python</primary>
21 </indexterm>
22
23 <sect2 role="package">
24 <title/>
25
26 <para>The Python 3 package contains the Python development environment. It
27 is useful for object-oriented programming, writing scripts, prototyping
28 large programs, and developing entire applications. Python is an interpreted
29 computer language.</para>
30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
36 <seg>&python-fin-sbu;</seg>
37 <seg>&python-fin-du;</seg>
38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Python 3</title>
45
46 <para>Prepare Python for compilation:</para>
47
48<screen><userinput remap="configure">./configure --prefix=/usr \
49 --enable-shared \
50 --with-system-expat \
51 --enable-optimizations</userinput></screen>
52
53 <variablelist>
54 <title>The meaning of the configure options:</title>
55
56 <varlistentry>
57 <term><parameter>--with-system-expat</parameter></term>
58 <listitem>
59 <para>This switch enables linking against the system version of
60 <application>Expat</application>.</para>
61 </listitem>
62 </varlistentry>
63
64 <varlistentry>
65 <term><parameter>--enable-optimizations</parameter></term>
66 <listitem>
67 <para>This switch enables extensive, but time-consuming, optimization
68 steps. The interpreter is built twice; tests performed on the first
69 build are used to improve the optimized final version.</para>
70 <!-- This description was drawn from the README.rst file
71 in the Python-3.11.0 package. -->
72 </listitem>
73 </varlistentry>
74
75 </variablelist>
76
77 <para>Compile the package:</para>
78
79<screen><userinput remap="make">make</userinput></screen>
80
81 <para>Some tests are known to occasionally hang indefinitely. So to test the
82 results, run the test suite but set a 2-minute time limit for each
83 test case:</para>
84
85<screen><userinput remap="test">make test TESTOPTS="--timeout 120"</userinput></screen>
86
87 <para>For a relatively slow system you may need to increase the time
88 limit and 1 SBU (measured when building Binutils pass 1 with one CPU
89 core) should be enough. Some tests are flaky, so the test suite will
90 automatically re-run failed tests. If a test failed but then passed
91 when re-run, it should be considered as passed.</para>
92
93 <para>Two tests named <filename>test_xml_etree</filename> and
94 <filename>test_xml_etree_c</filename> are known to fail with expat-2.6.0
95 or newer.</para>
96
97 <para>Install the package:</para>
98
99<screen><userinput remap="install">make install</userinput></screen>
100
101 <para>We use the <command>pip3</command> command to
102 install Python 3 programs and modules for all users as
103 <systemitem class='username'>root</systemitem> in several places in this book.
104 This conflicts with the Python developers' recommendation: to install packages into a
105 virtual environment, or into the home directory of a regular user (by running
106 <command>pip3</command> as this user). A multi-line warning
107 is triggered whenever <command>pip3</command> is issued by the
108 <systemitem class='username'>root</systemitem> user.</para>
109
110 <para>The main reason
111 for the recommendation is to avoid conflicts with the system's
112 package manager (<command>dpkg</command>, for example). LFS does not
113 have a system-wide package manager, so this is not a problem. Also,
114 <command>pip3</command> will check for a new version of
115 itself whenever it's run. Since domain name resolution is not yet configured
116 in the LFS chroot environment, <command>pip3</command> cannot check
117 for a new version of itself, and will
118 produce a warning. </para>
119
120 <para>After we boot the LFS system and set up a network connection,
121 a different warning will be issued, telling the user to update <command>pip3</command>
122 from a pre-built wheel on PyPI (whenever a new version is available). But LFS
123 considers <command>pip3</command> to be a part of Python 3, so it should not be
124 updated separately. Also, an update from a pre-built wheel would deviate
125 from our objective: to build a Linux system from source code. So the
126 warning about a new version of <command>pip3</command> should be ignored as
127 well. If you wish, you can suppress all these warnings by running the following
128 command, which creates a configuration file:</para>
129
130<screen><userinput remap="install">cat &gt; /etc/pip.conf &lt;&lt; EOF
131<literal>[global]
132root-user-action = ignore
133disable-pip-version-check = true</literal>
134EOF
135</userinput></screen>
136<!--
137<screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
138 -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
139</userinput></screen>
140-->
141 <important>
142 <para>
143 In LFS and BLFS we normally build and install Python modules with the
144 <command>pip3</command> command. Please be sure that the
145 <command>pip3 install</command> commands in both books are
146 run as the &root; user (unless it's for a Python virtual environment).
147 Running <command>pip3 install</command> as a non-&root; user may seem
148 to work, but it will cause the installed module to be inaccessible
149 by other users.
150 </para>
151
152 <para>
153 <command>pip3 install</command> will not reinstall an already installed
154 module automatically. When using the <command>pip3 install</command>
155 command to upgrade a module (for example, from meson-0.61.3 to
156 meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
157 the command line. If it's really necessary to downgrade a module, or
158 reinstall the same version for some reason, insert
159 <parameter>--force-reinstall --no-deps</parameter> into the command
160 line.
161 </para>
162 </important>
163
164 <para>If desired, install the preformatted documentation:</para>
165
166<screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
167
168tar --no-same-owner \
169 -xvf ../python-&python-version;-docs-html.tar.bz2
170cp -R --no-preserve=mode python-&python-version;-docs-html/* \
171 /usr/share/doc/python-&python-version;/html</userinput></screen>
172
173 <variablelist>
174 <title>The meaning of the documentation install commands:</title>
175
176 <varlistentry>
177 <term><option>--no-same-owner</option> (tar) and <option>--no-preserve=mode</option> (cp)</term>
178 <listitem>
179 <para>Ensure the installed files have the correct ownership and
180 permissions. Without these options, <application>tar</application>
181 will install the package files with the upstream creator's values
182 and files would have restrictive permissions.
183 </para>
184 </listitem>
185 </varlistentry>
186
187 </variablelist>
188
189 </sect2>
190
191 <sect2 id="contents-python" role="content">
192 <title>Contents of Python 3</title>
193
194 <segmentedlist>
195 <segtitle>Installed programs</segtitle>
196 <segtitle>Installed library</segtitle>
197 <segtitle>Installed directories</segtitle>
198
199 <seglistitem>
200 <seg>
201 2to3, idle3, pip3, pydoc3, python3, and python3-config
202 </seg>
203 <seg>
204 libpython&python-minor;.so and libpython3.so
205 </seg>
206 <seg>
207 /usr/include/python&python-minor;,
208 /usr/lib/python3, and
209 /usr/share/doc/python-&python-version;
210 </seg>
211 </seglistitem>
212 </segmentedlist>
213
214 <variablelist>
215 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
216 <?dbfo list-presentation="list"?>
217 <?dbhtml list-presentation="table"?>
218
219 <varlistentry id="python-2to3">
220 <term><command>2to3</command></term>
221 <listitem>
222 <para>
223 is a <application>Python</application> program that reads
224 <application>Python 2.x</application> source code and applies a
225 series of fixes to transform it into
226 valid <application>Python 3.x</application> code
227 </para>
228 <indexterm zone="ch-system-Python">
229 <primary sortas="b-2to3">2to3</primary>
230 </indexterm>
231 </listitem>
232 </varlistentry>
233
234 <varlistentry id="idle3">
235 <term><command>idle3</command></term>
236 <listitem>
237 <para>
238 is a wrapper script that opens a <application>Python</application>
239 aware GUI editor. For this script to run, you must have installed
240 <application>Tk</application> before Python, so that the Tkinter
241 Python module is built.
242 </para>
243 <indexterm zone="ch-system-Python">
244 <primary sortas="b-idle3">idle3</primary>
245 </indexterm>
246 </listitem>
247 </varlistentry>
248
249 <varlistentry id="pip3">
250 <term><command>pip3</command></term>
251 <listitem>
252 <para>
253 The package installer for Python. You can use pip to install
254 packages from Python Package Index and other indexes.
255 </para>
256 <indexterm zone="ch-system-Python">
257 <primary sortas="b-pip3">pip3</primary>
258 </indexterm>
259 </listitem>
260 </varlistentry>
261
262 <varlistentry id="pydoc3">
263 <term><command>pydoc3</command></term>
264 <listitem>
265 <para>
266 is the <application>Python</application> documentation tool
267 </para>
268 <indexterm zone="ch-system-Python">
269 <primary sortas="b-pydoc3">pydoc3</primary>
270 </indexterm>
271 </listitem>
272 </varlistentry>
273
274 <varlistentry id="python3">
275 <term><command>python3</command></term>
276 <listitem>
277 <para>
278 is the interpreter for Python, an interpreted, interactive,
279 object-oriented programming language
280 </para>
281 <indexterm zone="ch-system-Python">
282 <primary sortas="b-python3">python3</primary>
283 </indexterm>
284 </listitem>
285 </varlistentry>
286
287 </variablelist>
288
289 </sect2>
290
291</sect1>
292
Note: See TracBrowser for help on using the repository browser.