Python-2.7.18

Python 2 の概要

The Python 2 package contains the Python development environment. It is useful for object-oriented programming, writing scripts, prototyping large programs or developing entire applications. This version is for backward compatibility with other dependent packages.

[注記]

注記

Python2 has been deprecated by the upstream developers. Support for Python2 was discontinued on January 1st, 2020.

BLFS is attempting to use Python3 as much as possible, but some packages have not been updated to support Python3.

[注記]

注記

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

パッケージ情報

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

  • ダウンロード MD5 sum: fd6cc8ec0a78c44036f825e739f36e5a

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

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

  • 概算ビルド時間: 0.5 SBU (Using parallelism=4; add 5.9 SBU for tests)

追加のダウンロード

Python 2 の依存パッケージ

推奨

任意

BlueZ-5.71, Valgrind-3.22.0

Optional (For more additional modules)

libnsl-2.0.1 and Tk-8.6.13

Python 2 のインストール

First, disable the installation of a script that overwrites a more recent script:

sed -i '/2to3/d' ./setup.py

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

patch -Np1 -i ../Python-2.7.18-security_fixes-1.patch &&
./configure --prefix=/usr                              \
            --enable-shared                            \
            --with-system-expat                        \
            --with-system-ffi                          \
            --enable-unicode=ucs4                     &&
make

テストを実行するには、二度の実行が必要です。 ビルド結果をテストする場合は make -k test を実行します。 Several tests are known to fail, including test_ftplib, test_ssl, test_urllib2_localnet, test_xml_etree, test_xml_etree_c, and test_minidom. These failures are due to OpenSSL-3 and Expat-2.4.6.

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

make altinstall                                &&
ln -s python2.7        /usr/bin/python2        &&
ln -s python2.7-config /usr/bin/python2-config &&
chmod -v 755 /usr/lib/libpython2.7.so.1.0

Since Python 2 is in maintenance mode, and Python 3 is recommended by upstream for development, you probably do not need to install the documentation. However, if you still want to install documentation for both Python versions, be sure to define the PYTHONDOCS variable for the version you want to use, each time you need to consult the documentation. If you have downloaded the preformatted documentation from https://docs.python.org/download.html, install it as the root user:

install -v -dm755 /usr/share/doc/python-2.7.18 &&

tar --strip-components=1                     \
    --no-same-owner                          \
    --directory /usr/share/doc/python-2.7.18 \
    -xvf ../python-2.7.18-docs-html.tar.bz2 &&

find /usr/share/doc/python-2.7.18 -type d -exec chmod 0755 {} \; &&
find /usr/share/doc/python-2.7.18 -type f -exec chmod 0644 {} \;

コマンド説明

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

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

--enable-unicode=ucs4: This switch enables 32-bit Unicode support in Python.

--with-ensurepip=yes : This switch enables building pip and setuptools packaging programs. setuptools is needed for building some Python modules. This switch is not recommended because this version of Python is no longer maintained.

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

make altinstall: This make target omits some default symbolic links that may interfere with Python 3.

chmod ...: Fix permissions for libraries to be consistent with other libraries.

Python 2 の設定

In order for python to find the installed documentation, you must add the following environment variable to individual user's or the system's profile:

export PYTHONDOCS=/usr/share/doc/python-2.7.18

パッケージ構成

Installed Programs: pydoc, python2 (symlink), python2-config (symlink), python2.7, python2.7-config, smtpd.py, idle
Installed Libraries: libpython2.7.so
Installed Directories: /usr/{include,lib}/python2.7, /usr/share/doc/python-2.7.18

概略説明

idle

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

pydoc

Python ドキュメントツール。

python2

is an interpreted, interactive, object-oriented programming language

python2.7

is a version-specific name for the python program

smtpd.py

is an SMTP proxy implemented in Python