source: chapter08/python.xml@ 5f54f8e

xry111/loongarch xry111/loongarch-12.2
Last change on this file since 5f54f8e was a600e72, checked in by Xi Ruoyao <xry111@…>, 6 weeks ago

loongarch: Document a known failure

  • Property mode set to 100644
File size: 10.7 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 <!-- https://github.com/python/cpython/pull/120227
94 The typical page size of LoongArch Linux is 16 KiB so this issu
95 can be triggered. -->
96 <para>One test named <literal>test.test_asyncio.test_sendfile</literal>
97 is known to fail depending on the version and configuration of the host
98 kernel.</para>
99
100 <para>Install the package:</para>
101
102<screen><userinput remap="install">make install</userinput></screen>
103
104 <para>We use the <command>pip3</command> command to
105 install Python 3 programs and modules for all users as
106 <systemitem class='username'>root</systemitem> in several places in this book.
107 This conflicts with the Python developers' recommendation: to install packages into a
108 virtual environment, or into the home directory of a regular user (by running
109 <command>pip3</command> as this user). A multi-line warning
110 is triggered whenever <command>pip3</command> is issued by the
111 <systemitem class='username'>root</systemitem> user.</para>
112
113 <para>The main reason
114 for the recommendation is to avoid conflicts with the system's
115 package manager (<command>dpkg</command>, for example). LFS does not
116 have a system-wide package manager, so this is not a problem. Also,
117 <command>pip3</command> will check for a new version of
118 itself whenever it's run. Since domain name resolution is not yet configured
119 in the LFS chroot environment, <command>pip3</command> cannot check
120 for a new version of itself, and will
121 produce a warning. </para>
122
123 <para>After we boot the LFS system and set up a network connection,
124 a different warning will be issued, telling the user to update <command>pip3</command>
125 from a pre-built wheel on PyPI (whenever a new version is available). But LFS
126 considers <command>pip3</command> to be a part of Python 3, so it should not be
127 updated separately. Also, an update from a pre-built wheel would deviate
128 from our objective: to build a Linux system from source code. So the
129 warning about a new version of <command>pip3</command> should be ignored as
130 well. If you wish, you can suppress all these warnings by running the following
131 command, which creates a configuration file:</para>
132
133<screen><userinput remap="install">cat &gt; /etc/pip.conf &lt;&lt; EOF
134<literal>[global]
135root-user-action = ignore
136disable-pip-version-check = true</literal>
137EOF
138</userinput></screen>
139<!--
140<screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
141 -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
142</userinput></screen>
143-->
144 <important>
145 <para>
146 In LFS and BLFS we normally build and install Python modules with the
147 <command>pip3</command> command. Please be sure that the
148 <command>pip3 install</command> commands in both books are
149 run as the &root; user (unless it's for a Python virtual environment).
150 Running <command>pip3 install</command> as a non-&root; user may seem
151 to work, but it will cause the installed module to be inaccessible
152 by other users.
153 </para>
154
155 <para>
156 <command>pip3 install</command> will not reinstall an already installed
157 module automatically. When using the <command>pip3 install</command>
158 command to upgrade a module (for example, from meson-0.61.3 to
159 meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
160 the command line. If it's really necessary to downgrade a module, or
161 reinstall the same version for some reason, insert
162 <parameter>--force-reinstall --no-deps</parameter> into the command
163 line.
164 </para>
165 </important>
166
167 <para>If desired, install the preformatted documentation:</para>
168
169<screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
170
171tar --no-same-owner \
172 -xvf ../python-&python-version;-docs-html.tar.bz2
173cp -R --no-preserve=mode python-&python-version;-docs-html/* \
174 /usr/share/doc/python-&python-version;/html</userinput></screen>
175
176 <variablelist>
177 <title>The meaning of the documentation install commands:</title>
178
179 <varlistentry>
180 <term><option>--no-same-owner</option> (tar) and <option>--no-preserve=mode</option> (cp)</term>
181 <listitem>
182 <para>Ensure the installed files have the correct ownership and
183 permissions. Without these options, <application>tar</application>
184 will install the package files with the upstream creator's values
185 and files would have restrictive permissions.
186 </para>
187 </listitem>
188 </varlistentry>
189
190 </variablelist>
191
192 </sect2>
193
194 <sect2 id="contents-python" role="content">
195 <title>Contents of Python 3</title>
196
197 <segmentedlist>
198 <segtitle>Installed programs</segtitle>
199 <segtitle>Installed library</segtitle>
200 <segtitle>Installed directories</segtitle>
201
202 <seglistitem>
203 <seg>
204 2to3, idle3, pip3, pydoc3, python3, and python3-config
205 </seg>
206 <seg>
207 libpython&python-minor;.so and libpython3.so
208 </seg>
209 <seg>
210 /usr/include/python&python-minor;,
211 /usr/lib/python3, and
212 /usr/share/doc/python-&python-version;
213 </seg>
214 </seglistitem>
215 </segmentedlist>
216
217 <variablelist>
218 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
219 <?dbfo list-presentation="list"?>
220 <?dbhtml list-presentation="table"?>
221
222 <varlistentry id="python-2to3">
223 <term><command>2to3</command></term>
224 <listitem>
225 <para>
226 is a <application>Python</application> program that reads
227 <application>Python 2.x</application> source code and applies a
228 series of fixes to transform it into
229 valid <application>Python 3.x</application> code
230 </para>
231 <indexterm zone="ch-system-Python">
232 <primary sortas="b-2to3">2to3</primary>
233 </indexterm>
234 </listitem>
235 </varlistentry>
236
237 <varlistentry id="idle3">
238 <term><command>idle3</command></term>
239 <listitem>
240 <para>
241 is a wrapper script that opens a <application>Python</application>
242 aware GUI editor. For this script to run, you must have installed
243 <application>Tk</application> before Python, so that the Tkinter
244 Python module is built.
245 </para>
246 <indexterm zone="ch-system-Python">
247 <primary sortas="b-idle3">idle3</primary>
248 </indexterm>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry id="pip3">
253 <term><command>pip3</command></term>
254 <listitem>
255 <para>
256 The package installer for Python. You can use pip to install
257 packages from Python Package Index and other indexes.
258 </para>
259 <indexterm zone="ch-system-Python">
260 <primary sortas="b-pip3">pip3</primary>
261 </indexterm>
262 </listitem>
263 </varlistentry>
264
265 <varlistentry id="pydoc3">
266 <term><command>pydoc3</command></term>
267 <listitem>
268 <para>
269 is the <application>Python</application> documentation tool
270 </para>
271 <indexterm zone="ch-system-Python">
272 <primary sortas="b-pydoc3">pydoc3</primary>
273 </indexterm>
274 </listitem>
275 </varlistentry>
276
277 <varlistentry id="python3">
278 <term><command>python3</command></term>
279 <listitem>
280 <para>
281 is the interpreter for Python, an interpreted, interactive,
282 object-oriented programming language
283 </para>
284 <indexterm zone="ch-system-Python">
285 <primary sortas="b-python3">python3</primary>
286 </indexterm>
287 </listitem>
288 </varlistentry>
289
290 </variablelist>
291
292 </sect2>
293
294</sect1>
295
Note: See TracBrowser for help on using the repository browser.