source: chapter08/python.xml@ 092b86a

12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/mips64el
Last change on this file since 092b86a was 7152faa, checked in by Pierre Labastie <pierre.labastie@…>, 5 months ago

Change all xml files to utf-8 encoding

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