[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 " ">
|
---|
[4be7bcd] | 10 | <!ENTITY python3-md5sum "fe92acfa0db9b9f5044958edb451d463">
|
---|
[3df4c93] | 11 | <!ENTITY python3-size "19 MB">
|
---|
[4be7bcd] | 12 | <!ENTITY python3-buildsize "282 MB (add 63 MB for tests)">
|
---|
| 13 | <!ENTITY python3-time "2.1 SBU (add 1.2 SBU for tests; both using parallelism=4)">
|
---|
[e882fc37] | 14 | <!--
|
---|
[73353e7f] | 15 | Note: Size does not reflect docs that were install in LFS.
|
---|
[3df4c93] | 16 | -->
|
---|
[2cee003] | 17 | <!ENTITY python3htmldoc-download-http
|
---|
[1fe05eb] | 18 | "https://www.python.org/ftp/python/doc/&python3-version;/python-&python3-version;-docs-html.tar.bz2">
|
---|
[877b80ac] | 19 | <!ENTITY python3-docs-md5sum "b740495c9f6714e0998894ed8d1cb379" >
|
---|
[52d29f7] | 20 | ]>
|
---|
| 21 |
|
---|
[b88be39] | 22 | <sect1 id="python3" xreflabel="Python-&python3-version;">
|
---|
| 23 | <?dbhtml filename="python3.html" ?>
|
---|
[83f69e5d] | 24 |
|
---|
| 25 | <sect1info>
|
---|
| 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
|
---|
[b9a6bcc0] | 49 | are needed, or to upgrade this package.
|
---|
[de33b2a] | 50 | </para>
|
---|
| 51 | </note>
|
---|
[60ddbaf] | 52 |
|
---|
[ce1dd9df] | 53 | &lfs112_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 |
|
---|
[3df4c93] | 89 | <bridgehead renderas="sect3">Additional Optional Download</bridgehead>
|
---|
| 90 | <itemizedlist spacing="compact">
|
---|
| 91 | <listitem>
|
---|
| 92 | <para>
|
---|
| 93 | Download (HTTP): <ulink url="&python3htmldoc-download-http;"/>
|
---|
| 94 | </para>
|
---|
| 95 | </listitem>
|
---|
| 96 | <listitem>
|
---|
| 97 | <para>
|
---|
| 98 | Download MD5 sum: &python3-docs-md5sum;
|
---|
| 99 | </para>
|
---|
| 100 | </listitem>
|
---|
| 101 | </itemizedlist>
|
---|
| 102 |
|
---|
[03d30cf] | 103 | <bridgehead renderas="sect3">Python 3 Dependencies</bridgehead>
|
---|
[e882fc37] | 104 |
|
---|
[693f28e1] | 105 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
| 106 | <para role="recommended">
|
---|
[a82b5f44] | 107 | <xref linkend="sqlite"/> (required if building firefox or thunderbird)
|
---|
[693f28e1] | 108 | </para>
|
---|
| 109 |
|
---|
[83f69e5d] | 110 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
[355495ce] | 111 | <para role="optional">
|
---|
[7fe0ce3b] | 112 | <xref linkend="bluez"/>,
|
---|
[e882fc37] | 113 | <xref linkend="gdb"/> (required for some tests),
|
---|
| 114 | <xref linkend="valgrind"/>, and
|
---|
[4e207bb] | 115 | <ulink url="https://www.bytereef.org/mpdecimal/">libmpdec</ulink>
|
---|
[355495ce] | 116 | </para>
|
---|
| 117 |
|
---|
| 118 | <bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
|
---|
| 119 | <para role="optional">
|
---|
[9464475] | 120 | <xref linkend="db"/>,
|
---|
| 121 | <xref linkend="libnsl"/>, and
|
---|
[6030130] | 122 | <xref linkend="tk"/>
|
---|
[355495ce] | 123 | </para>
|
---|
[ce33273] | 124 |
|
---|
[1039de3] | 125 | <para condition="html" role="usernotes">User Notes:
|
---|
[355495ce] | 126 | <ulink url="&blfs-wiki;/Python3"/>
|
---|
| 127 | </para>
|
---|
[83f69e5d] | 128 | </sect2>
|
---|
| 129 |
|
---|
| 130 | <sect2 role="installation">
|
---|
[03d30cf] | 131 | <title>Installation of Python 3</title>
|
---|
[83f69e5d] | 132 |
|
---|
[355495ce] | 133 | <para>
|
---|
[03d30cf] | 134 | Install <application>Python 3</application> by running the following
|
---|
[355495ce] | 135 | commands:
|
---|
| 136 | </para>
|
---|
[83f69e5d] | 137 |
|
---|
[a87fb41] | 138 | <screen><userinput>CXX="/usr/bin/g++" \
|
---|
| 139 | ./configure --prefix=/usr \
|
---|
| 140 | --enable-shared \
|
---|
| 141 | --with-system-expat \
|
---|
| 142 | --with-system-ffi \
|
---|
| 143 | --enable-optimizations &&
|
---|
[83f69e5d] | 144 | make</userinput></screen>
|
---|
| 145 |
|
---|
[355495ce] | 146 | <para>
|
---|
[8bed3aa1] | 147 | To test the result, issue <command>make test</command>.
|
---|
[4be7bcd] | 148 | Some tests may need an Internet connection. <!--Two tests, test_distutils
|
---|
| 149 | and test_peg_generator are known to fail.-->
|
---|
[355495ce] | 150 | </para>
|
---|
| 151 |
|
---|
| 152 | <para>
|
---|
| 153 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 154 | </para>
|
---|
| 155 |
|
---|
[3df4c93] | 156 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
| 157 |
|
---|
| 158 | <para>
|
---|
[1fe05eb] | 159 | If upgrading and the documentation has been downloaded, optionally install
|
---|
[3df4c93] | 160 | it as the &root; user:
|
---|
| 161 | </para>
|
---|
| 162 |
|
---|
[4be7bcd] | 163 | <screen role="root"><userinput>install -v -dm755 /usr/share/doc/python-&python3-version;/html
|
---|
| 164 |
|
---|
| 165 | tar --strip-components=1 \
|
---|
[3df4c93] | 166 | --no-same-owner \
|
---|
| 167 | --no-same-permissions \
|
---|
| 168 | -C /usr/share/doc/python-&python3-version;/html \
|
---|
| 169 | -xvf ../python-&python3-version;-docs-html.tar.bz2</userinput></screen>
|
---|
[1970f00] | 170 |
|
---|
[879d269] | 171 | </sect2>
|
---|
| 172 |
|
---|
| 173 | <sect2 role="commands">
|
---|
| 174 | <title>Command Explanations</title>
|
---|
| 175 |
|
---|
[fd69a62] | 176 | <para>
|
---|
| 177 | <command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
|
---|
| 178 | message during configuration.
|
---|
| 179 | </para>
|
---|
| 180 |
|
---|
[355495ce] | 181 | <para>
|
---|
[f1d7196] | 182 | <parameter>--with-system-expat</parameter>: This switch enables linking
|
---|
| 183 | against the system version of <application>Expat</application>.
|
---|
[355495ce] | 184 | </para>
|
---|
| 185 |
|
---|
| 186 | <para>
|
---|
[f1d7196] | 187 | <parameter>--with-system-ffi</parameter>: This switch enables linking
|
---|
[8558044] | 188 | against the system version of <application>libffi</application>.
|
---|
[82fac2c] | 189 | </para>
|
---|
[988edbf5] | 190 | <!--
|
---|
[fd69a62] | 191 | <para>
|
---|
[6e94284] | 192 | <parameter>- -with-ensurepip=yes</parameter> : This switch enables building
|
---|
[8558044] | 193 | the <command>pip</command> and <command>setuptools</command> packaging
|
---|
[229d069] | 194 | programs. <command>setuptools</command> is needed for building some
|
---|
| 195 | Python modules.
|
---|
[fd69a62] | 196 | </para>
|
---|
[988edbf5] | 197 | -->
|
---|
[f1d7196] | 198 | <para>
|
---|
| 199 | <option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
|
---|
[229d069] | 200 | if you want to build the <application>Python</application> DBM Module
|
---|
[f1d7196] | 201 | against <application>Berkeley DB</application> instead of
|
---|
| 202 | <application>GDBM</application>.
|
---|
| 203 | </para>
|
---|
| 204 |
|
---|
[7c57f82] | 205 | <para>
|
---|
[a0bb9145] | 206 | <parameter>--enable-optimizations</parameter>: This switch enables
|
---|
[a87fb41] | 207 | stable, but expensive, optimizations.
|
---|
[7c57f82] | 208 | </para>
|
---|
| 209 |
|
---|
| 210 | <para>
|
---|
| 211 | <option>--with-lto</option>: This optional switch enables thick Link
|
---|
| 212 | Time Optimization. Unusually, it creates a much larger <filename
|
---|
[4e207bb] | 213 | class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-<arch>-linux-gnu/libpython&python3-majorver;.a</filename>
|
---|
[7c57f82] | 214 | with a small increase in the time to compile
|
---|
| 215 | <application>Python</application>. Run-time results do not appear to show
|
---|
| 216 | any benefit from doing this.
|
---|
| 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 |
|
---|
[229d069] | 253 | <!--
|
---|
[f2ff0e4] | 254 | easy_install-&python3-majorver;,
|
---|
[229d069] | 255 | -->
|
---|
[f2ff0e4] | 256 |
|
---|
| 257 | idle3 (symlink) and
|
---|
| 258 | idle&python3-majorver;,
|
---|
[f5c5306] | 259 |
|
---|
[f2ff0e4] | 260 | pip3 (symlink) and
|
---|
| 261 | pip&python3-majorver;,
|
---|
| 262 |
|
---|
[4873baa] | 263 | pydoc3 and
|
---|
[355495ce] | 264 | pydoc&python3-majorver;,
|
---|
| 265 |
|
---|
[7fe0ce3b] | 266 | python3 (symlink);
|
---|
[f2ff0e4] | 267 | python&python3-majorver;, and
|
---|
[355495ce] | 268 |
|
---|
[f2ff0e4] | 269 | python3-config (symlink) and
|
---|
| 270 | python&python3-majorver;-config
|
---|
[355495ce] | 271 | </seg>
|
---|
| 272 | <seg>
|
---|
[9e91b25] | 273 | libpython&python3-majorver;.so and libpython3.so
|
---|
[355495ce] | 274 | </seg>
|
---|
| 275 | <seg>
|
---|
[9e91b25] | 276 | /usr/include/python&python3-majorver;,
|
---|
[355495ce] | 277 | /usr/lib/python&python3-majorver;, and
|
---|
| 278 | /usr/share/doc/python-&python3-version;
|
---|
| 279 | </seg>
|
---|
[83f69e5d] | 280 | </seglistitem>
|
---|
| 281 | </segmentedlist>
|
---|
| 282 |
|
---|
| 283 | <variablelist>
|
---|
| 284 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 285 | <?dbfo list-presentation="list"?>
|
---|
| 286 | <?dbhtml list-presentation="table"?>
|
---|
[f2ff0e4] | 287 | <!--
|
---|
| 288 | <varlistentry id="2to3">
|
---|
| 289 | <term><command>2to3</command></term>
|
---|
| 290 | <listitem>
|
---|
| 291 | <para>
|
---|
| 292 | is designed to assist in the transition between python2 and python3
|
---|
| 293 | by automatically converting code to be Python3 compatible.
|
---|
| 294 | </para>
|
---|
| 295 | <indexterm zone="python3 2to3">
|
---|
| 296 | <primary sortas="b-2to3">2to3</primary>
|
---|
| 297 | </indexterm>
|
---|
| 298 | </listitem>
|
---|
| 299 | </varlistentry>
|
---|
| 300 | Put here for easy use when removing Python2 -->
|
---|
[229d069] | 301 | <!--
|
---|
[f2ff0e4] | 302 | <varlistentry id="easy_install">
|
---|
| 303 | <term><command>easy_install</command></term>
|
---|
| 304 | <listitem>
|
---|
| 305 | <para>
|
---|
| 306 | is a frontend to pip3 to make it easier to configure python modules
|
---|
[4c24eb0a] | 307 | through the PIP package manager
|
---|
[f2ff0e4] | 308 | </para>
|
---|
| 309 | <indexterm zone="python3 easy_install">
|
---|
| 310 | <primary sortas="python3 easy_install">easy_install</primary>
|
---|
| 311 | </indexterm>
|
---|
| 312 | </listitem>
|
---|
| 313 | </varlistentry>
|
---|
[229d069] | 314 | -->
|
---|
[355495ce] | 315 | <varlistentry id="idle3">
|
---|
| 316 | <term><command>idle3</command></term>
|
---|
[83f69e5d] | 317 | <listitem>
|
---|
[355495ce] | 318 | <para>
|
---|
[d0aecd33] | 319 | is a wrapper script that opens a <application>Python</application>
|
---|
| 320 | aware GUI editor. For this script to run, you must have installed
|
---|
| 321 | <application>Tk</application> before Python so that the Tkinter
|
---|
[4c24eb0a] | 322 | Python module is built
|
---|
[355495ce] | 323 | </para>
|
---|
| 324 | <indexterm zone="python3 idle3">
|
---|
| 325 | <primary sortas="b-idle3">idle3</primary>
|
---|
[83f69e5d] | 326 | </indexterm>
|
---|
| 327 | </listitem>
|
---|
| 328 | </varlistentry>
|
---|
| 329 |
|
---|
[355495ce] | 330 | <varlistentry id="pydoc3">
|
---|
| 331 | <term><command>pydoc3</command></term>
|
---|
[83f69e5d] | 332 | <listitem>
|
---|
[355495ce] | 333 | <para>
|
---|
| 334 | is the <application>Python</application> documentation
|
---|
[4c24eb0a] | 335 | tool
|
---|
[355495ce] | 336 | </para>
|
---|
| 337 | <indexterm zone="python3 pydoc3">
|
---|
| 338 | <primary sortas="b-pydoc3">pydo3c</primary>
|
---|
[83f69e5d] | 339 | </indexterm>
|
---|
| 340 | </listitem>
|
---|
| 341 | </varlistentry>
|
---|
| 342 |
|
---|
[b88be39] | 343 | <varlistentry id="python3-prog">
|
---|
[2cee003] | 344 | <term><command>python3</command></term>
|
---|
[83f69e5d] | 345 | <listitem>
|
---|
[355495ce] | 346 | <para>
|
---|
| 347 | is an interpreted, interactive, object-oriented programming
|
---|
[4c24eb0a] | 348 | language
|
---|
[355495ce] | 349 | </para>
|
---|
[b88be39] | 350 | <indexterm zone="python3 python3-prog">
|
---|
| 351 | <primary sortas="b-python3">python3</primary>
|
---|
[83f69e5d] | 352 | </indexterm>
|
---|
| 353 | </listitem>
|
---|
| 354 | </varlistentry>
|
---|
| 355 |
|
---|
[f67f5387] | 356 | <varlistentry id="python-ver">
|
---|
[b88be39] | 357 | <term><command>python&python3-majorver;</command></term>
|
---|
[83f69e5d] | 358 | <listitem>
|
---|
[355495ce] | 359 | <para>
|
---|
| 360 | is a version-specific name for the <command>python</command>
|
---|
[4c24eb0a] | 361 | program
|
---|
[355495ce] | 362 | </para>
|
---|
[b88be39] | 363 | <indexterm zone="python3 python-ver">
|
---|
[4c24eb0a] | 364 | <primary sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
[83f69e5d] | 365 | </indexterm>
|
---|
| 366 | </listitem>
|
---|
| 367 | </varlistentry>
|
---|
[f2ff0e4] | 368 | <!--
|
---|
[21e8edc] | 369 | <varlistentry id="pyvenv">
|
---|
| 370 | <term><command>pyvenv</command></term>
|
---|
| 371 | <listitem>
|
---|
| 372 | <para>
|
---|
| 373 | creates virtual <application>Python</application> environments in
|
---|
| 374 | one or more target directories.
|
---|
| 375 | </para>
|
---|
| 376 | <indexterm zone="python3 pyvenv">
|
---|
| 377 | <primary
|
---|
| 378 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
| 379 | </indexterm>
|
---|
| 380 | </listitem>
|
---|
| 381 | </varlistentry>
|
---|
[f2ff0e4] | 382 | -->
|
---|
[83f69e5d] | 383 | </variablelist>
|
---|
| 384 |
|
---|
| 385 | </sect2>
|
---|
[f45b1953] | 386 |
|
---|
| 387 | </sect1>
|
---|