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