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 | <!ENTITY python3-download-http
|
---|
8 | "https://www.python.org/ftp/python/&python3-version;/Python-&python3-version;.tar.xz">
|
---|
9 | <!ENTITY python3-download-ftp " ">
|
---|
10 | <!ENTITY python3-md5sum "fb7f7eae520285788449d569e45b6718">
|
---|
11 | <!ENTITY python3-size "19 MB">
|
---|
12 | <!ENTITY python3-buildsize "282 MB (add 63 MB for tests)">
|
---|
13 | <!ENTITY python3-time "1.9 SBU (add 2.8 SBU for tests; both using parallelism=4)">
|
---|
14 | <!--
|
---|
15 | Note: Size does not reflect docs that were install in LFS.
|
---|
16 | -->
|
---|
17 | <!ENTITY python3htmldoc-download-http
|
---|
18 | "https://www.python.org/ftp/python/doc/&python3-version;/python-&python3-version;-docs-html.tar.bz2">
|
---|
19 | <!ENTITY python3-docs-md5sum "cdce7b1189bcf52947f3b434ab04d7e2" >
|
---|
20 | ]>
|
---|
21 |
|
---|
22 | <sect1 id="python3" xreflabel="Python-&python3-version;">
|
---|
23 | <?dbhtml filename="python3.html" ?>
|
---|
24 |
|
---|
25 |
|
---|
26 | <title>Python-&python3-version;</title>
|
---|
27 |
|
---|
28 | <indexterm zone="python3">
|
---|
29 | <primary sortas="a-Python3">Python3</primary>
|
---|
30 | </indexterm>
|
---|
31 |
|
---|
32 | <sect2 role="package">
|
---|
33 | <title>Introduction to Python 3</title>
|
---|
34 |
|
---|
35 | <para>
|
---|
36 | The <application>Python 3</application> package contains the
|
---|
37 | <application>Python</application> development environment.
|
---|
38 | This is useful for object-oriented programming, writing scripts,
|
---|
39 | prototyping large programs or developing entire applications.
|
---|
40 | </para>
|
---|
41 |
|
---|
42 | <note>
|
---|
43 | <para>
|
---|
44 | <application>Python 3</application> was installed in LFS.
|
---|
45 | The only reason to rebuild it here is if optional modules
|
---|
46 | are needed, or to upgrade this package.
|
---|
47 | </para>
|
---|
48 | </note>
|
---|
49 |
|
---|
50 | &lfs113_checked;
|
---|
51 |
|
---|
52 | <important>
|
---|
53 | <para>
|
---|
54 | If upgrading to a new Python-3 minor version (for example,
|
---|
55 | from Python-3.10.x to Python-3.11.0), you will need to reinstall
|
---|
56 | any Python3 modules you have installed. You should also
|
---|
57 | reinstall packages that generate Python3 modules
|
---|
58 | including
|
---|
59 | <xref linkend="gobject-introspection"/>,
|
---|
60 | <xref linkend="opencv"/>,
|
---|
61 | <xref linkend="graphviz"/> (if swig is installed).
|
---|
62 | </para>
|
---|
63 |
|
---|
64 | <para>Before you upgrade, you can get a list of modules installed
|
---|
65 | with <command>pip3 list</command>. The list may be incomplete as
|
---|
66 | some Python modules are not installed with <command>pip3</command>,
|
---|
67 | for example the <literal>cracklib</literal> module installed by
|
---|
68 | <xref role='nodep' linkend='cracklib'/>. Use <command>ls
|
---|
69 | /usr/lib/python3.<replaceable>minor</replaceable>/site-packages</command>
|
---|
70 | for a comprehensive list.
|
---|
71 | </para>
|
---|
72 |
|
---|
73 | <para>
|
---|
74 | The Python modules from LFS will also have to be reinstalled:
|
---|
75 | <ulink url="&lfs-root;/chapter08/flit-core.html">flit-core</ulink>,
|
---|
76 | <ulink url="&lfs-root;/chapter08/wheel.html">wheel</ulink>, and
|
---|
77 | <ulink url="&lfs-root;/chapter08/meson.html">meson</ulink>.
|
---|
78 | </para>
|
---|
79 |
|
---|
80 | <para revision="systemd">
|
---|
81 | On systemd systems, it is also necessary to reinstall
|
---|
82 | <ulink url="&lfs-root;/chapter08/markupsafe.html">MarkupSafe</ulink>
|
---|
83 | and <ulink url="&lfs-root;/chapter08/jinja2.html">Jinja2</ulink>.
|
---|
84 | </para>
|
---|
85 | </important>
|
---|
86 |
|
---|
87 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
88 | <itemizedlist spacing="compact">
|
---|
89 | <listitem>
|
---|
90 | <para>
|
---|
91 | Download (HTTP): <ulink url="&python3-download-http;"/>
|
---|
92 | </para>
|
---|
93 | </listitem>
|
---|
94 | <listitem>
|
---|
95 | <para>
|
---|
96 | Download (FTP): <ulink url="&python3-download-ftp;"/>
|
---|
97 | </para>
|
---|
98 | </listitem>
|
---|
99 | <listitem>
|
---|
100 | <para>
|
---|
101 | Download MD5 sum: &python3-md5sum;
|
---|
102 | </para>
|
---|
103 | </listitem>
|
---|
104 | <listitem>
|
---|
105 | <para>
|
---|
106 | Download size: &python3-size;
|
---|
107 | </para>
|
---|
108 | </listitem>
|
---|
109 | <listitem>
|
---|
110 | <para>
|
---|
111 | Estimated disk space required: &python3-buildsize;
|
---|
112 | </para>
|
---|
113 | </listitem>
|
---|
114 | <listitem>
|
---|
115 | <para>
|
---|
116 | Estimated build time: &python3-time;
|
---|
117 | </para>
|
---|
118 | </listitem>
|
---|
119 | </itemizedlist>
|
---|
120 |
|
---|
121 | <bridgehead renderas="sect3">Additional Optional Download</bridgehead>
|
---|
122 | <itemizedlist spacing="compact">
|
---|
123 | <listitem>
|
---|
124 | <para>
|
---|
125 | Download (HTTP): <ulink url="&python3htmldoc-download-http;"/>
|
---|
126 | </para>
|
---|
127 | </listitem>
|
---|
128 | <listitem>
|
---|
129 | <para>
|
---|
130 | Download MD5 sum: &python3-docs-md5sum;
|
---|
131 | </para>
|
---|
132 | </listitem>
|
---|
133 | </itemizedlist>
|
---|
134 |
|
---|
135 | <bridgehead renderas="sect3">Python 3 Dependencies</bridgehead>
|
---|
136 |
|
---|
137 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
138 | <para role="recommended">
|
---|
139 | <xref linkend="sqlite"/> (required if building firefox or thunderbird)
|
---|
140 | </para>
|
---|
141 |
|
---|
142 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
143 | <para role="optional">
|
---|
144 | <xref linkend="bluez"/>,
|
---|
145 | <xref linkend="gdb"/> (required for some tests),
|
---|
146 | <xref linkend="valgrind"/>, and
|
---|
147 | <ulink url="https://www.bytereef.org/mpdecimal/">libmpdec</ulink>
|
---|
148 | </para>
|
---|
149 |
|
---|
150 | <bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
|
---|
151 | <para role="optional">
|
---|
152 | <xref linkend="db"/>,
|
---|
153 | <xref linkend="libnsl"/>, and
|
---|
154 | <xref linkend="tk"/>
|
---|
155 | </para>
|
---|
156 |
|
---|
157 | <para condition="html" role="usernotes">User Notes:
|
---|
158 | <ulink url="&blfs-wiki;/Python3"/>
|
---|
159 | </para>
|
---|
160 | </sect2>
|
---|
161 |
|
---|
162 | <sect2 role="installation">
|
---|
163 | <title>Installation of Python 3</title>
|
---|
164 |
|
---|
165 | <para>
|
---|
166 | Install <application>Python 3</application> by running the following
|
---|
167 | commands:
|
---|
168 | </para>
|
---|
169 |
|
---|
170 | <screen><userinput>CXX="/usr/bin/g++" \
|
---|
171 | ./configure --prefix=/usr \
|
---|
172 | --enable-shared \
|
---|
173 | --with-system-expat \
|
---|
174 | --with-system-ffi \
|
---|
175 | --enable-optimizations &&
|
---|
176 | make</userinput></screen>
|
---|
177 |
|
---|
178 | <para>
|
---|
179 | To test the result, issue <command>make test</command>.
|
---|
180 | Some tests may need an Internet connection. Two tests, test_distutils
|
---|
181 | and test_embed are known to fail.
|
---|
182 | </para>
|
---|
183 |
|
---|
184 | <para>
|
---|
185 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
186 | </para>
|
---|
187 |
|
---|
188 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
189 |
|
---|
190 | <para>
|
---|
191 | If upgrading and the documentation has been downloaded, optionally install
|
---|
192 | it as the &root; user:
|
---|
193 | </para>
|
---|
194 |
|
---|
195 | <screen role="root"><userinput>install -v -dm755 /usr/share/doc/python-&python3-version;/html
|
---|
196 |
|
---|
197 | tar --strip-components=1 \
|
---|
198 | --no-same-owner \
|
---|
199 | --no-same-permissions \
|
---|
200 | -C /usr/share/doc/python-&python3-version;/html \
|
---|
201 | -xvf ../python-&python3-version;-docs-html.tar.bz2</userinput></screen>
|
---|
202 |
|
---|
203 | </sect2>
|
---|
204 |
|
---|
205 | <sect2 role="commands">
|
---|
206 | <title>Command Explanations</title>
|
---|
207 |
|
---|
208 | <para>
|
---|
209 | <command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
|
---|
210 | message during configuration.
|
---|
211 | </para>
|
---|
212 |
|
---|
213 | <para>
|
---|
214 | <parameter>--with-system-expat</parameter>: This switch enables linking
|
---|
215 | against the system version of <application>Expat</application>.
|
---|
216 | </para>
|
---|
217 |
|
---|
218 | <para>
|
---|
219 | <parameter>--with-system-ffi</parameter>: This switch enables linking
|
---|
220 | against the system version of <application>libffi</application>.
|
---|
221 | </para>
|
---|
222 | <!--
|
---|
223 | <para>
|
---|
224 | <parameter>- -with-ensurepip=yes</parameter> : This switch enables building
|
---|
225 | the <command>pip</command> and <command>setuptools</command> packaging
|
---|
226 | programs. <command>setuptools</command> is needed for building some
|
---|
227 | Python modules.
|
---|
228 | </para>
|
---|
229 | -->
|
---|
230 | <para>
|
---|
231 | <option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
|
---|
232 | if you want to build the <application>Python</application> DBM Module
|
---|
233 | against <application>Berkeley DB</application> instead of
|
---|
234 | <application>GDBM</application>.
|
---|
235 | </para>
|
---|
236 |
|
---|
237 | <para>
|
---|
238 | <parameter>--enable-optimizations</parameter>: This switch enables
|
---|
239 | stable, but expensive, optimizations.
|
---|
240 | </para>
|
---|
241 |
|
---|
242 | <para>
|
---|
243 | <option>--with-lto</option>: This optional switch enables thick Link
|
---|
244 | Time Optimization. Unusually, it creates a much larger <filename
|
---|
245 | class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-<arch>-linux-gnu/libpython&python3-majorver;.a</filename>
|
---|
246 | with a small increase in the time to compile
|
---|
247 | <application>Python</application>. Run-time results do not appear to show
|
---|
248 | any benefit from doing this.
|
---|
249 | </para>
|
---|
250 |
|
---|
251 | </sect2>
|
---|
252 |
|
---|
253 | <sect2 role="configuration">
|
---|
254 | <title>Configuring Python 3</title>
|
---|
255 |
|
---|
256 | <para>
|
---|
257 | In order for <command>python3</command> to find the installed
|
---|
258 | documentation, create the following version independent symlink:
|
---|
259 | </para>
|
---|
260 |
|
---|
261 | <screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
|
---|
262 |
|
---|
263 | <para>
|
---|
264 | and add the following environment variable to the individual user's or
|
---|
265 | system's profile:
|
---|
266 | </para>
|
---|
267 |
|
---|
268 | <screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
|
---|
269 |
|
---|
270 | </sect2>
|
---|
271 |
|
---|
272 | <sect2 role="content">
|
---|
273 | <title>Contents</title>
|
---|
274 |
|
---|
275 | <segmentedlist>
|
---|
276 | <segtitle>Installed Programs</segtitle>
|
---|
277 | <segtitle>Installed Libraries</segtitle>
|
---|
278 | <segtitle>Installed Directories</segtitle>
|
---|
279 |
|
---|
280 | <seglistitem>
|
---|
281 | <seg>
|
---|
282 | 2to3 (symlink) and
|
---|
283 | 2to3-&python3-majorver;,
|
---|
284 |
|
---|
285 | <!--
|
---|
286 | easy_install-&python3-majorver;,
|
---|
287 | -->
|
---|
288 |
|
---|
289 | idle3 (symlink) and
|
---|
290 | idle&python3-majorver;,
|
---|
291 |
|
---|
292 | pip3 (symlink) and
|
---|
293 | pip&python3-majorver;,
|
---|
294 |
|
---|
295 | pydoc3 and
|
---|
296 | pydoc&python3-majorver;,
|
---|
297 |
|
---|
298 | python3 (symlink);
|
---|
299 | python&python3-majorver;, and
|
---|
300 |
|
---|
301 | python3-config (symlink) and
|
---|
302 | python&python3-majorver;-config
|
---|
303 | </seg>
|
---|
304 | <seg>
|
---|
305 | libpython&python3-majorver;.so and libpython3.so
|
---|
306 | </seg>
|
---|
307 | <seg>
|
---|
308 | /usr/include/python&python3-majorver;,
|
---|
309 | /usr/lib/python&python3-majorver;, and
|
---|
310 | /usr/share/doc/python-&python3-version;
|
---|
311 | </seg>
|
---|
312 | </seglistitem>
|
---|
313 | </segmentedlist>
|
---|
314 |
|
---|
315 | <variablelist>
|
---|
316 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
317 | <?dbfo list-presentation="list"?>
|
---|
318 | <?dbhtml list-presentation="table"?>
|
---|
319 | <!--
|
---|
320 | <varlistentry id="2to3">
|
---|
321 | <term><command>2to3</command></term>
|
---|
322 | <listitem>
|
---|
323 | <para>
|
---|
324 | is designed to assist in the transition between python2 and python3
|
---|
325 | by automatically converting code to be Python3 compatible.
|
---|
326 | </para>
|
---|
327 | <indexterm zone="python3 2to3">
|
---|
328 | <primary sortas="b-2to3">2to3</primary>
|
---|
329 | </indexterm>
|
---|
330 | </listitem>
|
---|
331 | </varlistentry>
|
---|
332 | Put here for easy use when removing Python2 -->
|
---|
333 | <!--
|
---|
334 | <varlistentry id="easy_install">
|
---|
335 | <term><command>easy_install</command></term>
|
---|
336 | <listitem>
|
---|
337 | <para>
|
---|
338 | is a frontend to pip3 to make it easier to configure python modules
|
---|
339 | through the PIP package manager
|
---|
340 | </para>
|
---|
341 | <indexterm zone="python3 easy_install">
|
---|
342 | <primary sortas="python3 easy_install">easy_install</primary>
|
---|
343 | </indexterm>
|
---|
344 | </listitem>
|
---|
345 | </varlistentry>
|
---|
346 | -->
|
---|
347 | <varlistentry id="idle3">
|
---|
348 | <term><command>idle3</command></term>
|
---|
349 | <listitem>
|
---|
350 | <para>
|
---|
351 | is a wrapper script that opens a <application>Python</application>
|
---|
352 | aware GUI editor. For this script to run, you must have installed
|
---|
353 | <application>Tk</application> before Python so that the Tkinter
|
---|
354 | Python module is built
|
---|
355 | </para>
|
---|
356 | <indexterm zone="python3 idle3">
|
---|
357 | <primary sortas="b-idle3">idle3</primary>
|
---|
358 | </indexterm>
|
---|
359 | </listitem>
|
---|
360 | </varlistentry>
|
---|
361 |
|
---|
362 | <varlistentry id="pydoc3">
|
---|
363 | <term><command>pydoc3</command></term>
|
---|
364 | <listitem>
|
---|
365 | <para>
|
---|
366 | is the <application>Python</application> documentation
|
---|
367 | tool
|
---|
368 | </para>
|
---|
369 | <indexterm zone="python3 pydoc3">
|
---|
370 | <primary sortas="b-pydoc3">pydo3c</primary>
|
---|
371 | </indexterm>
|
---|
372 | </listitem>
|
---|
373 | </varlistentry>
|
---|
374 |
|
---|
375 | <varlistentry id="python3-prog">
|
---|
376 | <term><command>python3</command></term>
|
---|
377 | <listitem>
|
---|
378 | <para>
|
---|
379 | is an interpreted, interactive, object-oriented programming
|
---|
380 | language
|
---|
381 | </para>
|
---|
382 | <indexterm zone="python3 python3-prog">
|
---|
383 | <primary sortas="b-python3">python3</primary>
|
---|
384 | </indexterm>
|
---|
385 | </listitem>
|
---|
386 | </varlistentry>
|
---|
387 |
|
---|
388 | <varlistentry id="python-ver">
|
---|
389 | <term><command>python&python3-majorver;</command></term>
|
---|
390 | <listitem>
|
---|
391 | <para>
|
---|
392 | is a version-specific name for the <command>python</command>
|
---|
393 | program
|
---|
394 | </para>
|
---|
395 | <indexterm zone="python3 python-ver">
|
---|
396 | <primary sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
397 | </indexterm>
|
---|
398 | </listitem>
|
---|
399 | </varlistentry>
|
---|
400 | <!--
|
---|
401 | <varlistentry id="pyvenv">
|
---|
402 | <term><command>pyvenv</command></term>
|
---|
403 | <listitem>
|
---|
404 | <para>
|
---|
405 | creates virtual <application>Python</application> environments in
|
---|
406 | one or more target directories.
|
---|
407 | </para>
|
---|
408 | <indexterm zone="python3 pyvenv">
|
---|
409 | <primary
|
---|
410 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
411 | </indexterm>
|
---|
412 | </listitem>
|
---|
413 | </varlistentry>
|
---|
414 | -->
|
---|
415 | </variablelist>
|
---|
416 |
|
---|
417 | </sect2>
|
---|
418 |
|
---|
419 | </sect1>
|
---|