#### Beyond Linux® From Scratch (systemd Edition) - Version 11.1

### Chapter 13. Programming

- Prev

  Python-2.7.18

- Next

  Python Modules

- Up
- Home

# Python-3.10.2

## 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.

This package is known to build and work properly using an LFS-11.1 platform.

### Package Information

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

- Download MD5 sum: 14e8c22458ed7779a1957b26cde01db9

- Download size: 18 MB

- Estimated disk space required: 201 MB (add 35 MB for tests)

- Estimated build time: 2.4 SBU (using parallelism=4; add 2.6 SBU for tests)

### Python 3 Dependencies

#### Recommended

SQLite-3.37.2 (required if building firefox or thunderbird)

#### Optional

BlueZ-5.63, GDB-11.2 (required for some tests), Valgrind-3.18.1, and libmpdec

#### Optional (For Additional Modules)

Berkeley DB-5.3.28, libnsl-2.0.0, and Tk-8.6.12

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

## Installation of Python 3

Install Python 3 by running the following commands:

    CXX="/usr/bin/g++"               \
    ./configure --prefix=/usr        \
                --enable-shared      \
                --with-system-expat  \
                --with-system-ffi    \
                --with-ensurepip=yes \
                --enable-optimizations &&
    make

To test the result, issue make test. Some tests may need an Internet connection. Two tests named `test_xml_etree` and `test_minidom` are known to fail.

Now, as the `root` user:

    make install

## 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.

`--with-system-ffi`: This switch enables linking against the system version of libffi.

`--with-ensurepip=yes` : This switch enables building the pip and setuptools packaging programs. setuptools is needed for building some Python modules.

`--with-dbmliborder=bdb:gdbm:ndbm`: Use this switch if you want to build the Python DBM Module against Berkeley DB instead of GDBM.

`--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.10/config-3.10-<arch>-linux-gnu/libpython3.10.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.10.2 /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: 2to3 (symlink) and 2to3-3.10, idle3 (symlink) and idle3.10, pip3 (symlink) and pip3.10, pydoc3 and pydoc3.10, python3 (symlink); python3.10, and python3-config (symlink) and python3.10-config
Installed Libraries: libpython3.10.so and libpython3.so
Installed Directories: /usr/include/python3.10, /usr/lib/python3.10, and /usr/share/doc/python-3.10.2

### 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.10 | is a version-specific name for the python program

Last updated on

- Prev

  Python-2.7.18

- Next

  Python Modules

- Up
- Home