Python-3.12.1

Python 3 の概要

Python 3 パッケージは Python 開発環境を提供します。 この環境は、オブジェクト指向プログラミング、スクリプト構築、大規模なプロトタイプ開発、一連のアプリケーション開発を可能とします。

[注記]

注記

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

[注記]

注記

LFS や依存パッケージが本ブックに示す最新安定バージョンでなかった場合には、BLFS 開発版においては、パッケージのビルドや処理実行が適切に行われないことがあります。

[重要]

重要

If upgrading to a new Python-3 minor version (for example, from Python-3.11.x to Python-3.12.0), you will need to reinstall any Python3 modules you have installed. You should also reinstall packages that generate Python3 modules including gobject-introspection-1.78.1, libxml2-2.12.3, opencv-4.8.1, Graphviz-9.0.0 (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.9.11. 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, wheel, setuptools, meson, MarkupSafe, and Jinja2.

パッケージ情報

  • ダウンロード (HTTP): https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tar.xz

  • ダウンロード MD5 sum: 50f827c800483776c8ef86e6a53831fa

  • ダウンロードサイズ: 20 MB

  • 必要ディスク容量: 337 MB (add 56 MB for tests)

  • 概算ビルド時間: 2.4 SBU (add 6.0 SBU for tests; both using parallelism=4)

Additional Optional Download

Python 3 の依存パッケージ

推奨

任意

BlueZ-5.71, GDB-14.1 (required for some tests), Valgrind-3.22.0, and libmpdec

任意 (追加モジュール用)

libnsl-2.0.1, Tk-8.6.13, and Berkeley DB (非推奨)

編集ノート: https://wiki.linuxfromscratch.org/blfs/wiki/Python3

Python 3 のインストール

以下のコマンドを実行して Python 3 をビルドします。

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

To test the result, issue LC_ALL=en_US.UTF-8 make test. Some tests may need an Internet connection.

root ユーザーになって以下を実行します。

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.12.1/html

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

コマンド説明

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-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.12/config-3.12-<arch>-linux-gnu/libpython3.12.a with a small increase in the time to compile Python. Run-time results do not appear to show any benefit from doing this.

Python 3 の設定

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

ln -svfn python-3.12.1 /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

パッケージ構成

インストールプログラム: 2to3 (symlink) and 2to3-3.12, idle3 (symlink) and idle3.12, pip3 and pip3.12, pydoc3 (symlink) and pydoc3.12, python3 (symlink) and python3.12, and python3-config (symlink), python3.12-config
インストールライブラリ: libpython3.12.so, libpython3.so
インストールディレクトリ: /usr/include/python3.12, /usr/lib/python3.12, /usr/share/doc/python-3.12.1

概略説明

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

is a version-specific name for the python program