glfs/general/prog/python3.xml
Douglas R. Reno 78af2ee0fd Some tags
git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@23550 af4574ff-66df-0310-9fd7-8a98e5e911e0
2020-08-17 19:49:57 +00:00

395 lines
13 KiB
XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
<!ENTITY python3-download-http
"https://www.python.org/ftp/python/&python3-version;/Python-&python3-version;.tar.xz">
<!ENTITY python3-download-ftp " ">
<!ENTITY python3-md5sum "35b5a3d0254c1c59be9736373d429db7">
<!ENTITY python3-size "17 MB">
<!ENTITY python3-buildsize "187 MB (add 27 MB for tests)">
<!ENTITY python3-time "0.5 SBU (using parallelism=4; add 2.1 SBU for tests, including rebuilding)">
<!--
Note: Size does not reflect docs that were install in LFS.
<!ENTITY python3htmldoc-download-http
"https://docs.python.org/ftp/python/doc/&python3-version;/python-&python3-version;-docs-html.tar.bz2"> -->
]>
<sect1 id="python3" xreflabel="Python-&python3-version;">
<?dbhtml filename="python3.html" ?>
<sect1info>
<othername>$LastChangedBy$</othername>
<date>$Date$</date>
</sect1info>
<title>Python-&python3-version;</title>
<indexterm zone="python3">
<primary sortas="a-Python3">Python3</primary>
</indexterm>
<sect2 role="package">
<title>Introduction to Python 3</title>
<para>
The <application>Python 3</application> package contains the
<application>Python</application> development environment.
This is useful for object-oriented programming, writing scripts,
prototyping large programs or developing entire applications.
</para>
<note>
<para>
<application>Python 3</application> was installed in LFS.
The only reason to rebuild it here is if optional modules
are needed.
</para>
</note>
&lfs10_checked;
<bridgehead renderas="sect3">Package Information</bridgehead>
<itemizedlist spacing="compact">
<listitem>
<para>
Download (HTTP): <ulink url="&python3-download-http;"/>
</para>
</listitem>
<listitem>
<para>
Download (FTP): <ulink url="&python3-download-ftp;"/>
</para>
</listitem>
<listitem>
<para>
Download MD5 sum: &python3-md5sum;
</para>
</listitem>
<listitem>
<para>
Download size: &python3-size;
</para>
</listitem>
<listitem>
<para>
Estimated disk space required: &python3-buildsize;
</para>
</listitem>
<listitem>
<para>
Estimated build time: &python3-time;
</para>
</listitem>
</itemizedlist>
<bridgehead renderas="sect3">Python 3 Dependencies</bridgehead>
<bridgehead renderas="sect4">Recommended</bridgehead>
<para role="recommended">
<xref linkend="sqlite"/> (required if building firefox)
</para>
<bridgehead renderas="sect4">Optional</bridgehead>
<para role="optional">
<xref linkend="bluez"/>,
<xref linkend="gdb"/> (required for some tests),
<xref linkend="valgrind"/>, and
<ulink url="http://www.bytereef.org/mpdecimal">libmpdec</ulink>
</para>
<bridgehead renderas="sect4">Optional (For Additional Modules)</bridgehead>
<para role="optional">
<xref linkend="db"/> and
<xref linkend="tk"/>
</para>
<para condition="html" role="usernotes">User Notes:
<ulink url="&blfs-wiki;/Python3"/>
</para>
</sect2>
<sect2 role="installation">
<title>Installation of Python 3</title>
<para>
Install <application>Python 3</application> by running the following
commands:
</para>
<screen><userinput>CXX="/usr/bin/g++" \
./configure --prefix=/usr \
--enable-shared \
--with-system-expat \
--with-system-ffi \
--with-ensurepip=yes &amp;&amp;
make</userinput></screen>
<para>
The test suite must be run separately, using an X terminal (see below).
</para>
<para>
Now, as the <systemitem class="username">root</systemitem> user:
</para>
<screen role="root"><userinput>make install &amp;&amp;
<!--ln -sfv pip&python3-majorver; /usr/bin/pip3 &amp;&amp;-->
chmod -v 755 /usr/lib/libpython&python3-majorver;.so &amp;&amp;
chmod -v 755 /usr/lib/libpython3.so</userinput></screen>
<para>
The test suite must be run separately from the build, either before or
after the package is built and installed. Do not run
<command>make install</command> after running the test suite. To build
and install the package, you need to start with a fresh or clean source
tree. For the tests, you also need a clean source code, so either start by
removing the source code directory and starting over, by uncompressing
the source tarball or by running <command>make clean</command>. Then
configure again, adding <quote>--with-pydebug</quote> to the
<command>configure</command> switches above, run <command>make</command>,
then <command>make test</command>. Remember that tests must be executed
using an X terminal.
The test SBU highly depends on the speed of the internet connection.
The test_sqlite test is known to fail.
</para>
</sect2>
<sect2 role="commands">
<title>Command Explanations</title>
<para>
<command> CXX="/usr/bin/g++" ./configure ...</command>: Avoid an annoying
message during configuration.
</para>
<para>
<parameter>--with-system-expat</parameter>: This switch enables linking
against the system version of <application>Expat</application>.
</para>
<para>
<parameter>--with-system-ffi</parameter>: This switch enables linking
against system version of <application>libffi</application>.
</para>
<para>
<parameter>--with-ensurepip=yes</parameter> : This switch enables building
<command>pip</command> and <command>setuptools</command> packaging programs.
<command>setuptools</command> is needed for building some Python modules.
</para>
<para>
<option>--with-dbmliborder=bdb:gdbm:ndbm</option>: Use this switch
if you want to build <application>Python</application> DBM Module
against <application>Berkeley DB</application> instead of
<application>GDBM</application>.
</para>
<para>
<option>--enable-optimization</option>: Use this switch
if you want to enable <emphasis>expensive</emphasis> optimizations (i.e.
Profile Guided Optimizations). This adds around 20 SBU, but can
<emphasis>slightly</emphasis> speed up some uses, such as using
<application>Sphinx</application> for creating documentation, or use of
<application>Python3</application> scripts.
</para>
<para>
<option>--with-lto</option>: This optional switch enables thick Link
Time Optimization. Unusually, it creates a much larger <filename
class="libraryfile">/usr/lib/python&python3-majorver;/config-&python3-majorver;-&lt;arch&gt;-linux-gnu/libpython&python3-majorver;.a</filename>
with a small increase in the time to compile
<application>Python</application>. Run-time results do not appear to show
any benefit from doing this.
</para>
<!--
<para>
<command>ln -sfv ...</command>: When upgrading to Python-3.8, it was
discovered that the symlink to pip3 is sometimes not created. Create
the symlink so that pip3 can be used as described in the book.
</para>
-->
<para>
<command>chmod ...</command>: Fix permissions for shared libraries to be
consistent with other libraries.
</para>
</sect2>
<sect2 role="configuration">
<title>Configuring Python 3</title>
<para>
In order for <command>python3</command> to find the installed
documentation, create the following version independent symlink:
</para>
<screen role="root"><userinput>ln -svfn python-&python3-version; /usr/share/doc/python-3</userinput></screen>
<para>
and add the following environment variable to the individual user's or
system's profile:
</para>
<screen role="root"><userinput>export PYTHONDOCS=/usr/share/doc/python-3/html</userinput></screen>
</sect2>
<sect2 role="content">
<title>Contents</title>
<segmentedlist>
<segtitle>Installed Programs</segtitle>
<segtitle>Installed Libraries</segtitle>
<segtitle>Installed Directories</segtitle>
<seglistitem>
<seg>
2to3 (symlink) and
2to3-&python3-majorver;,
easy_install (symlink) and
easy_install-&python3-majorver;,
idle3 (symlink) and
idle&python3-majorver;,
pip3 (symlink) and
pip&python3-majorver;,
pydoc3 (symlink) and
pydoc&python3-majorver;,
python3 (symlink);
python&python3-majorver;, and
python3-config (symlink) and
python&python3-majorver;-config
<!--
pyvenv (symlink),
pyvenv-&python3-majorver;
-->
</seg>
<seg>
libpython&python3-majorver;.so and libpython3.so
</seg>
<seg>
/usr/include/python&python3-majorver;,
/usr/lib/python&python3-majorver;, and
/usr/share/doc/python-&python3-version;
</seg>
</seglistitem>
</segmentedlist>
<variablelist>
<bridgehead renderas="sect3">Short Descriptions</bridgehead>
<?dbfo list-presentation="list"?>
<?dbhtml list-presentation="table"?>
<!--
<varlistentry id="2to3">
<term><command>2to3</command></term>
<listitem>
<para>
is designed to assist in the transition between python2 and python3
by automatically converting code to be Python3 compatible.
</para>
<indexterm zone="python3 2to3">
<primary sortas="b-2to3">2to3</primary>
</indexterm>
</listitem>
</varlistentry>
Put here for easy use when removing Python2 -->
<varlistentry id="easy_install">
<term><command>easy_install</command></term>
<listitem>
<para>
is a frontend to pip3 to make it easier to configure python modules
through the PIP package manager.
</para>
<indexterm zone="python3 easy_install">
<primary sortas="python3 easy_install">easy_install</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="idle3">
<term><command>idle3</command></term>
<listitem>
<para>
is a wrapper script that opens a <application>Python</application>
aware GUI editor. For this script to run, you must have installed
<application>Tk</application> before Python so that the Tkinter
Python module is built.
</para>
<indexterm zone="python3 idle3">
<primary sortas="b-idle3">idle3</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="pydoc3">
<term><command>pydoc3</command></term>
<listitem>
<para>
is the <application>Python</application> documentation
tool.
</para>
<indexterm zone="python3 pydoc3">
<primary sortas="b-pydoc3">pydo3c</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="python3-prog">
<term><command>python3</command></term>
<listitem>
<para>
is an interpreted, interactive, object-oriented programming
language.
</para>
<indexterm zone="python3 python3-prog">
<primary sortas="b-python3">python3</primary>
</indexterm>
</listitem>
</varlistentry>
<varlistentry id="python-ver">
<term><command>python&python3-majorver;</command></term>
<listitem>
<para>
is a version-specific name for the <command>python</command>
program.
</para>
<indexterm zone="python3 python-ver">
<primary
sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
</indexterm>
</listitem>
</varlistentry>
<!--
<varlistentry id="pyvenv">
<term><command>pyvenv</command></term>
<listitem>
<para>
creates virtual <application>Python</application> environments in
one or more target directories.
</para>
<indexterm zone="python3 pyvenv">
<primary
sortas="b-python&python3-majorver;">python&python3-majorver;</primary>
</indexterm>
</listitem>
</varlistentry>
-->
</variablelist>
</sect2>
</sect1>