source: general/prog/python3.xml@ 336d81c3

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 336d81c3 was 336d81c3, checked in by Xi Ruoyao <xry111@…>, 4 years ago

use python-majorver instead of hardcoding '3.8' everywhere

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@22844 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 12.5 KB
RevLine 
[52d29f7]1<?xml version="1.0" encoding="ISO-8859-1"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[52d29f7]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
[2cee003]7 <!ENTITY python3-download-http
[3f89ec5]8 "https://www.python.org/ftp/python/&python3-version;/Python-&python3-version;.tar.xz">
[355495ce]9 <!ENTITY python3-download-ftp " ">
[1b9f28f]10 <!ENTITY python3-md5sum "e9d6ebc92183a177b8e8a58cad5b8d67">
[9e91b25]11 <!ENTITY python3-size "17 MB">
[1b9f28f]12 <!ENTITY python3-buildsize "193 MB (add 27 MB for tests)">
13 <!ENTITY python3-time "0.5 SBU (using parallelism=4; add 1.6 SBU for tests, including rebuilding)">
[e882fc37]14 <!--
[73353e7f]15
16 Note: Size does not reflect docs that were install in LFS.
17
[2cee003]18 <!ENTITY python3htmldoc-download-http
[e882fc37]19 "https://docs.python.org/ftp/python/doc/&python3-version;/python-&python3-version;-docs-html.tar.bz2"> -->
[52d29f7]20]>
21
[b88be39]22<sect1 id="python3" xreflabel="Python-&python3-version;">
23 <?dbhtml filename="python3.html" ?>
[83f69e5d]24
25 <sect1info>
26 <othername>$LastChangedBy$</othername>
27 <date>$Date$</date>
28 </sect1info>
29
[b88be39]30 <title>Python-&python3-version;</title>
[83f69e5d]31
[b88be39]32 <indexterm zone="python3">
[03d30cf]33 <primary sortas="a-Python3">Python3</primary>
[83f69e5d]34 </indexterm>
35
36 <sect2 role="package">
[03d30cf]37 <title>Introduction to Python 3</title>
[83f69e5d]38
[355495ce]39 <para>
[03d30cf]40 The <application>Python 3</application> package contains the
[355495ce]41 <application>Python</application> development environment.
42 This is useful for object-oriented programming, writing scripts,
43 prototyping large programs or developing entire applications.
44 </para>
[48b816cb]45
[de33b2a]46 <note>
47 <para>
48 <application>Python 3</application> was installed in LFS.
49 The only reason to rebuild it here is if optional modules
50 are needed.
51 </para>
52 </note>
[60ddbaf]53
[1119387]54 &lfs91_checked;
[48b816cb]55
[83f69e5d]56 <bridgehead renderas="sect3">Package Information</bridgehead>
57 <itemizedlist spacing="compact">
58 <listitem>
[355495ce]59 <para>
60 Download (HTTP): <ulink url="&python3-download-http;"/>
61 </para>
[83f69e5d]62 </listitem>
63 <listitem>
[355495ce]64 <para>
65 Download (FTP): <ulink url="&python3-download-ftp;"/>
66 </para>
[83f69e5d]67 </listitem>
68 <listitem>
[355495ce]69 <para>
70 Download MD5 sum: &python3-md5sum;
71 </para>
[83f69e5d]72 </listitem>
73 <listitem>
[355495ce]74 <para>
75 Download size: &python3-size;
76 </para>
[83f69e5d]77 </listitem>
78 <listitem>
[355495ce]79 <para>
80 Estimated disk space required: &python3-buildsize;
81 </para>
[83f69e5d]82 </listitem>
83 <listitem>
[355495ce]84 <para>
85 Estimated build time: &python3-time;
86 </para>
[83f69e5d]87 </listitem>
88 </itemizedlist>
[e882fc37]89
[03d30cf]90 <bridgehead renderas="sect3">Python 3 Dependencies</bridgehead>
[e882fc37]91
[83f69e5d]92 <bridgehead renderas="sect4">Optional</bridgehead>
[355495ce]93 <para role="optional">
[7fe0ce3b]94 <xref linkend="bluez"/>,
[e882fc37]95 <xref linkend="gdb"/> (required for some tests),
96 <xref linkend="valgrind"/>, and
[7ffeb4bd]97 <ulink url="http://www.bytereef.org/mpdecimal">libmpdec</ulink>
[355495ce]98 </para>
99
100 <bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
101 <para role="optional">
[6030130]102 <xref linkend="db"/>,
103 <xref linkend="sqlite"/>, and
104 <xref linkend="tk"/>
[355495ce]105 </para>
[ce33273]106
[1039de3]107 <para condition="html" role="usernotes">User Notes:
[355495ce]108 <ulink url="&blfs-wiki;/Python3"/>
109 </para>
[83f69e5d]110 </sect2>
111
112 <sect2 role="installation">
[03d30cf]113 <title>Installation of Python 3</title>
[83f69e5d]114
[355495ce]115 <para>
[03d30cf]116 Install <application>Python 3</application> by running the following
[355495ce]117 commands:
118 </para>
[83f69e5d]119
[fd69a62]120<screen><userinput>CXX="/usr/bin/g++" \
121./configure --prefix=/usr \
[c525bd1]122 --enable-shared \
[355495ce]123 --with-system-expat \
[fd69a62]124 --with-system-ffi \
[879932f]125 --with-ensurepip=yes &amp;&amp;
[83f69e5d]126make</userinput></screen>
127
[355495ce]128 <para>
[7fe0ce3b]129 The test suite must be run separately, using an X terminal (see below).
[355495ce]130 </para>
131
132 <para>
133 Now, as the <systemitem class="username">root</systemitem> user:
134 </para>
135
[82fac2c]136<screen role="root"><userinput>make install &amp;&amp;
[d10196e0]137<!--ln -sfv pip&python3-majorver; /usr/bin/pip3 &amp;&amp;-->
[9e91b25]138chmod -v 755 /usr/lib/libpython&python3-majorver;.so &amp;&amp;
[355495ce]139chmod -v 755 /usr/lib/libpython3.so</userinput></screen>
[1970f00]140
[7fe0ce3b]141 <para>
142 The test suite must be run separately from the build, either before or
[7745345d]143 after the package is built and installed. Do not run
[af8a78d]144 <command>make install</command> after running the test suite. To build
[7745345d]145 and install the package, you need to start with a fresh or clean source
[e882fc37]146 tree. For the tests, you also need a clean source code, so either start by
[7745345d]147 removing the source code directory and starting over, by uncompressing
148 the source tarball or by running <command>make clean</command>. Then
149 configure again, adding <quote>--with-pydebug</quote> to the
150 <command>configure</command> switches above, run <command>make</command>,
[d7d743f0]151 then <command>make test</command>. Remember that tests must be executed
[73353e7f]152 using an X terminal.
153 The test SBU highly depends on the speed of the internet connection.
[9e91b25]154 The test_sqlite test is known to fail.
[7fe0ce3b]155 </para>
156
[879d269]157 </sect2>
158
159 <sect2 role="commands">
160 <title>Command Explanations</title>
161
[fd69a62]162 <para>
163 <command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
164 message during configuration.
165 </para>
166
[355495ce]167 <para>
[f1d7196]168 <parameter>--with-system-expat</parameter>: This switch enables linking
169 against the system version of <application>Expat</application>.
[355495ce]170 </para>
171
172 <para>
[f1d7196]173 <parameter>--with-system-ffi</parameter>: This switch enables linking
[60ddbaf]174 against system version of <application>libffi</application>.
[82fac2c]175 </para>
[fd69a62]176
177 <para>
[23c5563]178 <parameter>--with-ensurepip=yes</parameter> : This switch enables building
179 <command>pip</command> and <command>setuptools</command> packaging programs.
180 <command>setuptools</command> is needed for building some Python modules.
[fd69a62]181 </para>
[82fac2c]182
[f1d7196]183 <para>
184 <option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
185 if you want to build <application>Python</application> DBM Module
186 against <application>Berkeley DB</application> instead of
187 <application>GDBM</application>.
188 </para>
189
[7c57f82]190 <para>
191 <option>--enable-optimization</option>: Use this switch
192 if you want to enable <emphasis>expensive</emphasis> optimizations (i.e.
193 Profile Guided Optimizations). This adds around 20 SBU, but can
194 <emphasis>slightly</emphasis> speed up some uses, such as using
195 <application>Sphinx</application> for creating documentation, or use of
196 <application>Python3</application> scripts.
197 </para>
198
199 <para>
200 <option>--with-lto</option>: This optional switch enables thick Link
201 Time Optimization. Unusually, it creates a much larger <filename
[336d81c3]202 class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-x86_64-linux-gnu/libpython&python3-majorver;.a</filename>
[7c57f82]203 with a small increase in the time to compile
204 <application>Python</application>. Run-time results do not appear to show
205 any benefit from doing this.
206 </para>
[d10196e0]207 <!--
[56da2817]208 <para>
209 <command>ln -sfv ...</command>: When upgrading to Python-3.8, it was
210 discovered that the symlink to pip3 is sometimes not created. Create
211 the symlink so that pip3 can be used as described in the book.
212 </para>
[d10196e0]213 -->
[355495ce]214 <para>
[0d7900a]215 <command>chmod ...</command>: Fix permissions for shared libraries to be
[355495ce]216 consistent with other libraries.
217 </para>
[7224506]218
[879d269]219 </sect2>
220
221 <sect2 role="configuration">
[03d30cf]222 <title>Configuring Python 3</title>
[879d269]223
[355495ce]224 <para>
[03d30cf]225 In order for <command>python3</command> to find the installed
[d7015e7]226 documentation, create the following version independent symlink:
[355495ce]227 </para>
[1970f00]228
[d7015e7]229<screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
230
231 <para>
232 and add the following environment variable to the individual user's or
233 system's profile:
234 </para>
235
236<screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
[83f69e5d]237
238 </sect2>
239
240 <sect2 role="content">
241 <title>Contents</title>
242
243 <segmentedlist>
244 <segtitle>Installed Programs</segtitle>
245 <segtitle>Installed Libraries</segtitle>
246 <segtitle>Installed Directories</segtitle>
247
248 <seglistitem>
[355495ce]249 <seg>
[f2ff0e4]250 2to3 (symlink) and
[355495ce]251 2to3-&python3-majorver;,
252
[f2ff0e4]253 easy_install (symlink) and
254 easy_install-&python3-majorver;,
255
256 idle3 (symlink) and
257 idle&python3-majorver;,
[f5c5306]258
[f2ff0e4]259 pip3 (symlink) and
260 pip&python3-majorver;,
261
262 pydoc3 (symlink) and
[355495ce]263 pydoc&python3-majorver;,
264
[7fe0ce3b]265 python3 (symlink);
[f2ff0e4]266 python&python3-majorver;, and
[355495ce]267
[f2ff0e4]268 python3-config (symlink) and
269 python&python3-majorver;-config
270 <!--
[7fe0ce3b]271 pyvenv (symlink),
[f2ff0e4]272 pyvenv-&python3-majorver;
273 -->
[355495ce]274 </seg>
275 <seg>
[9e91b25]276 libpython&python3-majorver;.so and libpython3.so
[355495ce]277 </seg>
278 <seg>
[9e91b25]279 /usr/include/python&python3-majorver;,
[355495ce]280 /usr/lib/python&python3-majorver;, and
281 /usr/share/doc/python-&python3-version;
282 </seg>
[83f69e5d]283 </seglistitem>
284 </segmentedlist>
285
286 <variablelist>
287 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
288 <?dbfo list-presentation="list"?>
289 <?dbhtml list-presentation="table"?>
[f2ff0e4]290 <!--
291 <varlistentry id="2to3">
292 <term><command>2to3</command></term>
293 <listitem>
294 <para>
295 is designed to assist in the transition between python2 and python3
296 by automatically converting code to be Python3 compatible.
297 </para>
298 <indexterm zone="python3 2to3">
299 <primary sortas="b-2to3">2to3</primary>
300 </indexterm>
301 </listitem>
302 </varlistentry>
303 Put here for easy use when removing Python2 -->
304 <varlistentry id="easy_install">
305 <term><command>easy_install</command></term>
306 <listitem>
307 <para>
308 is a frontend to pip3 to make it easier to configure python modules
309 through the PIP package manager.
310 </para>
311 <indexterm zone="python3 easy_install">
312 <primary sortas="python3 easy_install">easy_install</primary>
313 </indexterm>
314 </listitem>
315 </varlistentry>
[83f69e5d]316
[355495ce]317 <varlistentry id="idle3">
318 <term><command>idle3</command></term>
[83f69e5d]319 <listitem>
[355495ce]320 <para>
[d0aecd33]321 is a wrapper script that opens a <application>Python</application>
322 aware GUI editor. For this script to run, you must have installed
323 <application>Tk</application> before Python so that the Tkinter
324 Python module is built.
[355495ce]325 </para>
326 <indexterm zone="python3 idle3">
327 <primary sortas="b-idle3">idle3</primary>
[83f69e5d]328 </indexterm>
329 </listitem>
330 </varlistentry>
331
[355495ce]332 <varlistentry id="pydoc3">
333 <term><command>pydoc3</command></term>
[83f69e5d]334 <listitem>
[355495ce]335 <para>
336 is the <application>Python</application> documentation
337 tool.
338 </para>
339 <indexterm zone="python3 pydoc3">
340 <primary sortas="b-pydoc3">pydo3c</primary>
[83f69e5d]341 </indexterm>
342 </listitem>
343 </varlistentry>
344
[b88be39]345 <varlistentry id="python3-prog">
[2cee003]346 <term><command>python3</command></term>
[83f69e5d]347 <listitem>
[355495ce]348 <para>
349 is an interpreted, interactive, object-oriented programming
350 language.
351 </para>
[b88be39]352 <indexterm zone="python3 python3-prog">
353 <primary sortas="b-python3">python3</primary>
[83f69e5d]354 </indexterm>
355 </listitem>
356 </varlistentry>
357
[f67f5387]358 <varlistentry id="python-ver">
[b88be39]359 <term><command>python&python3-majorver;</command></term>
[83f69e5d]360 <listitem>
[355495ce]361 <para>
362 is a version-specific name for the <command>python</command>
363 program.
364 </para>
[b88be39]365 <indexterm zone="python3 python-ver">
[2cee003]366 <primary
367 sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
[83f69e5d]368 </indexterm>
369 </listitem>
370 </varlistentry>
[f2ff0e4]371 <!--
[21e8edc]372 <varlistentry id="pyvenv">
373 <term><command>pyvenv</command></term>
374 <listitem>
375 <para>
376 creates virtual <application>Python</application> environments in
377 one or more target directories.
378 </para>
379 <indexterm zone="python3 pyvenv">
380 <primary
381 sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
382 </indexterm>
383 </listitem>
384 </varlistentry>
[f2ff0e4]385 -->
[83f69e5d]386 </variablelist>
387
388 </sect2>
[f45b1953]389
390</sect1>
Note: See TracBrowser for help on using the repository browser.