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