[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 " ">
|
---|
[ff23ffd] | 10 | <!ENTITY python3-md5sum "35b5a3d0254c1c59be9736373d429db7">
|
---|
[9e91b25] | 11 | <!ENTITY python3-size "17 MB">
|
---|
[8f3e8197] | 12 | <!ENTITY python3-buildsize "187 MB (add 27 MB for tests)">
|
---|
[434b1d9] | 13 | <!ENTITY python3-time "0.5 SBU (using parallelism=4; add 2.1 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 |
|
---|
[78af2ee] | 54 | &lfs10_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 |
|
---|
[693f28e1] | 92 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
| 93 | <para role="recommended">
|
---|
| 94 | <xref linkend="sqlite"/> (required if building firefox)
|
---|
| 95 | </para>
|
---|
| 96 |
|
---|
[83f69e5d] | 97 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
[355495ce] | 98 | <para role="optional">
|
---|
[7fe0ce3b] | 99 | <xref linkend="bluez"/>,
|
---|
[e882fc37] | 100 | <xref linkend="gdb"/> (required for some tests),
|
---|
| 101 | <xref linkend="valgrind"/>, and
|
---|
[7ffeb4bd] | 102 | <ulink url="http://www.bytereef.org/mpdecimal">libmpdec</ulink>
|
---|
[355495ce] | 103 | </para>
|
---|
| 104 |
|
---|
| 105 | <bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
|
---|
| 106 | <para role="optional">
|
---|
[3979b674] | 107 | <xref linkend="db"/> and
|
---|
[6030130] | 108 | <xref linkend="tk"/>
|
---|
[355495ce] | 109 | </para>
|
---|
[ce33273] | 110 |
|
---|
[1039de3] | 111 | <para condition="html" role="usernotes">User Notes:
|
---|
[355495ce] | 112 | <ulink url="&blfs-wiki;/Python3"/>
|
---|
| 113 | </para>
|
---|
[83f69e5d] | 114 | </sect2>
|
---|
| 115 |
|
---|
| 116 | <sect2 role="installation">
|
---|
[03d30cf] | 117 | <title>Installation of Python 3</title>
|
---|
[83f69e5d] | 118 |
|
---|
[355495ce] | 119 | <para>
|
---|
[03d30cf] | 120 | Install <application>Python 3</application> by running the following
|
---|
[355495ce] | 121 | commands:
|
---|
| 122 | </para>
|
---|
[83f69e5d] | 123 |
|
---|
[fd69a62] | 124 | <screen><userinput>CXX="/usr/bin/g++" \
|
---|
| 125 | ./configure --prefix=/usr \
|
---|
[c525bd1] | 126 | --enable-shared \
|
---|
[355495ce] | 127 | --with-system-expat \
|
---|
[fd69a62] | 128 | --with-system-ffi \
|
---|
[879932f] | 129 | --with-ensurepip=yes &&
|
---|
[83f69e5d] | 130 | make</userinput></screen>
|
---|
| 131 |
|
---|
[355495ce] | 132 | <para>
|
---|
[7fe0ce3b] | 133 | The test suite must be run separately, using an X terminal (see below).
|
---|
[355495ce] | 134 | </para>
|
---|
| 135 |
|
---|
| 136 | <para>
|
---|
| 137 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 138 | </para>
|
---|
| 139 |
|
---|
[82fac2c] | 140 | <screen role="root"><userinput>make install &&
|
---|
[d10196e0] | 141 | <!--ln -sfv pip&python3-majorver; /usr/bin/pip3 &&-->
|
---|
[9e91b25] | 142 | chmod -v 755 /usr/lib/libpython&python3-majorver;.so &&
|
---|
[355495ce] | 143 | chmod -v 755 /usr/lib/libpython3.so</userinput></screen>
|
---|
[1970f00] | 144 |
|
---|
[7fe0ce3b] | 145 | <para>
|
---|
| 146 | The test suite must be run separately from the build, either before or
|
---|
[7745345d] | 147 | after the package is built and installed. Do not run
|
---|
[af8a78d] | 148 | <command>make install</command> after running the test suite. To build
|
---|
[7745345d] | 149 | and install the package, you need to start with a fresh or clean source
|
---|
[e882fc37] | 150 | tree. For the tests, you also need a clean source code, so either start by
|
---|
[7745345d] | 151 | removing the source code directory and starting over, by uncompressing
|
---|
| 152 | the source tarball or by running <command>make clean</command>. Then
|
---|
| 153 | configure again, adding <quote>--with-pydebug</quote> to the
|
---|
| 154 | <command>configure</command> switches above, run <command>make</command>,
|
---|
[d7d743f0] | 155 | then <command>make test</command>. Remember that tests must be executed
|
---|
[73353e7f] | 156 | using an X terminal.
|
---|
| 157 | The test SBU highly depends on the speed of the internet connection.
|
---|
[9e91b25] | 158 | The test_sqlite test is known to fail.
|
---|
[7fe0ce3b] | 159 | </para>
|
---|
| 160 |
|
---|
[879d269] | 161 | </sect2>
|
---|
| 162 |
|
---|
| 163 | <sect2 role="commands">
|
---|
| 164 | <title>Command Explanations</title>
|
---|
| 165 |
|
---|
[fd69a62] | 166 | <para>
|
---|
| 167 | <command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
|
---|
| 168 | message during configuration.
|
---|
| 169 | </para>
|
---|
| 170 |
|
---|
[355495ce] | 171 | <para>
|
---|
[f1d7196] | 172 | <parameter>--with-system-expat</parameter>: This switch enables linking
|
---|
| 173 | against the system version of <application>Expat</application>.
|
---|
[355495ce] | 174 | </para>
|
---|
| 175 |
|
---|
| 176 | <para>
|
---|
[f1d7196] | 177 | <parameter>--with-system-ffi</parameter>: This switch enables linking
|
---|
[60ddbaf] | 178 | against system version of <application>libffi</application>.
|
---|
[82fac2c] | 179 | </para>
|
---|
[fd69a62] | 180 |
|
---|
| 181 | <para>
|
---|
[23c5563] | 182 | <parameter>--with-ensurepip=yes</parameter> : This switch enables building
|
---|
| 183 | <command>pip</command> and <command>setuptools</command> packaging programs.
|
---|
| 184 | <command>setuptools</command> is needed for building some Python modules.
|
---|
[fd69a62] | 185 | </para>
|
---|
[82fac2c] | 186 |
|
---|
[f1d7196] | 187 | <para>
|
---|
| 188 | <option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
|
---|
| 189 | if you want to build <application>Python</application> DBM Module
|
---|
| 190 | against <application>Berkeley DB</application> instead of
|
---|
| 191 | <application>GDBM</application>.
|
---|
| 192 | </para>
|
---|
| 193 |
|
---|
[7c57f82] | 194 | <para>
|
---|
| 195 | <option>--enable-optimization</option>: Use this switch
|
---|
| 196 | if you want to enable <emphasis>expensive</emphasis> optimizations (i.e.
|
---|
| 197 | Profile Guided Optimizations). This adds around 20 SBU, but can
|
---|
| 198 | <emphasis>slightly</emphasis> speed up some uses, such as using
|
---|
| 199 | <application>Sphinx</application> for creating documentation, or use of
|
---|
| 200 | <application>Python3</application> scripts.
|
---|
| 201 | </para>
|
---|
| 202 |
|
---|
| 203 | <para>
|
---|
| 204 | <option>--with-lto</option>: This optional switch enables thick Link
|
---|
| 205 | Time Optimization. Unusually, it creates a much larger <filename
|
---|
[229041f] | 206 | class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-<arch>-linux-gnu/libpython&python3-majorver;.a</filename>
|
---|
[7c57f82] | 207 | with a small increase in the time to compile
|
---|
| 208 | <application>Python</application>. Run-time results do not appear to show
|
---|
| 209 | any benefit from doing this.
|
---|
| 210 | </para>
|
---|
[d10196e0] | 211 | <!--
|
---|
[56da2817] | 212 | <para>
|
---|
| 213 | <command>ln -sfv ...</command>: When upgrading to Python-3.8, it was
|
---|
| 214 | discovered that the symlink to pip3 is sometimes not created. Create
|
---|
| 215 | the symlink so that pip3 can be used as described in the book.
|
---|
| 216 | </para>
|
---|
[d10196e0] | 217 | -->
|
---|
[355495ce] | 218 | <para>
|
---|
[0d7900a] | 219 | <command>chmod ...</command>: Fix permissions for shared libraries to be
|
---|
[355495ce] | 220 | consistent with other libraries.
|
---|
| 221 | </para>
|
---|
[7224506] | 222 |
|
---|
[879d269] | 223 | </sect2>
|
---|
| 224 |
|
---|
| 225 | <sect2 role="configuration">
|
---|
[03d30cf] | 226 | <title>Configuring Python 3</title>
|
---|
[879d269] | 227 |
|
---|
[355495ce] | 228 | <para>
|
---|
[03d30cf] | 229 | In order for <command>python3</command> to find the installed
|
---|
[d7015e7] | 230 | documentation, create the following version independent symlink:
|
---|
[355495ce] | 231 | </para>
|
---|
[1970f00] | 232 |
|
---|
[d7015e7] | 233 | <screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
|
---|
| 234 |
|
---|
| 235 | <para>
|
---|
| 236 | and add the following environment variable to the individual user's or
|
---|
| 237 | system's profile:
|
---|
| 238 | </para>
|
---|
| 239 |
|
---|
| 240 | <screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
|
---|
[83f69e5d] | 241 |
|
---|
| 242 | </sect2>
|
---|
| 243 |
|
---|
| 244 | <sect2 role="content">
|
---|
| 245 | <title>Contents</title>
|
---|
| 246 |
|
---|
| 247 | <segmentedlist>
|
---|
| 248 | <segtitle>Installed Programs</segtitle>
|
---|
| 249 | <segtitle>Installed Libraries</segtitle>
|
---|
| 250 | <segtitle>Installed Directories</segtitle>
|
---|
| 251 |
|
---|
| 252 | <seglistitem>
|
---|
[355495ce] | 253 | <seg>
|
---|
[f2ff0e4] | 254 | 2to3 (symlink) and
|
---|
[355495ce] | 255 | 2to3-&python3-majorver;,
|
---|
| 256 |
|
---|
[f2ff0e4] | 257 | easy_install (symlink) and
|
---|
| 258 | easy_install-&python3-majorver;,
|
---|
| 259 |
|
---|
| 260 | idle3 (symlink) and
|
---|
| 261 | idle&python3-majorver;,
|
---|
[f5c5306] | 262 |
|
---|
[f2ff0e4] | 263 | pip3 (symlink) and
|
---|
| 264 | pip&python3-majorver;,
|
---|
| 265 |
|
---|
| 266 | pydoc3 (symlink) and
|
---|
[355495ce] | 267 | pydoc&python3-majorver;,
|
---|
| 268 |
|
---|
[7fe0ce3b] | 269 | python3 (symlink);
|
---|
[f2ff0e4] | 270 | python&python3-majorver;, and
|
---|
[355495ce] | 271 |
|
---|
[f2ff0e4] | 272 | python3-config (symlink) and
|
---|
| 273 | python&python3-majorver;-config
|
---|
| 274 | <!--
|
---|
[7fe0ce3b] | 275 | pyvenv (symlink),
|
---|
[f2ff0e4] | 276 | pyvenv-&python3-majorver;
|
---|
| 277 | -->
|
---|
[355495ce] | 278 | </seg>
|
---|
| 279 | <seg>
|
---|
[9e91b25] | 280 | libpython&python3-majorver;.so and libpython3.so
|
---|
[355495ce] | 281 | </seg>
|
---|
| 282 | <seg>
|
---|
[9e91b25] | 283 | /usr/include/python&python3-majorver;,
|
---|
[355495ce] | 284 | /usr/lib/python&python3-majorver;, and
|
---|
| 285 | /usr/share/doc/python-&python3-version;
|
---|
| 286 | </seg>
|
---|
[83f69e5d] | 287 | </seglistitem>
|
---|
| 288 | </segmentedlist>
|
---|
| 289 |
|
---|
| 290 | <variablelist>
|
---|
| 291 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 292 | <?dbfo list-presentation="list"?>
|
---|
| 293 | <?dbhtml list-presentation="table"?>
|
---|
[f2ff0e4] | 294 | <!--
|
---|
| 295 | <varlistentry id="2to3">
|
---|
| 296 | <term><command>2to3</command></term>
|
---|
| 297 | <listitem>
|
---|
| 298 | <para>
|
---|
| 299 | is designed to assist in the transition between python2 and python3
|
---|
| 300 | by automatically converting code to be Python3 compatible.
|
---|
| 301 | </para>
|
---|
| 302 | <indexterm zone="python3 2to3">
|
---|
| 303 | <primary sortas="b-2to3">2to3</primary>
|
---|
| 304 | </indexterm>
|
---|
| 305 | </listitem>
|
---|
| 306 | </varlistentry>
|
---|
| 307 | Put here for easy use when removing Python2 -->
|
---|
| 308 | <varlistentry id="easy_install">
|
---|
| 309 | <term><command>easy_install</command></term>
|
---|
| 310 | <listitem>
|
---|
| 311 | <para>
|
---|
| 312 | is a frontend to pip3 to make it easier to configure python modules
|
---|
| 313 | through the PIP package manager.
|
---|
| 314 | </para>
|
---|
| 315 | <indexterm zone="python3 easy_install">
|
---|
| 316 | <primary sortas="python3 easy_install">easy_install</primary>
|
---|
| 317 | </indexterm>
|
---|
| 318 | </listitem>
|
---|
| 319 | </varlistentry>
|
---|
[83f69e5d] | 320 |
|
---|
[355495ce] | 321 | <varlistentry id="idle3">
|
---|
| 322 | <term><command>idle3</command></term>
|
---|
[83f69e5d] | 323 | <listitem>
|
---|
[355495ce] | 324 | <para>
|
---|
[d0aecd33] | 325 | is a wrapper script that opens a <application>Python</application>
|
---|
| 326 | aware GUI editor. For this script to run, you must have installed
|
---|
| 327 | <application>Tk</application> before Python so that the Tkinter
|
---|
| 328 | Python module is built.
|
---|
[355495ce] | 329 | </para>
|
---|
| 330 | <indexterm zone="python3 idle3">
|
---|
| 331 | <primary sortas="b-idle3">idle3</primary>
|
---|
[83f69e5d] | 332 | </indexterm>
|
---|
| 333 | </listitem>
|
---|
| 334 | </varlistentry>
|
---|
| 335 |
|
---|
[355495ce] | 336 | <varlistentry id="pydoc3">
|
---|
| 337 | <term><command>pydoc3</command></term>
|
---|
[83f69e5d] | 338 | <listitem>
|
---|
[355495ce] | 339 | <para>
|
---|
| 340 | is the <application>Python</application> documentation
|
---|
| 341 | tool.
|
---|
| 342 | </para>
|
---|
| 343 | <indexterm zone="python3 pydoc3">
|
---|
| 344 | <primary sortas="b-pydoc3">pydo3c</primary>
|
---|
[83f69e5d] | 345 | </indexterm>
|
---|
| 346 | </listitem>
|
---|
| 347 | </varlistentry>
|
---|
| 348 |
|
---|
[b88be39] | 349 | <varlistentry id="python3-prog">
|
---|
[2cee003] | 350 | <term><command>python3</command></term>
|
---|
[83f69e5d] | 351 | <listitem>
|
---|
[355495ce] | 352 | <para>
|
---|
| 353 | is an interpreted, interactive, object-oriented programming
|
---|
| 354 | language.
|
---|
| 355 | </para>
|
---|
[b88be39] | 356 | <indexterm zone="python3 python3-prog">
|
---|
| 357 | <primary sortas="b-python3">python3</primary>
|
---|
[83f69e5d] | 358 | </indexterm>
|
---|
| 359 | </listitem>
|
---|
| 360 | </varlistentry>
|
---|
| 361 |
|
---|
[f67f5387] | 362 | <varlistentry id="python-ver">
|
---|
[b88be39] | 363 | <term><command>python&python3-majorver;</command></term>
|
---|
[83f69e5d] | 364 | <listitem>
|
---|
[355495ce] | 365 | <para>
|
---|
| 366 | is a version-specific name for the <command>python</command>
|
---|
| 367 | program.
|
---|
| 368 | </para>
|
---|
[b88be39] | 369 | <indexterm zone="python3 python-ver">
|
---|
[2cee003] | 370 | <primary
|
---|
| 371 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
[83f69e5d] | 372 | </indexterm>
|
---|
| 373 | </listitem>
|
---|
| 374 | </varlistentry>
|
---|
[f2ff0e4] | 375 | <!--
|
---|
[21e8edc] | 376 | <varlistentry id="pyvenv">
|
---|
| 377 | <term><command>pyvenv</command></term>
|
---|
| 378 | <listitem>
|
---|
| 379 | <para>
|
---|
| 380 | creates virtual <application>Python</application> environments in
|
---|
| 381 | one or more target directories.
|
---|
| 382 | </para>
|
---|
| 383 | <indexterm zone="python3 pyvenv">
|
---|
| 384 | <primary
|
---|
| 385 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
| 386 | </indexterm>
|
---|
| 387 | </listitem>
|
---|
| 388 | </varlistentry>
|
---|
[f2ff0e4] | 389 | -->
|
---|
[83f69e5d] | 390 | </variablelist>
|
---|
| 391 |
|
---|
| 392 | </sect2>
|
---|
[f45b1953] | 393 |
|
---|
| 394 | </sect1>
|
---|