[fcc02767] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 | ]>
|
---|
| 7 |
|
---|
| 8 | <sect1 id="ch-system-Python" role="wrap">
|
---|
| 9 | <?dbhtml filename="Python.html"?>
|
---|
| 10 |
|
---|
| 11 | <sect1info condition="script">
|
---|
| 12 | <productname>Python</productname>
|
---|
| 13 | <productnumber>&python-version;</productnumber>
|
---|
| 14 | <address>&python-url;</address>
|
---|
| 15 | </sect1info>
|
---|
| 16 |
|
---|
| 17 | <title>Python-&python-version;</title>
|
---|
| 18 |
|
---|
| 19 | <indexterm zone="ch-system-Python">
|
---|
[4798321] | 20 | <primary sortas="a-Python">Python</primary>
|
---|
[fcc02767] | 21 | </indexterm>
|
---|
| 22 |
|
---|
| 23 | <sect2 role="package">
|
---|
| 24 | <title/>
|
---|
| 25 |
|
---|
| 26 | <para>The Python 3 package contains the Python development environment. It
|
---|
| 27 | is useful for object-oriented programming, writing scripts, prototyping
|
---|
[6a156bab] | 28 | large programs, or developing entire applications.</para>
|
---|
[fcc02767] | 29 |
|
---|
| 30 | <segmentedlist>
|
---|
| 31 | <segtitle>&buildtime;</segtitle>
|
---|
| 32 | <segtitle>&diskspace;</segtitle>
|
---|
| 33 |
|
---|
| 34 | <seglistitem>
|
---|
[fb386e0] | 35 | <seg>&python-fin-sbu;</seg>
|
---|
| 36 | <seg>&python-fin-du;</seg>
|
---|
[fcc02767] | 37 | </seglistitem>
|
---|
| 38 | </segmentedlist>
|
---|
| 39 |
|
---|
| 40 | </sect2>
|
---|
| 41 |
|
---|
| 42 | <sect2 role="installation">
|
---|
| 43 | <title>Installation of Python 3</title>
|
---|
| 44 |
|
---|
| 45 | <para>Prepare Python for compilation:</para>
|
---|
| 46 |
|
---|
[5ed37b3] | 47 | <screen><userinput remap="configure">./configure --prefix=/usr \
|
---|
| 48 | --enable-shared \
|
---|
| 49 | --with-system-expat \
|
---|
| 50 | --with-system-ffi \
|
---|
| 51 | --enable-optimizations</userinput></screen>
|
---|
[fcc02767] | 52 |
|
---|
| 53 | <variablelist>
|
---|
| 54 | <title>The meaning of the configure options:</title>
|
---|
| 55 |
|
---|
| 56 | <varlistentry>
|
---|
| 57 | <term><parameter>--with-system-expat</parameter></term>
|
---|
| 58 | <listitem>
|
---|
| 59 | <para>This switch enables linking against system version of
|
---|
| 60 | <application>Expat</application>.</para>
|
---|
| 61 | </listitem>
|
---|
| 62 | </varlistentry>
|
---|
| 63 |
|
---|
| 64 | <varlistentry>
|
---|
| 65 | <term><parameter>--with-system-ffi</parameter></term>
|
---|
| 66 | <listitem>
|
---|
| 67 | <para>This switch enables linking against system version of
|
---|
| 68 | <application>libffi</application>.</para>
|
---|
| 69 | </listitem>
|
---|
| 70 | </varlistentry>
|
---|
| 71 |
|
---|
[5ed37b3] | 72 | <varlistentry>
|
---|
| 73 | <term><parameter>--enable-optimizations</parameter></term>
|
---|
| 74 | <listitem>
|
---|
| 75 | <para>This switch enables stable, but expensive, optimizations.</para>
|
---|
| 76 | </listitem>
|
---|
| 77 | </varlistentry>
|
---|
| 78 |
|
---|
[fcc02767] | 79 | </variablelist>
|
---|
| 80 |
|
---|
| 81 | <para>Compile the package:</para>
|
---|
| 82 |
|
---|
| 83 | <screen><userinput remap="make">make</userinput></screen>
|
---|
| 84 |
|
---|
[5ed37b3] | 85 | <para>Running the tests at this point is not recommended. The
|
---|
| 86 | tests are known to hang indefinitely in the partial LFS environment.
|
---|
| 87 | If desired, the tests can be rerun at the end of this chapter or
|
---|
| 88 | when Python 3 is reinstalled in BLFS. To run the tests anyway,
|
---|
| 89 | issue <command>make test</command>.</para>
|
---|
[fcc02767] | 90 |
|
---|
| 91 | <para>Install the package:</para>
|
---|
| 92 |
|
---|
[3cf8a59] | 93 | <screen><userinput remap="install">make install</userinput></screen>
|
---|
[fcc02767] | 94 |
|
---|
[94bf45a] | 95 | <para>In several places we use the <command>pip3</command> command to
|
---|
[ee16e55] | 96 | install Python 3 programs and modules for all users as
|
---|
| 97 | <systemitem class='username'>root</systemitem>. This conflicts
|
---|
| 98 | with the Python developers recommendation to install packages into a
|
---|
| 99 | virtual environment or the home directory of a regular user (by running
|
---|
| 100 | <command>pip3</command> as this user). To this end, a multi-line warning
|
---|
| 101 | is written when using <command>pip3</command> as the
|
---|
| 102 | <systemitem class='username'>root</systemitem> user. The main reason
|
---|
| 103 | of this recommendation is for avoiding a conflict with the system
|
---|
| 104 | package manager (<command>dpkg</command> for example), but LFS does not
|
---|
[bf6f9e7] | 105 | have a system-wide package manager so this is not a problem. And,
|
---|
| 106 | <command>pip3</command> will attempt to check for a new version of
|
---|
| 107 | itself whenever it's run. As domain name resolving is not configured
|
---|
| 108 | yet in LFS chroot environment, it will fail to check for a new version
|
---|
| 109 | and produce a warning. Once we boot the LFS system and set up network
|
---|
| 110 | connection, it will then produce a warning telling the user to update it
|
---|
| 111 | from a pre-built wheel on PyPI if any new version is available. But LFS
|
---|
| 112 | consider <command>pip3</command> a part of Python 3 so it should not be
|
---|
| 113 | updated separately, and an update from a pre-built wheel will deviate
|
---|
| 114 | from our purpose to build a Linux system from source code. So the
|
---|
| 115 | warning for a new <command>pip3</command> version should be ignored as
|
---|
| 116 | well. If desired, suppress these warnings by running the following
|
---|
| 117 | commands:</para>
|
---|
[e953813] | 118 |
|
---|
[3094b8c] | 119 | <screen><userinput remap="install">cat > /etc/pip.conf << EOF
|
---|
| 120 | [global]
|
---|
| 121 | root-user-action = ignore
|
---|
[bf6f9e7] | 122 | disable-pip-version-check = true
|
---|
[3094b8c] | 123 | EOF
|
---|
| 124 | </userinput></screen>
|
---|
| 125 | <!--
|
---|
[e953813] | 126 | <screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
|
---|
| 127 | -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
|
---|
| 128 | </userinput></screen>
|
---|
[3094b8c] | 129 | -->
|
---|
[720c0bd] | 130 | <important>
|
---|
| 131 | <para>
|
---|
[dd9987c] | 132 | In LFS and BLFS we normally build and install Python modules with the
|
---|
| 133 | <command>pip3</command> command. Please take care that the
|
---|
[720c0bd] | 134 | <command>pip3 install</command> commands in both the books should be
|
---|
[93db1e61] | 135 | run as the &root; user unless it's for a Python virtual environment.
|
---|
[dd9987c] | 136 | Running a <command>pip3 install</command> as a non-&root; user may seem
|
---|
| 137 | to work fine, but it will cause the installed module to be inaccessible
|
---|
| 138 | by other users.
|
---|
[720c0bd] | 139 | </para>
|
---|
[dd9987c] | 140 |
|
---|
[720c0bd] | 141 | <para>
|
---|
[dd9987c] | 142 | <command>pip3 install</command> will not reinstall an already installed
|
---|
| 143 | module by default. For using the <command>pip3 install</command>
|
---|
| 144 | command to upgrade a module (for example, from meson-0.61.3 to
|
---|
| 145 | meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
|
---|
| 146 | the command line. If it's really necessary to downgrade a module or
|
---|
[af3cf8d] | 147 | reinstall the same version for some reason, insert
|
---|
| 148 | <parameter>--force-reinstall --no-deps</parameter> into the command
|
---|
| 149 | line.
|
---|
[720c0bd] | 150 | </para>
|
---|
| 151 | </important>
|
---|
[e953813] | 152 |
|
---|
[fcc02767] | 153 | <para>If desired, install the preformatted documentation:</para>
|
---|
| 154 |
|
---|
[d672ab7] | 155 | <screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
|
---|
[fcc02767] | 156 |
|
---|
| 157 | tar --strip-components=1 \
|
---|
| 158 | --no-same-owner \
|
---|
| 159 | --no-same-permissions \
|
---|
| 160 | -C /usr/share/doc/python-&python-version;/html \
|
---|
| 161 | -xvf ../python-&python-version;-docs-html.tar.bz2</userinput></screen>
|
---|
| 162 |
|
---|
| 163 | <variablelist>
|
---|
| 164 | <title>The meaning of the documentation install commands:</title>
|
---|
| 165 |
|
---|
| 166 | <varlistentry>
|
---|
| 167 | <term><option>--no-same-owner</option> and <option>--no-same-permissions</option></term>
|
---|
| 168 | <listitem>
|
---|
[d672ab7] | 169 | <para>Ensure the installed files have the correct ownership and
|
---|
[fcc02767] | 170 | permissions. Without these options, using <application>tar</application>
|
---|
[d672ab7] | 171 | will install the package files with the upstream creator's values.
|
---|
[fcc02767] | 172 | </para>
|
---|
| 173 | </listitem>
|
---|
| 174 | </varlistentry>
|
---|
| 175 |
|
---|
| 176 | </variablelist>
|
---|
| 177 |
|
---|
| 178 | </sect2>
|
---|
| 179 |
|
---|
| 180 | <sect2 id="contents-python" role="content">
|
---|
| 181 | <title>Contents of Python 3</title>
|
---|
| 182 |
|
---|
| 183 | <segmentedlist>
|
---|
| 184 | <segtitle>Installed Programs</segtitle>
|
---|
| 185 | <segtitle>Installed Library</segtitle>
|
---|
| 186 | <segtitle>Installed Directories</segtitle>
|
---|
| 187 |
|
---|
| 188 | <seglistitem>
|
---|
| 189 | <seg>
|
---|
| 190 | 2to3, idle3, pip3, pydoc3, python3, and python3-config
|
---|
| 191 | </seg>
|
---|
| 192 | <seg>
|
---|
| 193 | libpython&python-minor;.so and libpython3.so
|
---|
| 194 | </seg>
|
---|
| 195 | <seg>
|
---|
[d672ab7] | 196 | /usr/include/python&python-minor;,
|
---|
[fcc02767] | 197 | /usr/lib/python3, and
|
---|
| 198 | /usr/share/doc/python-&python-version;
|
---|
| 199 | </seg>
|
---|
| 200 | </seglistitem>
|
---|
| 201 | </segmentedlist>
|
---|
| 202 |
|
---|
| 203 | <variablelist>
|
---|
| 204 | <bridgehead renderas="sect3">Short Descriptions</bridgehead>
|
---|
| 205 | <?dbfo list-presentation="list"?>
|
---|
| 206 | <?dbhtml list-presentation="table"?>
|
---|
| 207 |
|
---|
| 208 | <varlistentry id="python-2to3">
|
---|
| 209 | <term><command>2to3</command></term>
|
---|
| 210 | <listitem>
|
---|
| 211 | <para>
|
---|
| 212 | is a <application>Python</application> program that reads
|
---|
| 213 | <application>Python 2.x</application> source code and applies a
|
---|
[d672ab7] | 214 | series of fixes to transform it into
|
---|
[8d35535] | 215 | valid <application>Python 3.x</application> code
|
---|
[fcc02767] | 216 | </para>
|
---|
| 217 | <indexterm zone="ch-system-Python">
|
---|
| 218 | <primary sortas="b-2to3">2to3</primary>
|
---|
| 219 | </indexterm>
|
---|
| 220 | </listitem>
|
---|
| 221 | </varlistentry>
|
---|
| 222 |
|
---|
| 223 | <varlistentry id="idle3">
|
---|
| 224 | <term><command>idle3</command></term>
|
---|
| 225 | <listitem>
|
---|
| 226 | <para>
|
---|
| 227 | is a wrapper script that opens a <application>Python</application>
|
---|
| 228 | aware GUI editor. For this script to run, you must have installed
|
---|
| 229 | <application>Tk</application> before Python so that the Tkinter
|
---|
[8d35535] | 230 | Python module is built
|
---|
[fcc02767] | 231 | </para>
|
---|
| 232 | <indexterm zone="ch-system-Python">
|
---|
| 233 | <primary sortas="b-idle3">idle3</primary>
|
---|
| 234 | </indexterm>
|
---|
| 235 | </listitem>
|
---|
| 236 | </varlistentry>
|
---|
| 237 |
|
---|
| 238 | <varlistentry id="pip3">
|
---|
| 239 | <term><command>pip3</command></term>
|
---|
| 240 | <listitem>
|
---|
| 241 | <para>
|
---|
| 242 | The package installer for Python. You can use pip to install
|
---|
[8d35535] | 243 | packages from Python Package Index and other indexes
|
---|
[fcc02767] | 244 | </para>
|
---|
| 245 | <indexterm zone="ch-system-Python">
|
---|
| 246 | <primary sortas="b-pip3">pip3</primary>
|
---|
| 247 | </indexterm>
|
---|
| 248 | </listitem>
|
---|
| 249 | </varlistentry>
|
---|
| 250 |
|
---|
| 251 | <varlistentry id="pydoc3">
|
---|
| 252 | <term><command>pydoc3</command></term>
|
---|
| 253 | <listitem>
|
---|
| 254 | <para>
|
---|
[8d35535] | 255 | is the <application>Python</application> documentation tool
|
---|
[fcc02767] | 256 | </para>
|
---|
| 257 | <indexterm zone="ch-system-Python">
|
---|
| 258 | <primary sortas="b-pydoc3">pydoc3</primary>
|
---|
| 259 | </indexterm>
|
---|
| 260 | </listitem>
|
---|
| 261 | </varlistentry>
|
---|
| 262 |
|
---|
| 263 | <varlistentry id="python3">
|
---|
| 264 | <term><command>python3</command></term>
|
---|
| 265 | <listitem>
|
---|
| 266 | <para>
|
---|
| 267 | is an interpreted, interactive, object-oriented programming
|
---|
[8d35535] | 268 | language
|
---|
[fcc02767] | 269 | </para>
|
---|
| 270 | <indexterm zone="ch-system-Python">
|
---|
| 271 | <primary sortas="b-python3">python3</primary>
|
---|
| 272 | </indexterm>
|
---|
| 273 | </listitem>
|
---|
| 274 | </varlistentry>
|
---|
[6a156bab] | 275 |
|
---|
[fcc02767] | 276 | </variablelist>
|
---|
| 277 |
|
---|
| 278 | </sect2>
|
---|
| 279 |
|
---|
| 280 | </sect1>
|
---|
| 281 |
|
---|