
Fix "error: invalid command 'bdist_wheel'" when building on aarch64. For aarch64 platform, it seems it always tries to build wheels first for python packages which have no wheels in PyPi. Although it will install the source packages successfully at last. Task: #41701 Story: #2008562 Change-Id: Id3dc4eaad9b698241ad70a69f93b8463bc15de0d
98 lines
3.2 KiB
Bash
Executable File
98 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
SCRIPTDIR=$(dirname $0)
|
|
IPADIR=/tmp/ironic-python-agent
|
|
IRLIBDIR=/tmp/ironic-lib
|
|
UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt
|
|
VENVDIR=/opt/ironic-python-agent
|
|
# 19.1.1 is required for cryptography.
|
|
REQUIRED_PIP_STR="19.1.1"
|
|
REQUIRED_PIP_TUPLE="(19, 1, 1)"
|
|
|
|
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 [ $IPA_PYTHON_VERSION == 3 ]; then
|
|
$IPA_PYTHON -m venv $VENVDIR
|
|
else
|
|
$IPA_PYTHON -m virtualenv $VENVDIR
|
|
fi
|
|
|
|
HAS_PIP=$($VENVDIR/bin/python -c \
|
|
"import pip; print(tuple(map(int, pip.__version__.split('.'))) >= $REQUIRED_PIP_TUPLE)")
|
|
if [ $HAS_PIP == "False" ]; then
|
|
# NOTE(dtantsur): use a fixed version to avoid breakages
|
|
$VENVDIR/bin/pip install "pip==$REQUIRED_PIP_STR"
|
|
fi
|
|
|
|
# Upgrade setuptools package for openSuse and in virtualenvs using Python 2.x
|
|
# NOTE(rpittau): if we want to keep compatibility with Python 2.x, we need to
|
|
# upgrade setuptools in the virtualenv as the default installed has issues
|
|
# when parsing requirements.
|
|
if [ "$DISTRO_NAME" == "opensuse" ] || [ $IPA_PYTHON_VERSION == 2 ]; then
|
|
$VENVDIR/bin/pip install -U setuptools
|
|
fi
|
|
|
|
# For aarch64 platform, it seems it always tries to build wheels first for
|
|
# python packages which have no wheels in PyPi. Although it will install the
|
|
# source packages successfully at last.
|
|
if [[ "$ARCH" =~ (arm64|aarch64) ]]; then
|
|
$VENVDIR/bin/pip install wheel
|
|
fi
|
|
|
|
# install IPA inside the virtual environment
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS $IPADIR
|
|
ln -s $VENVDIR/bin/ironic-python-agent /usr/local/bin/
|
|
ln -s $VENVDIR/bin/ironic-collect-introspection-data /usr/local/bin/
|
|
|
|
# install ironic-lib from source if requested
|
|
if [ ${IRONIC_LIB_FROM_SOURCE:-false} == "true" ]; then
|
|
$VENVDIR/bin/pip install -c $UPPER_CONSTRAINTS -r $IRLIBDIR/requirements.txt
|
|
$VENVDIR/bin/pip install $IRLIBDIR
|
|
fi
|
|
|
|
case "$DIB_INIT_SYSTEM" in
|
|
upstart)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.conf /etc/init/ironic-python-agent.conf
|
|
;;
|
|
systemd)
|
|
install -D -g root -o root -m 0644 ${SCRIPTDIR}/ironic-python-agent.service /usr/lib/systemd/system/ironic-python-agent.service
|
|
;;
|
|
sysv)
|
|
install -D -g root -o root -m 0755 ${SCRIPTDIR}/ironic-python-agent.init /etc/init.d/ironic-python-agent.init
|
|
update-rc.d ironic-python-agent.init defaults
|
|
;;
|
|
*)
|
|
echo "Unsupported init system"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
# Copying the self signed certificate for request library
|
|
if [ -f /tmp/in_target.d/ipa-trusted-cert.pem ]; then
|
|
cat /tmp/in_target.d/ipa-trusted-cert.pem >> $($VENVDIR/bin/python -c "import requests; print(requests.certs.where())")
|
|
fi
|