source: chapter08/python.xml@ 8b4fb12

12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 8b4fb12 was dc8572f, checked in by Thomas Trepl <thomas@…>, 7 months ago

Fix cmds installing python docs (permissions)

  • Property mode set to 100644
File size: 10.1 KB
RevLine 
[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
[8e751f7]28 large programs, and developing entire applications. Python is an interpreted
29 computer language.</para>
[fcc02767]30
31 <segmentedlist>
32 <segtitle>&buildtime;</segtitle>
33 <segtitle>&diskspace;</segtitle>
34
35 <seglistitem>
[fb386e0]36 <seg>&python-fin-sbu;</seg>
37 <seg>&python-fin-du;</seg>
[fcc02767]38 </seglistitem>
39 </segmentedlist>
40
41 </sect2>
42
43 <sect2 role="installation">
44 <title>Installation of Python 3</title>
45
46 <para>Prepare Python for compilation:</para>
47
[5ed37b3]48<screen><userinput remap="configure">./configure --prefix=/usr \
49 --enable-shared \
50 --with-system-expat \
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>
[8e751f7]59 <para>This switch enables linking against the system version of
[fcc02767]60 <application>Expat</application>.</para>
61 </listitem>
62 </varlistentry>
63
[5ed37b3]64 <varlistentry>
65 <term><parameter>--enable-optimizations</parameter></term>
66 <listitem>
[8e751f7]67 <para>This switch enables extensive, but time-consuming, optimization
68 steps. The interpreter is built twice; tests performed on the first
69 build are used to improve the optimized final version.</para>
70 <!-- This description was drawn from the README.rst file
71 in the Python-3.11.0 package. -->
[5ed37b3]72 </listitem>
73 </varlistentry>
74
[fcc02767]75 </variablelist>
76
77 <para>Compile the package:</para>
78
79<screen><userinput remap="make">make</userinput></screen>
80
[5ed37b3]81 <para>Running the tests at this point is not recommended. The
82 tests are known to hang indefinitely in the partial LFS environment.
[8e751f7]83 If desired, the tests can be rerun at the end of this chapter, or
[5ed37b3]84 when Python 3 is reinstalled in BLFS. To run the tests anyway,
85 issue <command>make test</command>.</para>
[fcc02767]86
87 <para>Install the package:</para>
88
[3cf8a59]89<screen><userinput remap="install">make install</userinput></screen>
[fcc02767]90
[8e751f7]91 <para>We use the <command>pip3</command> command to
[ee16e55]92 install Python 3 programs and modules for all users as
[8e751f7]93 <systemitem class='username'>root</systemitem> in several places in this book.
94 This conflicts with the Python developers' recommendation: to install packages into a
95 virtual environment, or into the home directory of a regular user (by running
96 <command>pip3</command> as this user). A multi-line warning
97 is triggered whenever <command>pip3</command> is issued by the
98 <systemitem class='username'>root</systemitem> user.</para>
99
100 <para>The main reason
101 for the recommendation is to avoid conflicts with the system's
102 package manager (<command>dpkg</command>, for example). LFS does not
103 have a system-wide package manager, so this is not a problem. Also,
104 <command>pip3</command> will check for a new version of
105 itself whenever it's run. Since domain name resolution is not yet configured
106 in the LFS chroot environment, <command>pip3</command> cannot check
107 for a new version of itself, and will
108 produce a warning. </para>
109
110 <para>After we boot the LFS system and set up a network connection,
111 a different warning will be issued, telling the user to update <command>pip3</command>
112 from a pre-built wheel on PyPI (whenever a new version is available). But LFS
113 considers <command>pip3</command> to be a part of Python 3, so it should not be
114 updated separately. Also, an update from a pre-built wheel would deviate
115 from our objective: to build a Linux system from source code. So the
116 warning about a new version of <command>pip3</command> should be ignored as
117 well. If you wish, you can suppress all these warnings by running the following
118 command, which creates a configuration file:</para>
[e953813]119
[2e9e5b4]120<screen><userinput remap="install">cat &gt; /etc/pip.conf &lt;&lt; EOF
121<literal>[global]
[3094b8c]122root-user-action = ignore
[2e9e5b4]123disable-pip-version-check = true</literal>
[3094b8c]124EOF
125</userinput></screen>
126<!--
[e953813]127<screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
128 -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
129</userinput></screen>
[3094b8c]130-->
[720c0bd]131 <important>
132 <para>
[dd9987c]133 In LFS and BLFS we normally build and install Python modules with the
[8e751f7]134 <command>pip3</command> command. Please be sure that the
135 <command>pip3 install</command> commands in both books are
136 run as the &root; user (unless it's for a Python virtual environment).
137 Running <command>pip3 install</command> as a non-&root; user may seem
138 to work, but it will cause the installed module to be inaccessible
[dd9987c]139 by other users.
[720c0bd]140 </para>
[dd9987c]141
[720c0bd]142 <para>
[dd9987c]143 <command>pip3 install</command> will not reinstall an already installed
[8e751f7]144 module automatically. When using the <command>pip3 install</command>
[dd9987c]145 command to upgrade a module (for example, from meson-0.61.3 to
146 meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
[8e751f7]147 the command line. If it's really necessary to downgrade a module, or
[af3cf8d]148 reinstall the same version for some reason, insert
149 <parameter>--force-reinstall --no-deps</parameter> into the command
150 line.
[720c0bd]151 </para>
152 </important>
[e953813]153
[fcc02767]154 <para>If desired, install the preformatted documentation:</para>
155
[d672ab7]156<screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
[fcc02767]157
[dc8572f]158tar --no-same-owner \
159 -xvf ../python-&python-version;-docs-html.tar.bz2
160cp -R --no-preserve=mode python-&python-version;-docs-html/* \
161 /usr/share/doc/python-&python-version;/html</userinput></screen>
[fcc02767]162
163 <variablelist>
164 <title>The meaning of the documentation install commands:</title>
165
166 <varlistentry>
[dc8572f]167 <term><option>--no-same-owner</option> (tar) and <option>--no-preserve=mode</option> (cp)</term>
[fcc02767]168 <listitem>
[d672ab7]169 <para>Ensure the installed files have the correct ownership and
[8e751f7]170 permissions. Without these options, <application>tar</application>
[dc8572f]171 will install the package files with the upstream creator's values
172 and files would have restrictive permissions.
[fcc02767]173 </para>
174 </listitem>
175 </varlistentry>
176
177 </variablelist>
178
179 </sect2>
180
181 <sect2 id="contents-python" role="content">
182 <title>Contents of Python 3</title>
183
184 <segmentedlist>
[ab31b97]185 <segtitle>Installed programs</segtitle>
186 <segtitle>Installed library</segtitle>
187 <segtitle>Installed directories</segtitle>
[fcc02767]188
189 <seglistitem>
190 <seg>
191 2to3, idle3, pip3, pydoc3, python3, and python3-config
192 </seg>
193 <seg>
194 libpython&python-minor;.so and libpython3.so
195 </seg>
196 <seg>
[d672ab7]197 /usr/include/python&python-minor;,
[fcc02767]198 /usr/lib/python3, and
199 /usr/share/doc/python-&python-version;
200 </seg>
201 </seglistitem>
202 </segmentedlist>
203
204 <variablelist>
205 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
206 <?dbfo list-presentation="list"?>
207 <?dbhtml list-presentation="table"?>
208
209 <varlistentry id="python-2to3">
210 <term><command>2to3</command></term>
211 <listitem>
212 <para>
213 is a <application>Python</application> program that reads
214 <application>Python 2.x</application> source code and applies a
[d672ab7]215 series of fixes to transform it into
[8d35535]216 valid <application>Python 3.x</application> code
[fcc02767]217 </para>
218 <indexterm zone="ch-system-Python">
219 <primary sortas="b-2to3">2to3</primary>
220 </indexterm>
221 </listitem>
222 </varlistentry>
223
224 <varlistentry id="idle3">
225 <term><command>idle3</command></term>
226 <listitem>
227 <para>
228 is a wrapper script that opens a <application>Python</application>
229 aware GUI editor. For this script to run, you must have installed
[8e751f7]230 <application>Tk</application> before Python, so that the Tkinter
231 Python module is built.
[fcc02767]232 </para>
233 <indexterm zone="ch-system-Python">
234 <primary sortas="b-idle3">idle3</primary>
235 </indexterm>
236 </listitem>
237 </varlistentry>
238
239 <varlistentry id="pip3">
240 <term><command>pip3</command></term>
241 <listitem>
242 <para>
243 The package installer for Python. You can use pip to install
[8e751f7]244 packages from Python Package Index and other indexes.
[fcc02767]245 </para>
246 <indexterm zone="ch-system-Python">
247 <primary sortas="b-pip3">pip3</primary>
248 </indexterm>
249 </listitem>
250 </varlistentry>
251
252 <varlistentry id="pydoc3">
253 <term><command>pydoc3</command></term>
254 <listitem>
255 <para>
[8d35535]256 is the <application>Python</application> documentation tool
[fcc02767]257 </para>
258 <indexterm zone="ch-system-Python">
259 <primary sortas="b-pydoc3">pydoc3</primary>
260 </indexterm>
261 </listitem>
262 </varlistentry>
263
264 <varlistentry id="python3">
265 <term><command>python3</command></term>
266 <listitem>
267 <para>
[8e751f7]268 is the interpreter for Python, an interpreted, interactive,
269 object-oriented programming language
[fcc02767]270 </para>
271 <indexterm zone="ch-system-Python">
272 <primary sortas="b-python3">python3</primary>
273 </indexterm>
274 </listitem>
275 </varlistentry>
[6a156bab]276
[fcc02767]277 </variablelist>
278
279 </sect2>
280
281</sect1>
282
Note: See TracBrowser for help on using the repository browser.