source: chapter08/python.xml@ 94bf45a

11.2 11.2-rc1 multilib s6-init trunk xry111/arm64 xry111/clfs-ng xry111/pip3 xry111/queue-11.3 xry111/rust-wip-20221008
Last change on this file since 94bf45a was 94bf45a, checked in by Bruce Dubbs <bdubbs@…>, 5 months ago

Spelling

  • Property mode set to 100644
File size: 8.9 KB
Line 
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">
20 <primary sortas="a-Python">Python</primary>
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
28 large programs, or developing entire applications.</para>
29
30 <segmentedlist>
31 <segtitle>&buildtime;</segtitle>
32 <segtitle>&diskspace;</segtitle>
33
34 <seglistitem>
35 <seg>&python-fin-sbu;</seg>
36 <seg>&python-fin-du;</seg>
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
47<screen><userinput remap="configure">./configure --prefix=/usr \
48 --enable-shared \
49 --with-system-expat \
50 --with-system-ffi \
51 --enable-optimizations</userinput></screen>
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
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
79 </variablelist>
80
81 <para>Compile the package:</para>
82
83<screen><userinput remap="make">make</userinput></screen>
84
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>
90
91 <para>Install the package:</para>
92
93<screen><userinput remap="install">make install</userinput></screen>
94
95 <para>In several places we use the <command>pip3</command> command to
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
105 have a system-wide package manager so this is not a problem. If desired,
106 suppress this warning by running the following command:</para>
107
108<screen><userinput remap="install">sed -e '/def warn_if_run_as_root/a\ return' \
109 -i /usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py
110</userinput></screen>
111
112 <important>
113 <para>
114 In LFS and BLFS we normally build and install Python modules with the
115 <command>pip3</command> command. Please take care that the
116 <command>pip3 install</command> commands in both the books should be
117 run as the &root; user unless it's for a Python virtual environment.
118 Running a <command>pip3 install</command> as a non-&root; user may seem
119 to work fine, but it will cause the installed module to be inaccessible
120 by other users.
121 </para>
122
123 <para>
124 <command>pip3 install</command> will not reinstall an already installed
125 module by default. For using the <command>pip3 install</command>
126 command to upgrade a module (for example, from meson-0.61.3 to
127 meson-0.62.0), insert the option <parameter>--upgrade</parameter> into
128 the command line. If it's really necessary to downgrade a module or
129 reinstall the same version for some reason, insert
130 <parameter>--force-reinstall --no-deps</parameter> into the command
131 line.
132 </para>
133 </important>
134
135 <para>If desired, install the preformatted documentation:</para>
136
137<screen><userinput remap="install">install -v -dm755 /usr/share/doc/python-&python-version;/html
138
139tar --strip-components=1 \
140 --no-same-owner \
141 --no-same-permissions \
142 -C /usr/share/doc/python-&python-version;/html \
143 -xvf ../python-&python-version;-docs-html.tar.bz2</userinput></screen>
144
145 <variablelist>
146 <title>The meaning of the documentation install commands:</title>
147
148 <varlistentry>
149 <term><option>--no-same-owner</option> and <option>--no-same-permissions</option></term>
150 <listitem>
151 <para>Ensure the installed files have the correct ownership and
152 permissions. Without these options, using <application>tar</application>
153 will install the package files with the upstream creator's values.
154 </para>
155 </listitem>
156 </varlistentry>
157
158 </variablelist>
159
160 </sect2>
161
162 <sect2 id="contents-python" role="content">
163 <title>Contents of Python 3</title>
164
165 <segmentedlist>
166 <segtitle>Installed Programs</segtitle>
167 <segtitle>Installed Library</segtitle>
168 <segtitle>Installed Directories</segtitle>
169
170 <seglistitem>
171 <seg>
172 2to3, idle3, pip3, pydoc3, python3, and python3-config
173 </seg>
174 <seg>
175 libpython&python-minor;.so and libpython3.so
176 </seg>
177 <seg>
178 /usr/include/python&python-minor;,
179 /usr/lib/python3, and
180 /usr/share/doc/python-&python-version;
181 </seg>
182 </seglistitem>
183 </segmentedlist>
184
185 <variablelist>
186 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
187 <?dbfo list-presentation="list"?>
188 <?dbhtml list-presentation="table"?>
189
190 <varlistentry id="python-2to3">
191 <term><command>2to3</command></term>
192 <listitem>
193 <para>
194 is a <application>Python</application> program that reads
195 <application>Python 2.x</application> source code and applies a
196 series of fixes to transform it into
197 valid <application>Python 3.x</application> code
198 </para>
199 <indexterm zone="ch-system-Python">
200 <primary sortas="b-2to3">2to3</primary>
201 </indexterm>
202 </listitem>
203 </varlistentry>
204
205 <varlistentry id="idle3">
206 <term><command>idle3</command></term>
207 <listitem>
208 <para>
209 is a wrapper script that opens a <application>Python</application>
210 aware GUI editor. For this script to run, you must have installed
211 <application>Tk</application> before Python so that the Tkinter
212 Python module is built
213 </para>
214 <indexterm zone="ch-system-Python">
215 <primary sortas="b-idle3">idle3</primary>
216 </indexterm>
217 </listitem>
218 </varlistentry>
219
220 <varlistentry id="pip3">
221 <term><command>pip3</command></term>
222 <listitem>
223 <para>
224 The package installer for Python. You can use pip to install
225 packages from Python Package Index and other indexes
226 </para>
227 <indexterm zone="ch-system-Python">
228 <primary sortas="b-pip3">pip3</primary>
229 </indexterm>
230 </listitem>
231 </varlistentry>
232
233 <varlistentry id="pydoc3">
234 <term><command>pydoc3</command></term>
235 <listitem>
236 <para>
237 is the <application>Python</application> documentation tool
238 </para>
239 <indexterm zone="ch-system-Python">
240 <primary sortas="b-pydoc3">pydoc3</primary>
241 </indexterm>
242 </listitem>
243 </varlistentry>
244
245 <varlistentry id="python3">
246 <term><command>python3</command></term>
247 <listitem>
248 <para>
249 is an interpreted, interactive, object-oriented programming
250 language
251 </para>
252 <indexterm zone="ch-system-Python">
253 <primary sortas="b-python3">python3</primary>
254 </indexterm>
255 </listitem>
256 </varlistentry>
257
258 </variablelist>
259
260 </sect2>
261
262</sect1>
263
Note: See TracBrowser for help on using the repository browser.