%general-entities; ]> Python &python-version;
&python-url;
Python-&python-version; Python <para>The Python 3 package contains the Python development environment. It is useful for object-oriented programming, writing scripts, prototyping large programs, and developing entire applications. Python is an interpreted computer language.</para> <segmentedlist> <segtitle>&buildtime;</segtitle> <segtitle>&diskspace;</segtitle> <seglistitem> <seg>&python-fin-sbu;</seg> <seg>&python-fin-du;</seg> </seglistitem> </segmentedlist> </sect2> <sect2 role="installation"> <title>Installation of Python 3 Prepare Python for compilation: ./configure --prefix=/usr \ --enable-shared \ --with-system-expat \ --with-system-ffi \ --enable-optimizations The meaning of the configure options: --with-system-expat This switch enables linking against the system version of Expat. --with-system-ffi This switch enables linking against the system version of libffi.so. --enable-optimizations This switch enables extensive, but time-consuming, optimization steps. The interpreter is built twice; tests performed on the first build are used to improve the optimized final version. Compile the package: make Running the tests at this point is not recommended. The tests are known to hang indefinitely in the partial LFS environment. If desired, the tests can be rerun at the end of this chapter, or when Python 3 is reinstalled in BLFS. To run the tests anyway, issue make test. Install the package: make install We use the pip3 command to install Python 3 programs and modules for all users as root in several places in this book. This conflicts with the Python developers' recommendation: to install packages into a virtual environment, or into the home directory of a regular user (by running pip3 as this user). A multi-line warning is triggered whenever pip3 is issued by the root user. The main reason for the recommendation is to avoid conflicts with the system's package manager (dpkg, for example). LFS does not have a system-wide package manager, so this is not a problem. Also, pip3 will check for a new version of itself whenever it's run. Since domain name resolution is not yet configured in the LFS chroot environment, pip3 cannot check for a new version of itself, and will produce a warning. After we boot the LFS system and set up a network connection, a different warning will be issued, telling the user to update pip3 from a pre-built wheel on PyPI (whenever a new version is available). But LFS considers pip3 to be a part of Python 3, so it should not be updated separately. Also, an update from a pre-built wheel would deviate from our objective: to build a Linux system from source code. So the warning about a new version of pip3 should be ignored as well. If you wish, you can suppress all these warnings by running the following command, which creates a configuration file: cat > /etc/pip.conf << EOF [global] root-user-action = ignore disable-pip-version-check = true EOF In LFS and BLFS we normally build and install Python modules with the pip3 command. Please be sure that the pip3 install commands in both books are run as the &root; user (unless it's for a Python virtual environment). Running pip3 install as a non-&root; user may seem to work, but it will cause the installed module to be inaccessible by other users. pip3 install will not reinstall an already installed module automatically. When using the pip3 install command to upgrade a module (for example, from meson-0.61.3 to meson-0.62.0), insert the option --upgrade into the command line. If it's really necessary to downgrade a module, or reinstall the same version for some reason, insert --force-reinstall --no-deps into the command line. If desired, install the preformatted documentation: install -v -dm755 /usr/share/doc/python-&python-version;/html tar --strip-components=1 \ --no-same-owner \ --no-same-permissions \ -C /usr/share/doc/python-&python-version;/html \ -xvf ../python-&python-version;-docs-html.tar.bz2 The meaning of the documentation install commands: and Ensure the installed files have the correct ownership and permissions. Without these options, tar will install the package files with the upstream creator's values. Contents of Python 3 Installed Programs Installed Library Installed Directories 2to3, idle3, pip3, pydoc3, python3, and python3-config libpython&python-minor;.so and libpython3.so /usr/include/python&python-minor;, /usr/lib/python3, and /usr/share/doc/python-&python-version; Short Descriptions 2to3 is a Python program that reads Python 2.x source code and applies a series of fixes to transform it into valid Python 3.x code 2to3 idle3 is a wrapper script that opens a Python aware GUI editor. For this script to run, you must have installed Tk before Python, so that the Tkinter Python module is built. idle3 pip3 The package installer for Python. You can use pip to install packages from Python Package Index and other indexes. pip3 pydoc3 is the Python documentation tool pydoc3 python3 is the interpreter for Python, an interpreted, interactive, object-oriented programming language python3