source: chapter08/python.xml@ 70f30e9

xry111/arm64 xry111/arm64-12.0
Last change on this file since 70f30e9 was 30f5283, checked in by Xi Ruoyao <xry111@…>, 18 months ago

python: style "libffi.so" correctly

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