From a28b8fa5bc49bf8452c5e8f8fdf39f5f09e46ff2 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Fri, 31 Jul 2020 17:13:20 +0200 Subject: [PATCH] Support installing with Python 3 on CentOS 7 RHEL/CentOS 8 dropped support for some older hardware that is still in use. Since CentOS 7 has Python 3, let's support it for now. Also fixes an issue with C.UTF-8 locale which does not seem to work on CentOS 7 (and actually causes a failure with newer python packages). Change-Id: I1b5797b030ef896ad4b2a95a504a0215ca6ee574 --- .zuul.yaml | 11 +++++++++ .../60-ironic-python-agent-ramdisk-install | 23 ++++++++++++++++--- .../centos7-python3-185f1d35c37096c7.yaml | 5 ++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/centos7-python3-185f1d35c37096c7.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 22ecb79..5bf1f9e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -79,6 +79,15 @@ image_type: 'dib' image_distro: 'centos7' +- job: + name: ironic-python-agent-check-image-dib-centos7-python3 + parent: ironic-python-agent-check-image-base + required-projects: + - openstack/diskimage-builder + vars: + image_type: 'dib' + image_distro: 'centos7' + - job: name: ironic-python-agent-check-image-dib-centos8 parent: ironic-python-agent-check-image-base @@ -133,6 +142,8 @@ - ironic-python-agent-check-image-dib-centos8 - ironic-python-agent-check-image-dib-centos7 # Non-voting jobs + - ironic-python-agent-check-image-dib-centos7-python3: + voting: false - ironic-python-agent-check-image-dib-fedora: voting: false - ironic-python-agent-check-image-dib-debian: diff --git a/dib/ironic-python-agent-ramdisk/install.d/ironic-python-agent-ramdisk-source-install/60-ironic-python-agent-ramdisk-install b/dib/ironic-python-agent-ramdisk/install.d/ironic-python-agent-ramdisk-source-install/60-ironic-python-agent-ramdisk-install index 1b5cddb..a01c50f 100755 --- a/dib/ironic-python-agent-ramdisk/install.d/ironic-python-agent-ramdisk-source-install/60-ironic-python-agent-ramdisk-install +++ b/dib/ironic-python-agent-ramdisk/install.d/ironic-python-agent-ramdisk-source-install/60-ironic-python-agent-ramdisk-install @@ -13,11 +13,28 @@ IPADIR=/tmp/ironic-python-agent UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt VENVDIR=/opt/ironic-python-agent +IPA_PYTHON_VERSION=$DIB_PYTHON_VERSION +IPA_PYTHON="$DIB_PYTHON" + +case "$DISTRO_NAME" in + centos7|rhel7) + # NOTE(dtantsur): C.UTF-8 doesn't seem to exist in CentOS 7 + export LC_ALL=en_US.UTF-8 + + if grep -q 'Python :: 3 :: Only' $IPADIR/setup.cfg; then + echo "WARNING: using Python 3 on CentOS 7, this is not recommended" + ${YUM:-yum} install -y python3 python3-devel + IPA_PYTHON=python3 + IPA_PYTHON_VERSION=3 + fi + ;; +esac + # create the virtual environment using the default python -if [ $DIB_PYTHON_VERSION == 3 ]; then - $DIB_PYTHON -m venv $VENVDIR +if [ $IPA_PYTHON_VERSION == 3 ]; then + $IPA_PYTHON -m venv $VENVDIR else - $DIB_PYTHON -m virtualenv $VENVDIR + $IPA_PYTHON -m virtualenv $VENVDIR fi # pip might be an older version which does not support the -c option, therefore diff --git a/releasenotes/notes/centos7-python3-185f1d35c37096c7.yaml b/releasenotes/notes/centos7-python3-185f1d35c37096c7.yaml new file mode 100644 index 0000000..7528ce5 --- /dev/null +++ b/releasenotes/notes/centos7-python3-185f1d35c37096c7.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Supports building images for Ussuri+ on CentOS 7 using Python 3. This is + not recommended but is necessary for some older hardware.