#### Beyond Linux® From Scratch (systemd Edition) - Version r13.0-491

### Chapter 13. Programming

- Prev

  PHP-8.5.5

- Next

  Python-3.11.1

- Up
- Home

# Python-3.14.4

## Introduction to Python 3

The Python 3 package contains the Python development environment. This is useful for object-oriented programming, writing scripts, prototyping large programs or developing entire applications.

### Note

Python 3 was installed in LFS. The only reason to rebuild it here is if optional modules are needed, or to upgrade this package.

### Note

Development versions of BLFS may not build or run some packages properly if LFS or dependencies have been updated since the most recent stable versions of the books.

### Important

If upgrading to a new Python-3 minor version (for example, from Python-3.13.x to Python-3.14.0), you will need to reinstall any Python modules you have installed. You should also reinstall packages that generate Python modules, including GLib-2.88.0 (with GObject Introspection), opencv-4.13.0, FontForge-20251009, gnome-tweaks-49.0, Samba-4.24.0, and Graphviz-14.1.5 (if swig is installed).

Before you upgrade, you can get a list of modules installed with pip3 list. The list may be incomplete as some Python modules are not installed with pip3, for example the `cracklib` module installed by CrackLib-2.10.3. Use ls /usr/lib/python3.`minor`/site-packages for a comprehensive list.

The Python modules from LFS will also have to be reinstalled: flit-core, packaging, wheel, setuptools, meson, MarkupSafe, and Jinja2.

### Package Information

- Download (HTTP): https://www.python.org/ftp/python/3.14.4/Python-3.14.4.tar.xz

- Download MD5 sum: 279d92a745927c3aa5fdf68ec0bfd638

- Download size: 23 MB

- Estimated disk space required: 335 MB (add 65 MB for tests)

- Estimated build time: 2.2 SBU (add 1.0 SBU for tests; both using parallelism=4)

### Required Additional Download

- Required patch: https://www.linuxfromscratch.org/patches/blfs/svn/Python-3.14.4-security_fixes-2.patch

### Additional Optional Download

- Download (HTTP): https://www.python.org/ftp/python/doc/3.14.4/python-3.14.4-docs-html.tar.bz2

- Download MD5 sum: 3f98bcb588db43de46d0bc2f7fd64789

### Python 3 Dependencies

#### Optional

BlueZ-5.86, GDB-17.1 (required for some tests), Valgrind-3.26.0, and libmpdec

#### Optional (For Additional Modules)

libnsl-2.0.1, Tk-8.6.17, and Berkeley DB (deprecated)

### Note

An Internet connection is needed for some tests of this package. The system certificate store may need to be set up with make-ca-1.16.1 before testing this package.

Editor Notes: https://wiki.linuxfromscratch.org/blfs/wiki/Python3

## Installation of Python 3

First, apply a patch consisting of security fixes from upstream:

    patch -Np1 -i ../Python-3.14.4-security_fixes-2.patch

Install Python 3 by running the following commands:

    ./configure --prefix=/usr              \
                --enable-shared            \
                --with-system-expat        \
                --enable-optimizations     \
                --without-static-libpython &&
    make

Some tests are known to occasionally hang indefinitely. So to test the results, run the test suite but set a 2-minute time limit for each test case:

    make test TESTOPTS="--timeout 120"

For a relatively slow system you may need to increase the time limit and 1 SBU (measured when building Binutils pass 1 with one CPU core) should be enough. Some tests are flaky, so the test suite will automatically re-run failed tests. If a test failed but then passed when re-run, it should be considered as passed.

Now, as the `root` user:

    make install

If upgrading and the documentation has been downloaded, optionally install it as the `root` user:

    install -v -dm755 /usr/share/doc/python-3.14.4/html

    tar --strip-components=1  \
        --no-same-owner       \
        --no-same-permissions \
        -C /usr/share/doc/python-3.14.4/html \
        -xvf ../python-3.14.4-docs-html.tar.bz2

## Command Explanations

CXX="/usr/bin/g++" ./configure ...: Avoid an annoying message during configuration.

`--with-system-expat`: This switch enables linking against the system version of Expat.

`--enable-optimizations`: This switch enables stable, but expensive, optimizations.

`--with-lto`: This optional switch enables thick Link Time Optimization. Unusually, it creates a much larger `/usr/lib/python3.14/config-3.14-<arch>-linux-gnu/libpython3.14.a` with a small increase in the time to compile Python. Run-time results do not appear to show any benefit from doing this.

## Configuring Python 3

In order for python3 to find the installed documentation, create the following version independent symlink:

    ln -svfn python-3.14.4 /usr/share/doc/python-3

and add the following environment variable to the individual user's or system's profile:

    export PYTHONDOCS=/usr/share/doc/python-3/html

## Contents

Installed Programs: idle3 (symlink) and idle3.14, pip3 and pip3.14, pydoc3 (symlink) and pydoc3.14, python3 (symlink) and python3.14, and python3-config (symlink) and python3.14-config
Installed Libraries: libpython3.14.so and libpython3.so
Installed Directories: /usr/include/python3.14, /usr/lib/python3.14, and /usr/share/doc/python-3.14.4

### Short Descriptions

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
pydoc3 | is the Python documentation tool
python3 | is an interpreted, interactive, object-oriented programming language
python3.14 | is a version-specific name for the python program

- Prev

  PHP-8.5.5

- Next

  Python-3.11.1

- Up
- Home