Use correct command for Python virtualenv

Using the virtualenv command will generate a virtualenv with the
default python exec for the entire system, that means that even
if DIB_PYTHON is python3, the virtualenv will use python2.
With this change we use the venv embedded command if the version
of Python is 3.x to generate a virtualenv with the correct
Python 3 version.

Change-Id: I8bec32c5e0dae2dee27615146f946a9649f23fd1
This commit is contained in:
Riccardo Pittau 2020-01-29 18:31:33 +01:00
parent 22a12a3a41
commit 46c78a10c1

View File

@ -14,7 +14,11 @@ UPPER_CONSTRAINTS=/tmp/requirements/upper-constraints.txt
VENVDIR=/opt/ironic-python-agent
# create the virtual environment using the default python
$DIB_PYTHON -m virtualenv -- $VENVDIR
if [ $DIB_PYTHON_VERSION == 3 ]; then
$DIB_PYTHON -m venv $VENVDIR
else
$DIB_PYTHON -m virtualenv $VENVDIR
fi
# pip might be an older version which does not support the -c option, therefore upgrade first
$VENVDIR/bin/pip install pip --upgrade