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