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, or developing entire applications.</para>
|
---|
29 |
|
---|
30 | <segmentedlist>
|
---|
31 | <segtitle>&buildtime;</segtitle>
|
---|
32 | <segtitle>&diskspace;</segtitle>
|
---|
33 |
|
---|
34 | <seglistitem>
|
---|
35 | <seg>&python-fin-sbu;</seg>
|
---|
36 | <seg>&python-fin-du;</seg>
|
---|
37 | </seglistitem>
|
---|
38 | </segmentedlist>
|
---|
39 |
|
---|
40 | </sect2>
|
---|
41 |
|
---|
42 | <sect2 role="installation">
|
---|
43 | <title>Installation of Python 3</title>
|
---|
44 |
|
---|
45 | <para>Prepare Python for compilation:</para>
|
---|
46 |
|
---|
47 | <screen><userinput remap="configure">./configure --prefix=/usr \
|
---|
48 | --enable-shared \
|
---|
49 | --with-system-expat \
|
---|
50 | --with-system-ffi \
|
---|
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 system version of
|
---|
60 | <application>Expat</application>.</para>
|
---|
61 | </listitem>
|
---|
62 | </varlistentry>
|
---|
63 |
|
---|
64 | <varlistentry>
|
---|
65 | <term><parameter>--with-system-ffi</parameter></term>
|
---|
66 | <listitem>
|
---|
67 | <para>This switch enables linking against system version of
|
---|
68 | <application>libffi</application>.</para>
|
---|
69 | </listitem>
|
---|
70 | </varlistentry>
|
---|
71 |
|
---|
72 | <varlistentry>
|
---|
73 | <term><parameter>--enable-optimizations</parameter></term>
|
---|
74 | <listitem>
|
---|
75 | <para>This switch enables stable, but expensive, optimizations.</para>
|
---|
76 | </listitem>
|
---|
77 | </varlistentry>
|
---|
78 |
|
---|
79 | </variablelist>
|
---|
80 |
|
---|
81 | <para>Compile the package:</para>
|
---|
82 |
|
---|
83 | <screen><userinput remap="make">make</userinput></screen>
|
---|
84 |
|
---|
85 | <para>Running the tests at this point is not recommended. The
|
---|
86 | tests are known to hang indefinitely in the partial LFS environment.
|
---|
87 | If desired, the tests can be rerun at the end of this chapter or
|
---|
88 | when Python 3 is reinstalled in BLFS. To run the tests anyway,
|
---|
89 | issue <command>make test</command>.</para>
|
---|
90 |
|
---|
91 | <para>Install the package:</para>
|
---|
92 |
|
---|
93 | <screen><userinput remap="install">make install</userinput></screen>
|
---|
94 |
|
---|
95 | <para>In several places we use the <command>pip3</command> command to
|
---|
96 | install Python 3 programs and modules for all users as
|
---|
97 | <systemitem class='username'>root</systemitem>. This conflicts
|
---|
98 | with the Python developers recommendation to install packages into a
|
---|
99 | virtual environment or the home directory of a regular user (by running
|
---|
100 | <command>pip3</command> as this user). To this end, a multi-line warning
|
---|
101 | is written when using <command>pip3</command> as the
|
---|
102 | <systemitem class='username'>root</systemitem> user. The main reason
|
---|
103 | of this recommendation is for avoiding a conflict with the system
|
---|
104 | package manager (<command>dpkg</command> for example), but LFS does not
|
---|
105 | have a system-wide package manager so this is not a problem. If desired,
|
---|
106 | suppress this warning by running the following commands:</para>
|
---|
107 |
|
---|
108 | <screen><userinput remap="install">cat > /etc/pip.conf << EOF
|
---|
109 | [global]
|
---|
110 | root-user-action = ignore
|
---|
111 | EOF
|
---|
112 | </userinput></screen>
|
---|
113 | <!--
|
---|
114 | <screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
|
---|
115 | -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
|
---|
116 | </userinput></screen>
|
---|
117 | -->
|
---|
118 | <important>
|
---|
119 | <para>
|
---|
120 | In LFS and BLFS we normally build and install Python modules with the
|
---|
121 | <command>pip3</command> command. Please take care that the
|
---|
122 | <command>pip3 install</command> commands in both the books should be
|
---|
123 | run as the &root; user unless it's for a Python virtual environment.
|
---|
124 | Running a <command>pip3 install</command> as a non-&root; user may seem
|
---|
125 | to work fine, but it will cause the installed module to be inaccessible
|
---|
126 | by other users.
|
---|
127 | </para>
|
---|
128 |
|
---|
129 | <para>
|
---|
130 | <command>pip3 install</command> will not reinstall an already installed
|
---|
131 | module by default. For using the <command>pip3 install</command>
|
---|
132 | command to upgrade a module (for example, from meson-0.61.3 to
|
---|
133 | meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
|
---|
134 | the command line. If it's really necessary to downgrade a module or
|
---|
135 | reinstall the same version for some reason, insert
|
---|
136 | <parameter>--force-reinstall --no-deps</parameter> into the command
|
---|
137 | line.
|
---|
138 | </para>
|
---|
139 | </important>
|
---|
140 |
|
---|
141 | <para>If desired, install the preformatted documentation:</para>
|
---|
142 |
|
---|
143 | <screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
|
---|
144 |
|
---|
145 | tar --strip-components=1 \
|
---|
146 | --no-same-owner \
|
---|
147 | --no-same-permissions \
|
---|
148 | -C /usr/share/doc/python-&python-version;/html \
|
---|
149 | -xvf ../python-&python-version;-docs-html.tar.bz2</userinput></screen>
|
---|
150 |
|
---|
151 | <variablelist>
|
---|
152 | <title>The meaning of the documentation install commands:</title>
|
---|
153 |
|
---|
154 | <varlistentry>
|
---|
155 | <term><option>--no-same-owner</option> and <option>--no-same-permissions</option></term>
|
---|
156 | <listitem>
|
---|
157 | <para>Ensure the installed files have the correct ownership and
|
---|
158 | permissions. Without these options, using <application>tar</application>
|
---|
159 | will install the package files with the upstream creator's values.
|
---|
160 | </para>
|
---|
161 | </listitem>
|
---|
162 | </varlistentry>
|
---|
163 |
|
---|
164 | </variablelist>
|
---|
165 |
|
---|
166 | </sect2>
|
---|
167 |
|
---|
168 | <sect2 id="contents-python" role="content">
|
---|
169 | <title>Contents of Python 3</title>
|
---|
170 |
|
---|
171 | <segmentedlist>
|
---|
172 | <segtitle>Installed Programs</segtitle>
|
---|
173 | <segtitle>Installed Library</segtitle>
|
---|
174 | <segtitle>Installed Directories</segtitle>
|
---|
175 |
|
---|
176 | <seglistitem>
|
---|
177 | <seg>
|
---|
178 | 2to3, idle3, pip3, pydoc3, python3, and python3-config
|
---|
179 | </seg>
|
---|
180 | <seg>
|
---|
181 | libpython&python-minor;.so and libpython3.so
|
---|
182 | </seg>
|
---|
183 | <seg>
|
---|
184 | /usr/include/python&python-minor;,
|
---|
185 | /usr/lib/python3, and
|
---|
186 | /usr/share/doc/python-&python-version;
|
---|
187 | </seg>
|
---|
188 | </seglistitem>
|
---|
189 | </segmentedlist>
|
---|
190 |
|
---|
191 | <variablelist>
|
---|
192 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
193 | <?dbfo list-presentation="list"?>
|
---|
194 | <?dbhtml list-presentation="table"?>
|
---|
195 |
|
---|
196 | <varlistentry id="python-2to3">
|
---|
197 | <term><command>2to3</command></term>
|
---|
198 | <listitem>
|
---|
199 | <para>
|
---|
200 | is a <application>Python</application> program that reads
|
---|
201 | <application>Python 2.x</application> source code and applies a
|
---|
202 | series of fixes to transform it into
|
---|
203 | valid <application>Python 3.x</application> code
|
---|
204 | </para>
|
---|
205 | <indexterm zone="ch-system-Python">
|
---|
206 | <primary sortas="b-2to3">2to3</primary>
|
---|
207 | </indexterm>
|
---|
208 | </listitem>
|
---|
209 | </varlistentry>
|
---|
210 |
|
---|
211 | <varlistentry id="idle3">
|
---|
212 | <term><command>idle3</command></term>
|
---|
213 | <listitem>
|
---|
214 | <para>
|
---|
215 | is a wrapper script that opens a <application>Python</application>
|
---|
216 | aware GUI editor. For this script to run, you must have installed
|
---|
217 | <application>Tk</application> before Python so that the Tkinter
|
---|
218 | Python module is built
|
---|
219 | </para>
|
---|
220 | <indexterm zone="ch-system-Python">
|
---|
221 | <primary sortas="b-idle3">idle3</primary>
|
---|
222 | </indexterm>
|
---|
223 | </listitem>
|
---|
224 | </varlistentry>
|
---|
225 |
|
---|
226 | <varlistentry id="pip3">
|
---|
227 | <term><command>pip3</command></term>
|
---|
228 | <listitem>
|
---|
229 | <para>
|
---|
230 | The package installer for Python. You can use pip to install
|
---|
231 | packages from Python Package Index and other indexes
|
---|
232 | </para>
|
---|
233 | <indexterm zone="ch-system-Python">
|
---|
234 | <primary sortas="b-pip3">pip3</primary>
|
---|
235 | </indexterm>
|
---|
236 | </listitem>
|
---|
237 | </varlistentry>
|
---|
238 |
|
---|
239 | <varlistentry id="pydoc3">
|
---|
240 | <term><command>pydoc3</command></term>
|
---|
241 | <listitem>
|
---|
242 | <para>
|
---|
243 | is the <application>Python</application> documentation tool
|
---|
244 | </para>
|
---|
245 | <indexterm zone="ch-system-Python">
|
---|
246 | <primary sortas="b-pydoc3">pydoc3</primary>
|
---|
247 | </indexterm>
|
---|
248 | </listitem>
|
---|
249 | </varlistentry>
|
---|
250 |
|
---|
251 | <varlistentry id="python3">
|
---|
252 | <term><command>python3</command></term>
|
---|
253 | <listitem>
|
---|
254 | <para>
|
---|
255 | is an interpreted, interactive, object-oriented programming
|
---|
256 | language
|
---|
257 | </para>
|
---|
258 | <indexterm zone="ch-system-Python">
|
---|
259 | <primary sortas="b-python3">python3</primary>
|
---|
260 | </indexterm>
|
---|
261 | </listitem>
|
---|
262 | </varlistentry>
|
---|
263 |
|
---|
264 | </variablelist>
|
---|
265 |
|
---|
266 | </sect2>
|
---|
267 |
|
---|
268 | </sect1>
|
---|
269 |
|
---|