Update self version fetching mechanism

With release of new setuptools running setup.py --version started
returining extra line. Eventually, running setup.py as a script is not
considered as good practice and we should not rely on it's output much.
Instead, we can leverage importlib.metadata as it should be more
reliable in long run.

Closes-Bug: #1997365
Change-Id: Ife227db4ad25851456e1acc6b4daf198f39d989a
This commit is contained in:
Dmitriy Rabotyagov 2022-11-22 18:10:01 +01:00
parent b4443d3021
commit 7eebc69e8a

View File

@ -156,7 +156,7 @@ if [ "${SETUP_ARA}" == "true" ]; then
fi
# Get current code version (this runs at the root of OSA clone)
export CURRENT_OSA_VERSION=$(cd ${OSA_CLONE_DIR}; /opt/ansible-runtime/bin/python setup.py --version)
export CURRENT_OSA_VERSION=$(cd ${OSA_CLONE_DIR}; /opt/ansible-runtime/bin/python -c "from importlib.metadata import version; print(version('openstack-ansible'))")
# Ensure that Ansible binaries run from the venv
pushd /opt/ansible-runtime/bin