diff --git a/imagebuild/tinyipa/build-tinyipa.sh b/imagebuild/tinyipa/build-tinyipa.sh index 119e73c5e..9eb77aa5e 100755 --- a/imagebuild/tinyipa/build-tinyipa.sh +++ b/imagebuild/tinyipa/build-tinyipa.sh @@ -9,6 +9,7 @@ TINYCORE_MIRROR_URL=${TINYCORE_MIRROR_URL:-} TINYIPA_REQUIRE_BIOSDEVNAME=${TINYIPA_REQUIRE_BIOSDEVNAME:-false} TINYIPA_REQUIRE_IPMITOOL=${TINYIPA_REQUIRE_IPMITOOL:-true} IRONIC_LIB_SOURCE=${IRONIC_LIB_SOURCE:-} +USE_PYTHON3=${USE_PYTHON3:-False} CHROOT_PATH="/tmp/overides:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin" CHROOT_CMD="sudo chroot $BUILDDIR /usr/bin/env -i PATH=$CHROOT_PATH http_proxy=$http_proxy https_proxy=$https_proxy no_proxy=$no_proxy" @@ -74,7 +75,9 @@ mkdir -p "$BUILDDIR/tmp/localpip" # Download IPA and requirements cd ../.. rm -rf *.egg-info +pwd python setup.py sdist --dist-dir "$BUILDDIR/tmp/localpip" --quiet +ls $BUILDDIR/tmp/localpip || true cp requirements.txt $BUILDDIR/tmp/ipa-requirements.txt if [ -n "$IRONIC_LIB_SOURCE" ]; then @@ -127,20 +130,32 @@ $CHROOT_CMD chmod a+rwx /etc/sysconfig/tcuser mkdir $BUILDDIR/tmp/overides cp $WORKDIR/build_files/fakeuname $BUILDDIR/tmp/overides/uname +PY_REQS="buildreqs_python2.lst" +if [[ $USE_PYTHON3 == "True" ]]; then + PY_REQS="buildreqs_python3.lst" +fi + while read line; do sudo chroot --userspec=$TC:$STAFF $BUILDDIR /usr/bin/env -i PATH=$CHROOT_PATH http_proxy=$http_proxy https_proxy=$https_proxy no_proxy=$no_proxy tce-load -wci $line -done < $WORKDIR/build_files/buildreqs.lst +done < <(paste $WORKDIR/build_files/$PY_REQS $WORKDIR/build_files/buildreqs.lst) + +PIP_COMMAND="pip" +TINYIPA_PYTHON_EXE="python" +if [[ $USE_PYTHON3 == "True" ]]; then + PIP_COMMAND="pip3" + TINYIPA_PYTHON_EXE="python3" +fi # Build python wheels -$CHROOT_CMD python -m ensurepip -$CHROOT_CMD pip install --upgrade pip wheel -$CHROOT_CMD pip install pbr -$CHROOT_CMD pip wheel -c /tmp/upper-constraints.txt --wheel-dir /tmp/wheels -r /tmp/ipa-requirements.txt +$CHROOT_CMD ${TINYIPA_PYTHON_EXE} -m ensurepip +$CHROOT_CMD ${PIP_COMMAND} install --upgrade pip wheel +$CHROOT_CMD ${PIP_COMMAND} install pbr +$CHROOT_CMD ${PIP_COMMAND} wheel -c /tmp/upper-constraints.txt --wheel-dir /tmp/wheels -r /tmp/ipa-requirements.txt if [ -n "$IRONIC_LIB_SOURCE" ]; then - $CHROOT_CMD pip wheel -c /tmp/upper-constraints.txt --wheel-dir /tmp/wheels -r /tmp/ironic-lib-requirements.txt - $CHROOT_CMD pip wheel -c /tmp/upper-constraints.txt --no-index --pre --wheel-dir /tmp/wheels --find-links=/tmp/localpip --find-links=/tmp/wheels ironic-lib + $CHROOT_CMD ${PIP_COMMAND} wheel -c /tmp/upper-constraints.txt --wheel-dir /tmp/wheels -r /tmp/ironic-lib-requirements.txt + $CHROOT_CMD ${PIP_COMMAND} wheel -c /tmp/upper-constraints.txt --no-index --pre --wheel-dir /tmp/wheels --find-links=/tmp/localpip --find-links=/tmp/wheels ironic-lib fi -$CHROOT_CMD pip wheel -c /tmp/upper-constraints.txt --no-index --pre --wheel-dir /tmp/wheels --find-links=/tmp/localpip --find-links=/tmp/wheels ironic-python-agent +$CHROOT_CMD ${PIP_COMMAND} wheel -c /tmp/upper-constraints.txt --no-index --pre --wheel-dir /tmp/wheels --find-links=/tmp/localpip --find-links=/tmp/wheels ironic-python-agent echo Resulting wheels: ls -1 $BUILDDIR/tmp/wheels diff --git a/imagebuild/tinyipa/build_files/bootlocal.sh b/imagebuild/tinyipa/build_files/bootlocal.sh index c5cd29ea8..0fcf0b4f7 100755 --- a/imagebuild/tinyipa/build_files/bootlocal.sh +++ b/imagebuild/tinyipa/build_files/bootlocal.sh @@ -20,7 +20,11 @@ fi # Install IPA and dependecies if ! type "ironic-python-agent" > /dev/null ; then - pip install --no-index --find-links=file:///tmp/wheelhouse ironic_python_agent + PIP_COMMAND="pip" + if hash pip3 2>/dev/null; then + PIP_COMMAND="pip3" + fi + $PIP_COMMAND install --no-index --find-links=file:///tmp/wheelhouse ironic_python_agent fi # Create ipa-rescue-config directory for rescue password diff --git a/imagebuild/tinyipa/build_files/buildreqs.lst b/imagebuild/tinyipa/build_files/buildreqs.lst index c255a1072..6fd9293c5 100644 --- a/imagebuild/tinyipa/build_files/buildreqs.lst +++ b/imagebuild/tinyipa/build_files/buildreqs.lst @@ -18,8 +18,6 @@ parted.tcz pciutils.tcz pixman-dev.tcz pkg-config.tcz -python-dev.tcz -python.tcz raid-dm-4.8.17-tinycore64.tcz scsi-4.8.17-tinycore64.tcz udev-lib.tcz diff --git a/imagebuild/tinyipa/build_files/buildreqs_python2.lst b/imagebuild/tinyipa/build_files/buildreqs_python2.lst new file mode 100644 index 000000000..cc7549241 --- /dev/null +++ b/imagebuild/tinyipa/build_files/buildreqs_python2.lst @@ -0,0 +1,2 @@ +python.tcz +python-dev.tcz \ No newline at end of file diff --git a/imagebuild/tinyipa/build_files/buildreqs_python3.lst b/imagebuild/tinyipa/build_files/buildreqs_python3.lst new file mode 100644 index 000000000..1b6b0c007 --- /dev/null +++ b/imagebuild/tinyipa/build_files/buildreqs_python3.lst @@ -0,0 +1,2 @@ +python3.6.tcz +python3.6-dev.tcz \ No newline at end of file diff --git a/imagebuild/tinyipa/build_files/finalreqs.lst b/imagebuild/tinyipa/build_files/finalreqs.lst index b1ad59aa3..fa210ab72 100644 --- a/imagebuild/tinyipa/build_files/finalreqs.lst +++ b/imagebuild/tinyipa/build_files/finalreqs.lst @@ -6,7 +6,6 @@ hdparm.tcz iproute2.tcz parted.tcz popt.tcz -python.tcz pciutils.tcz raid-dm-4.8.17-tinycore64.tcz scsi-4.8.17-tinycore64.tcz diff --git a/imagebuild/tinyipa/build_files/finalreqs_python2.lst b/imagebuild/tinyipa/build_files/finalreqs_python2.lst new file mode 100644 index 000000000..c29888454 --- /dev/null +++ b/imagebuild/tinyipa/build_files/finalreqs_python2.lst @@ -0,0 +1 @@ +python.tcz \ No newline at end of file diff --git a/imagebuild/tinyipa/build_files/finalreqs_python3.lst b/imagebuild/tinyipa/build_files/finalreqs_python3.lst new file mode 100644 index 000000000..a2a4bdc87 --- /dev/null +++ b/imagebuild/tinyipa/build_files/finalreqs_python3.lst @@ -0,0 +1,2 @@ +python3.6.tcz +expat2.tcz \ No newline at end of file diff --git a/imagebuild/tinyipa/finalise-tinyipa.sh b/imagebuild/tinyipa/finalise-tinyipa.sh index 260b0d046..fd859a3f7 100755 --- a/imagebuild/tinyipa/finalise-tinyipa.sh +++ b/imagebuild/tinyipa/finalise-tinyipa.sh @@ -24,6 +24,8 @@ PYOPTIMIZE_TINYIPA=${PYOPTIMIZE_TINYIPA:-true} TINYIPA_REQUIRE_BIOSDEVNAME=${TINYIPA_REQUIRE_BIOSDEVNAME:-false} TINYIPA_REQUIRE_IPMITOOL=${TINYIPA_REQUIRE_IPMITOOL:-true} TINYIPA_UDEV_SETTLE_TIMEOUT=${TINYIPA_UDEV_SETTLE_TIMEOUT:-20} +USE_PYTHON3=${USE_PYTHON3:-False} + echo "Finalising tinyipa:" @@ -85,9 +87,14 @@ fi mkdir $FINALDIR/tmp/overides cp $WORKDIR/build_files/fakeuname $FINALDIR/tmp/overides/uname +PY_REQS="finalreqs_python2.lst" +if [[ $USE_PYTHON3 == "True" ]]; then + PY_REQS="finalreqs_python3.lst" +fi + while read line; do $TC_CHROOT_CMD tce-load -wic $line -done < $WORKDIR/build_files/finalreqs.lst +done < <(paste $WORKDIR/build_files/finalreqs.lst $WORKDIR/build_files/$PY_REQS) if $INSTALL_SSH ; then # Install and configure bare minimum for SSH access @@ -128,12 +135,19 @@ fi # Ensure tinyipa picks up installed kernel modules $CHROOT_CMD depmod -a `$WORKDIR/build_files/fakeuname -r` -# Install pip -$CHROOT_CMD python -m ensurepip --upgrade +PIP_COMMAND="pip" +TINYIPA_PYTHON_EXE="python" +if [[ $USE_PYTHON3 == "True" ]]; then + PIP_COMMAND="pip3" + TINYIPA_PYTHON_EXE="python3" +fi -# If flag is set install the python now +# Install pip +$CHROOT_CMD ${TINYIPA_PYTHON_EXE} -m ensurepip --upgrade + +# If flag is set install python now if $BUILD_AND_INSTALL_TINYIPA ; then - $CHROOT_CMD pip install --no-index --find-links=file:///tmp/wheelhouse --pre ironic_python_agent + $CHROOT_CMD $PIP_COMMAND install --no-index --find-links=file:///tmp/wheelhouse --pre ironic_python_agent rm -rf $FINALDIR/tmp/wheelhouse fi @@ -156,6 +170,15 @@ sudo sed -i '/# Main/a NOZSWAP=1' "$FINALDIR/etc/init.d/tc-config" if $PYOPTIMIZE_TINYIPA; then # Precompile all python + if [[ $USE_PYTHON3 == "True" ]]; then + set +e + $CHROOT_CMD /bin/bash -c "python3 -OO -m compileall /usr/local/lib/python3.6" + set -e + find $FINALDIR/usr/local/lib/python3.6 -name "*.py" -not -path "*ironic_python_agent/api/config.py" | sudo xargs --no-run-if-empty rm + find $FINALDIR/usr/local/lib/python3.6 -name "*.pyc" ! -name "*opt-2*" | sudo xargs --no-run-if-empty rm + sudo find $FINALDIR/usr/local/lib/python3.6 -type d -name __pycache__ -exec sh -c 'cd "$1"; for f in *; do mv -i "$f" .. ; done' find-sh {} \; + find $FINALDIR/usr/local/lib/python3.6 -name "*.cpython-36.opt-2*" | sed 'p;s/\.cpython-36\.opt-2//' | sudo xargs -n2 --no-run-if-empty mv + fi set +e $CHROOT_CMD /bin/bash -c "python -OO -m compileall /usr/local/lib/python2.7" set -e diff --git a/releasenotes/notes/build-tinyipa-with-python3-d4a64aa18f970968.yaml b/releasenotes/notes/build-tinyipa-with-python3-d4a64aa18f970968.yaml new file mode 100644 index 000000000..741a3e1c9 --- /dev/null +++ b/releasenotes/notes/build-tinyipa-with-python3-d4a64aa18f970968.yaml @@ -0,0 +1,4 @@ +--- +other: + - Updates the tinyipa build scripts to support building and running Ironic + Python Agent with python3.6. diff --git a/zuul.d/ironic-jobs.yaml b/zuul.d/ironic-jobs.yaml index 150159535..ec2440c91 100644 --- a/zuul.d/ironic-jobs.yaml +++ b/zuul.d/ironic-jobs.yaml @@ -54,6 +54,7 @@ parent: ironic-ipa-base timeout: 7200 vars: + devstack_localrc: IRONIC_DEPLOY_DRIVER: ipmi IRONIC_DEFAULT_DEPLOY_INTERFACE: iscsi