[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 " ">
|
---|
[842348b0] | 10 | <!ENTITY python3-md5sum "d33e4aae66097051c2eca45ee3604803">
|
---|
[d373629] | 11 | <!ENTITY python3-size "16 MB">
|
---|
[842348b0] | 12 | <!ENTITY python3-buildsize "180 MB (add 22 MB for tests)">
|
---|
| 13 | <!ENTITY python3-time "1.0 SBU (add 1.1 SBU for tests)">
|
---|
[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 |
|
---|
[60ddbaf] | 46 | <note><para><application>Python 3</application> was installed in LFS.
|
---|
| 47 | The only reason to rebuild it here is if optional modules
|
---|
| 48 | are needed.</para></note>
|
---|
| 49 |
|
---|
[6030130] | 50 | &lfs90_checked;
|
---|
[48b816cb] | 51 |
|
---|
[83f69e5d] | 52 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 53 | <itemizedlist spacing="compact">
|
---|
| 54 | <listitem>
|
---|
[355495ce] | 55 | <para>
|
---|
| 56 | Download (HTTP): <ulink url="&python3-download-http;"/>
|
---|
| 57 | </para>
|
---|
[83f69e5d] | 58 | </listitem>
|
---|
| 59 | <listitem>
|
---|
[355495ce] | 60 | <para>
|
---|
| 61 | Download (FTP): <ulink url="&python3-download-ftp;"/>
|
---|
| 62 | </para>
|
---|
[83f69e5d] | 63 | </listitem>
|
---|
| 64 | <listitem>
|
---|
[355495ce] | 65 | <para>
|
---|
| 66 | Download MD5 sum: &python3-md5sum;
|
---|
| 67 | </para>
|
---|
[83f69e5d] | 68 | </listitem>
|
---|
| 69 | <listitem>
|
---|
[355495ce] | 70 | <para>
|
---|
| 71 | Download size: &python3-size;
|
---|
| 72 | </para>
|
---|
[83f69e5d] | 73 | </listitem>
|
---|
| 74 | <listitem>
|
---|
[355495ce] | 75 | <para>
|
---|
| 76 | Estimated disk space required: &python3-buildsize;
|
---|
| 77 | </para>
|
---|
[83f69e5d] | 78 | </listitem>
|
---|
| 79 | <listitem>
|
---|
[355495ce] | 80 | <para>
|
---|
| 81 | Estimated build time: &python3-time;
|
---|
| 82 | </para>
|
---|
[83f69e5d] | 83 | </listitem>
|
---|
| 84 | </itemizedlist>
|
---|
[e882fc37] | 85 |
|
---|
[03d30cf] | 86 | <bridgehead renderas="sect3">Python 3 Dependencies</bridgehead>
|
---|
[e882fc37] | 87 |
|
---|
[83f69e5d] | 88 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
[355495ce] | 89 | <para role="optional">
|
---|
[7fe0ce3b] | 90 | <xref linkend="bluez"/>,
|
---|
[e882fc37] | 91 | <xref linkend="gdb"/> (required for some tests),
|
---|
| 92 | <xref linkend="valgrind"/>, and
|
---|
| 93 | <ulink url="http://www.bytereef.org/mpdecimal">libmpcdec</ulink>
|
---|
[355495ce] | 94 | </para>
|
---|
| 95 |
|
---|
| 96 | <bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
|
---|
| 97 | <para role="optional">
|
---|
[6030130] | 98 | <xref linkend="db"/>,
|
---|
| 99 | <xref linkend="sqlite"/>, and
|
---|
| 100 | <xref linkend="tk"/>
|
---|
[355495ce] | 101 | </para>
|
---|
[ce33273] | 102 |
|
---|
[1039de3] | 103 | <para condition="html" role="usernotes">User Notes:
|
---|
[355495ce] | 104 | <ulink url="&blfs-wiki;/Python3"/>
|
---|
| 105 | </para>
|
---|
[83f69e5d] | 106 | </sect2>
|
---|
| 107 |
|
---|
| 108 | <sect2 role="installation">
|
---|
[03d30cf] | 109 | <title>Installation of Python 3</title>
|
---|
[83f69e5d] | 110 |
|
---|
[355495ce] | 111 | <para>
|
---|
[03d30cf] | 112 | Install <application>Python 3</application> by running the following
|
---|
[355495ce] | 113 | commands:
|
---|
| 114 | </para>
|
---|
[83f69e5d] | 115 |
|
---|
[fd69a62] | 116 | <screen><userinput>CXX="/usr/bin/g++" \
|
---|
| 117 | ./configure --prefix=/usr \
|
---|
[c525bd1] | 118 | --enable-shared \
|
---|
[355495ce] | 119 | --with-system-expat \
|
---|
[fd69a62] | 120 | --with-system-ffi \
|
---|
[879932f] | 121 | --with-ensurepip=yes &&
|
---|
[83f69e5d] | 122 | make</userinput></screen>
|
---|
| 123 |
|
---|
[355495ce] | 124 | <para>
|
---|
[7fe0ce3b] | 125 | The test suite must be run separately, using an X terminal (see below).
|
---|
[355495ce] | 126 | </para>
|
---|
| 127 |
|
---|
| 128 | <para>
|
---|
| 129 | Now, as the <systemitem class="username">root</systemitem> user:
|
---|
| 130 | </para>
|
---|
| 131 |
|
---|
[82fac2c] | 132 | <screen role="root"><userinput>make install &&
|
---|
[c525bd1] | 133 | chmod -v 755 /usr/lib/libpython&python3-majorver;m.so &&
|
---|
[355495ce] | 134 | chmod -v 755 /usr/lib/libpython3.so</userinput></screen>
|
---|
[1970f00] | 135 |
|
---|
[7fe0ce3b] | 136 | <para>
|
---|
| 137 | The test suite must be run separately from the build, either before or
|
---|
[7745345d] | 138 | after the package is built and installed. Do not run
|
---|
[af8a78d] | 139 | <command>make install</command> after running the test suite. To build
|
---|
[7745345d] | 140 | and install the package, you need to start with a fresh or clean source
|
---|
[e882fc37] | 141 | tree. For the tests, you also need a clean source code, so either start by
|
---|
[7745345d] | 142 | removing the source code directory and starting over, by uncompressing
|
---|
| 143 | the source tarball or by running <command>make clean</command>. Then
|
---|
| 144 | configure again, adding <quote>--with-pydebug</quote> to the
|
---|
| 145 | <command>configure</command> switches above, run <command>make</command>,
|
---|
[d7d743f0] | 146 | then <command>make test</command>. Remember that tests must be executed
|
---|
[73353e7f] | 147 | using an X terminal.
|
---|
| 148 | The test SBU highly depends on the speed of the internet connection.
|
---|
[7fe0ce3b] | 149 | </para>
|
---|
| 150 |
|
---|
[879d269] | 151 | </sect2>
|
---|
| 152 |
|
---|
| 153 | <sect2 role="commands">
|
---|
| 154 | <title>Command Explanations</title>
|
---|
| 155 |
|
---|
[fd69a62] | 156 | <para>
|
---|
| 157 | <command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
|
---|
| 158 | message during configuration.
|
---|
| 159 | </para>
|
---|
| 160 |
|
---|
[355495ce] | 161 | <para>
|
---|
[f1d7196] | 162 | <parameter>--with-system-expat</parameter>: This switch enables linking
|
---|
| 163 | against the system version of <application>Expat</application>.
|
---|
[355495ce] | 164 | </para>
|
---|
| 165 |
|
---|
| 166 | <para>
|
---|
[f1d7196] | 167 | <parameter>--with-system-ffi</parameter>: This switch enables linking
|
---|
[60ddbaf] | 168 | against system version of <application>libffi</application>.
|
---|
[82fac2c] | 169 | </para>
|
---|
[fd69a62] | 170 |
|
---|
| 171 | <para>
|
---|
[23c5563] | 172 | <parameter>--with-ensurepip=yes</parameter> : This switch enables building
|
---|
| 173 | <command>pip</command> and <command>setuptools</command> packaging programs.
|
---|
| 174 | <command>setuptools</command> is needed for building some Python modules.
|
---|
[fd69a62] | 175 | </para>
|
---|
[82fac2c] | 176 |
|
---|
[f1d7196] | 177 | <para>
|
---|
| 178 | <option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
|
---|
| 179 | if you want to build <application>Python</application> DBM Module
|
---|
| 180 | against <application>Berkeley DB</application> instead of
|
---|
| 181 | <application>GDBM</application>.
|
---|
| 182 | </para>
|
---|
| 183 |
|
---|
[7c57f82] | 184 | <para>
|
---|
| 185 | <option>--enable-optimization</option>: Use this switch
|
---|
| 186 | if you want to enable <emphasis>expensive</emphasis> optimizations (i.e.
|
---|
| 187 | Profile Guided Optimizations). This adds around 20 SBU, but can
|
---|
| 188 | <emphasis>slightly</emphasis> speed up some uses, such as using
|
---|
| 189 | <application>Sphinx</application> for creating documentation, or use of
|
---|
| 190 | <application>Python3</application> scripts.
|
---|
| 191 | </para>
|
---|
| 192 |
|
---|
| 193 | <para>
|
---|
| 194 | <option>--with-lto</option>: This optional switch enables thick Link
|
---|
| 195 | Time Optimization. Unusually, it creates a much larger <filename
|
---|
| 196 | class="libraryfile">/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu/libpython3.7m.a</filename>
|
---|
| 197 | with a small increase in the time to compile
|
---|
| 198 | <application>Python</application>. Run-time results do not appear to show
|
---|
| 199 | any benefit from doing this.
|
---|
| 200 | </para>
|
---|
| 201 |
|
---|
[355495ce] | 202 | <para>
|
---|
[0d7900a] | 203 | <command>chmod ...</command>: Fix permissions for shared libraries to be
|
---|
[355495ce] | 204 | consistent with other libraries.
|
---|
| 205 | </para>
|
---|
[7224506] | 206 |
|
---|
[879d269] | 207 | </sect2>
|
---|
| 208 |
|
---|
| 209 | <sect2 role="configuration">
|
---|
[03d30cf] | 210 | <title>Configuring Python 3</title>
|
---|
[879d269] | 211 |
|
---|
[355495ce] | 212 | <para>
|
---|
[03d30cf] | 213 | In order for <command>python3</command> to find the installed
|
---|
[d7015e7] | 214 | documentation, create the following version independent symlink:
|
---|
[355495ce] | 215 | </para>
|
---|
[1970f00] | 216 |
|
---|
[d7015e7] | 217 | <screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
|
---|
| 218 |
|
---|
| 219 | <para>
|
---|
| 220 | and add the following environment variable to the individual user's or
|
---|
| 221 | system's profile:
|
---|
| 222 | </para>
|
---|
| 223 |
|
---|
| 224 | <screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
|
---|
[83f69e5d] | 225 |
|
---|
| 226 | </sect2>
|
---|
| 227 |
|
---|
| 228 | <sect2 role="content">
|
---|
| 229 | <title>Contents</title>
|
---|
| 230 |
|
---|
| 231 | <segmentedlist>
|
---|
| 232 | <segtitle>Installed Programs</segtitle>
|
---|
| 233 | <segtitle>Installed Libraries</segtitle>
|
---|
| 234 | <segtitle>Installed Directories</segtitle>
|
---|
| 235 |
|
---|
| 236 | <seglistitem>
|
---|
[355495ce] | 237 | <seg>
|
---|
[7fe0ce3b] | 238 | 2to3 (symlink),
|
---|
[355495ce] | 239 | 2to3-&python3-majorver;,
|
---|
| 240 |
|
---|
[f5c5306] | 241 | idle3 (symlink), and
|
---|
| 242 | idle&python3-majorver;
|
---|
| 243 |
|
---|
[7fe0ce3b] | 244 | pydoc3 (symlink),
|
---|
[355495ce] | 245 | pydoc&python3-majorver;,
|
---|
| 246 |
|
---|
[7fe0ce3b] | 247 | python3 (symlink);
|
---|
| 248 | python&python3-majorver; and python&python3-majorver;m (hardlinked);
|
---|
[355495ce] | 249 |
|
---|
[7fe0ce3b] | 250 | python3-config (symlink),
|
---|
| 251 | python&python3-majorver;-config (symlink),
|
---|
[c525bd1] | 252 | python&python3-majorver;m-config,
|
---|
[355495ce] | 253 |
|
---|
[7fe0ce3b] | 254 | pyvenv (symlink),
|
---|
[41d241e] | 255 | pyvenv-&python3-majorver;,
|
---|
[355495ce] | 256 | </seg>
|
---|
| 257 | <seg>
|
---|
[47f0aa1] | 258 | libpython&python3-majorver;m.so and libpython3.so
|
---|
[355495ce] | 259 | </seg>
|
---|
| 260 | <seg>
|
---|
[c525bd1] | 261 | /usr/include/python&python3-majorver;m,
|
---|
[355495ce] | 262 | /usr/lib/python&python3-majorver;, and
|
---|
| 263 | /usr/share/doc/python-&python3-version;
|
---|
| 264 | </seg>
|
---|
[83f69e5d] | 265 | </seglistitem>
|
---|
| 266 | </segmentedlist>
|
---|
| 267 |
|
---|
| 268 | <variablelist>
|
---|
| 269 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 270 | <?dbfo list-presentation="list"?>
|
---|
| 271 | <?dbhtml list-presentation="table"?>
|
---|
| 272 |
|
---|
[355495ce] | 273 | <varlistentry id="idle3">
|
---|
| 274 | <term><command>idle3</command></term>
|
---|
[83f69e5d] | 275 | <listitem>
|
---|
[355495ce] | 276 | <para>
|
---|
[d0aecd33] | 277 | is a wrapper script that opens a <application>Python</application>
|
---|
| 278 | aware GUI editor. For this script to run, you must have installed
|
---|
| 279 | <application>Tk</application> before Python so that the Tkinter
|
---|
| 280 | Python module is built.
|
---|
[355495ce] | 281 | </para>
|
---|
| 282 | <indexterm zone="python3 idle3">
|
---|
| 283 | <primary sortas="b-idle3">idle3</primary>
|
---|
[83f69e5d] | 284 | </indexterm>
|
---|
| 285 | </listitem>
|
---|
| 286 | </varlistentry>
|
---|
| 287 |
|
---|
[355495ce] | 288 | <varlistentry id="pydoc3">
|
---|
| 289 | <term><command>pydoc3</command></term>
|
---|
[83f69e5d] | 290 | <listitem>
|
---|
[355495ce] | 291 | <para>
|
---|
| 292 | is the <application>Python</application> documentation
|
---|
| 293 | tool.
|
---|
| 294 | </para>
|
---|
| 295 | <indexterm zone="python3 pydoc3">
|
---|
| 296 | <primary sortas="b-pydoc3">pydo3c</primary>
|
---|
[83f69e5d] | 297 | </indexterm>
|
---|
| 298 | </listitem>
|
---|
| 299 | </varlistentry>
|
---|
| 300 |
|
---|
[b88be39] | 301 | <varlistentry id="python3-prog">
|
---|
[2cee003] | 302 | <term><command>python3</command></term>
|
---|
[83f69e5d] | 303 | <listitem>
|
---|
[355495ce] | 304 | <para>
|
---|
| 305 | is an interpreted, interactive, object-oriented programming
|
---|
| 306 | language.
|
---|
| 307 | </para>
|
---|
[b88be39] | 308 | <indexterm zone="python3 python3-prog">
|
---|
| 309 | <primary sortas="b-python3">python3</primary>
|
---|
[83f69e5d] | 310 | </indexterm>
|
---|
| 311 | </listitem>
|
---|
| 312 | </varlistentry>
|
---|
| 313 |
|
---|
[f67f5387] | 314 | <varlistentry id="python-ver">
|
---|
[b88be39] | 315 | <term><command>python&python3-majorver;</command></term>
|
---|
[83f69e5d] | 316 | <listitem>
|
---|
[355495ce] | 317 | <para>
|
---|
| 318 | is a version-specific name for the <command>python</command>
|
---|
| 319 | program.
|
---|
| 320 | </para>
|
---|
[b88be39] | 321 | <indexterm zone="python3 python-ver">
|
---|
[2cee003] | 322 | <primary
|
---|
| 323 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
[83f69e5d] | 324 | </indexterm>
|
---|
| 325 | </listitem>
|
---|
| 326 | </varlistentry>
|
---|
| 327 |
|
---|
[21e8edc] | 328 | <varlistentry id="pyvenv">
|
---|
| 329 | <term><command>pyvenv</command></term>
|
---|
| 330 | <listitem>
|
---|
| 331 | <para>
|
---|
| 332 | creates virtual <application>Python</application> environments in
|
---|
| 333 | one or more target directories.
|
---|
| 334 | </para>
|
---|
| 335 | <indexterm zone="python3 pyvenv">
|
---|
| 336 | <primary
|
---|
| 337 | sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
|
---|
| 338 | </indexterm>
|
---|
| 339 | </listitem>
|
---|
| 340 | </varlistentry>
|
---|
| 341 |
|
---|
[83f69e5d] | 342 | </variablelist>
|
---|
| 343 |
|
---|
| 344 | </sect2>
|
---|
[f45b1953] | 345 |
|
---|
| 346 | </sect1>
|
---|