[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 " ">
|
---|
[4873baa] | 10 | <!ENTITY python3-md5sum "6ebfe157f6e88d9eabfbaf3fa92129f6">
|
---|
| 11 | <!ENTITY python3-size "18 MB">
|
---|
| 12 | <!ENTITY python3-buildsize "397 MB (add 30 MB for tests)">
|
---|
| 13 | <!ENTITY python3-time "0.4 SBU (using parallelism=4; add 2.2 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">
|
---|
[a82b5f44] | 94 | <xref linkend="sqlite"/> (required if building firefox or thunderbird)
|
---|
[693f28e1] | 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 |
|
---|
[4873baa] | 140 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
[1970f00] | 141 |
|
---|
[7fe0ce3b] | 142 | <para>
|
---|
| 143 | The test suite must be run separately from the build, either before or
|
---|
[7745345d] | 144 | after the package is built and installed. Do not run
|
---|
[af8a78d] | 145 | <command>make install</command> after running the test suite. To build
|
---|
[7745345d] | 146 | and install the package, you need to start with a fresh or clean source
|
---|
[e882fc37] | 147 | tree. For the tests, you also need a clean source code, so either start by
|
---|
[7745345d] | 148 | removing the source code directory and starting over, by uncompressing
|
---|
| 149 | the source tarball or by running <command>make clean</command>. Then
|
---|
| 150 | configure again, adding <quote>--with-pydebug</quote> to the
|
---|
| 151 | <command>configure</command> switches above, run <command>make</command>,
|
---|
[d7d743f0] | 152 | then <command>make test</command>. Remember that tests must be executed
|
---|
[73353e7f] | 153 | using an X terminal.
|
---|
| 154 | The test SBU highly depends on the speed of the internet connection.
|
---|
[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
|
---|
[229041f] | 202 | class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-<arch>-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 | -->
|
---|
[7224506] | 214 |
|
---|
[879d269] | 215 | </sect2>
|
---|
| 216 |
|
---|
| 217 | <sect2 role="configuration">
|
---|
[03d30cf] | 218 | <title>Configuring Python 3</title>
|
---|
[879d269] | 219 |
|
---|
[355495ce] | 220 | <para>
|
---|
[03d30cf] | 221 | In order for <command>python3</command> to find the installed
|
---|
[d7015e7] | 222 | documentation, create the following version independent symlink:
|
---|
[355495ce] | 223 | </para>
|
---|
[1970f00] | 224 |
|
---|
[d7015e7] | 225 | <screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
|
---|
| 226 |
|
---|
| 227 | <para>
|
---|
| 228 | and add the following environment variable to the individual user's or
|
---|
| 229 | system's profile:
|
---|
| 230 | </para>
|
---|
| 231 |
|
---|
| 232 | <screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
|
---|
[83f69e5d] | 233 |
|
---|
| 234 | </sect2>
|
---|
| 235 |
|
---|
| 236 | <sect2 role="content">
|
---|
| 237 | <title>Contents</title>
|
---|
| 238 |
|
---|
| 239 | <segmentedlist>
|
---|
| 240 | <segtitle>Installed Programs</segtitle>
|
---|
| 241 | <segtitle>Installed Libraries</segtitle>
|
---|
| 242 | <segtitle>Installed Directories</segtitle>
|
---|
| 243 |
|
---|
| 244 | <seglistitem>
|
---|
[355495ce] | 245 | <seg>
|
---|
[f2ff0e4] | 246 | 2to3 (symlink) and
|
---|
[355495ce] | 247 | 2to3-&python3-majorver;,
|
---|
| 248 |
|
---|
[f2ff0e4] | 249 | easy_install-&python3-majorver;,
|
---|
| 250 |
|
---|
| 251 | idle3 (symlink) and
|
---|
| 252 | idle&python3-majorver;,
|
---|
[f5c5306] | 253 |
|
---|
[f2ff0e4] | 254 | pip3 (symlink) and
|
---|
| 255 | pip&python3-majorver;,
|
---|
| 256 |
|
---|
[4873baa] | 257 | pydoc3 and
|
---|
[355495ce] | 258 | pydoc&python3-majorver;,
|
---|
| 259 |
|
---|
[7fe0ce3b] | 260 | python3 (symlink);
|
---|
[f2ff0e4] | 261 | python&python3-majorver;, and
|
---|
[355495ce] | 262 |
|
---|
[4873baa] | 263 | python3 (symlink), and
|
---|
| 264 | python&python3-majorver;
|
---|
| 265 |
|
---|
[f2ff0e4] | 266 | python3-config (symlink) and
|
---|
| 267 | python&python3-majorver;-config
|
---|
[355495ce] | 268 | </seg>
|
---|
| 269 | <seg>
|
---|
[9e91b25] | 270 | libpython&python3-majorver;.so and libpython3.so
|
---|
[355495ce] | 271 | </seg>
|
---|
| 272 | <seg>
|
---|
[9e91b25] | 273 | /usr/include/python&python3-majorver;,
|
---|
[355495ce] | 274 | /usr/lib/python&python3-majorver;, and
|
---|
| 275 | /usr/share/doc/python-&python3-version;
|
---|
| 276 | </seg>
|
---|
[83f69e5d] | 277 | </seglistitem>
|
---|
| 278 | </segmentedlist>
|
---|
| 279 |
|
---|
| 280 | <variablelist>
|
---|
| 281 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 282 | <?dbfo list-presentation="list"?>
|
---|
| 283 | <?dbhtml list-presentation="table"?>
|
---|
[f2ff0e4] | 284 | <!--
|
---|
| 285 | <varlistentry id="2to3">
|
---|
| 286 | <term><command>2to3</command></term>
|
---|
| 287 | <listitem>
|
---|
| 288 | <para>
|
---|
| 289 | is designed to assist in the transition between python2 and python3
|
---|
| 290 | by automatically converting code to be Python3 compatible.
|
---|
| 291 | </para>
|
---|
| 292 | <indexterm zone="python3 2to3">
|
---|
| 293 | <primary sortas="b-2to3">2to3</primary>
|
---|
| 294 | </indexterm>
|
---|
| 295 | </listitem>
|
---|
| 296 | </varlistentry>
|
---|
| 297 | Put here for easy use when removing Python2 -->
|
---|
| 298 | <varlistentry id="easy_install">
|
---|
| 299 | <term><command>easy_install</command></term>
|
---|
| 300 | <listitem>
|
---|
| 301 | <para>
|
---|
| 302 | is a frontend to pip3 to make it easier to configure python modules
|
---|
| 303 | through the PIP package manager.
|
---|
| 304 | </para>
|
---|
| 305 | <indexterm zone="python3 easy_install">
|
---|
| 306 | <primary sortas="python3 easy_install">easy_install</primary>
|
---|
| 307 | </indexterm>
|
---|
| 308 | </listitem>
|
---|
| 309 | </varlistentry>
|
---|
[83f69e5d] | 310 |
|
---|
[355495ce] | 311 | <varlistentry id="idle3">
|
---|
| 312 | <term><command>idle3</command></term>
|
---|
[83f69e5d] | 313 | <listitem>
|
---|
[355495ce] | 314 | <para>
|
---|
[d0aecd33] | 315 | is a wrapper script that opens a <application>Python</application>
|
---|
| 316 | aware GUI editor. For this script to run, you must have installed
|
---|
| 317 | <application>Tk</application> before Python so that the Tkinter
|
---|
| 318 | Python module is built.
|
---|
[355495ce] | 319 | </para>
|
---|
| 320 | <indexterm zone="python3 idle3">
|
---|
| 321 | <primary sortas="b-idle3">idle3</primary>
|
---|
[83f69e5d] | 322 | </indexterm>
|
---|
| 323 | </listitem>
|
---|
| 324 | </varlistentry>
|
---|
| 325 |
|
---|
[355495ce] | 326 | <varlistentry id="pydoc3">
|
---|
| 327 | <term><command>pydoc3</command></term>
|
---|
[83f69e5d] | 328 | <listitem>
|
---|
[355495ce] | 329 | <para>
|
---|
| 330 | is the <application>Python</application> documentation
|
---|
| 331 | tool.
|
---|
| 332 | </para>
|
---|
| 333 | <indexterm zone="python3 pydoc3">
|
---|
| 334 | <primary sortas="b-pydoc3">pydo3c</primary>
|
---|
[83f69e5d] | 335 | </indexterm>
|
---|
| 336 | </listitem>
|
---|
| 337 | </varlistentry>
|
---|
| 338 |
|
---|
[b88be39] | 339 | <varlistentry id="python3-prog">
|
---|
[2cee003] | 340 | <term><command>python3</command></term>
|
---|
[83f69e5d] | 341 | <listitem>
|
---|
[355495ce] | 342 | <para>
|
---|
| 343 | is an interpreted, interactive, object-oriented programming
|
---|
| 344 | language.
|
---|
| 345 | </para>
|
---|
[b88be39] | 346 | <indexterm zone="python3 python3-prog">
|
---|
| 347 | <primary sortas="b-python3">python3</primary>
|
---|
[83f69e5d] | 348 | </indexterm>
|
---|
| 349 | </listitem>
|
---|
| 350 | </varlistentry>
|
---|
| 351 |
|
---|
[f67f5387] | 352 | <varlistentry id="python-ver">
|
---|
[b88be39] | 353 | <term><command>python&python3-majorver;</command></term>
|
---|
[83f69e5d] | 354 | <listitem>
|
---|
[355495ce] | 355 | <para>
|
---|
| 356 | is a version-specific name for the <command>python</command>
|
---|
| 357 | program.
|
---|
| 358 | </para>
|
---|
[b88be39] | 359 | <indexterm zone="python3 python-ver">
|
---|
[2cee003] | 360 | <primary
|
---|
| 361 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
[83f69e5d] | 362 | </indexterm>
|
---|
| 363 | </listitem>
|
---|
| 364 | </varlistentry>
|
---|
[f2ff0e4] | 365 | <!--
|
---|
[21e8edc] | 366 | <varlistentry id="pyvenv">
|
---|
| 367 | <term><command>pyvenv</command></term>
|
---|
| 368 | <listitem>
|
---|
| 369 | <para>
|
---|
| 370 | creates virtual <application>Python</application> environments in
|
---|
| 371 | one or more target directories.
|
---|
| 372 | </para>
|
---|
| 373 | <indexterm zone="python3 pyvenv">
|
---|
| 374 | <primary
|
---|
| 375 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
| 376 | </indexterm>
|
---|
| 377 | </listitem>
|
---|
| 378 | </varlistentry>
|
---|
[f2ff0e4] | 379 | -->
|
---|
[83f69e5d] | 380 | </variablelist>
|
---|
| 381 |
|
---|
| 382 | </sect2>
|
---|
[f45b1953] | 383 |
|
---|
| 384 | </sect1>
|
---|