function activate_dlrnapi_venv {
    if [ ! -d $WORKSPACE/dlrnapi_venv ]; then
        virtualenv --system-site-packages $WORKSPACE/dlrnapi_venv
    fi
    source $WORKSPACE/dlrnapi_venv/bin/activate
    pip install -U dlrnapi_client shyaml
}

function deactivate_dlrnapi_venv {
    # deactivate can fail with unbound variable, so we need +u
    set +u
    [[ $VIRTUAL_ENV = $WORKSPACE/dlrnapi_venv ]] && deactivate
}

function activate_dlrnapi_venv {
    if [ ! -d $WORKSPACE/dlrnapi_venv ]; then
        if [ $(command -v virtualenv) ]; then
            virtualenv --system-site-packages $WORKSPACE/dlrnapi_venv
        else
            python3 -m venv  --system-site-packages $WORKSPACE/dlrnapi_venv
        fi
    fi
    source $WORKSPACE/dlrnapi_venv/bin/activate
    pip install -U dlrnapi_client shyaml
}

function deactivate_dlrnapi_venv {
    # deactivate can fail with unbound variable, so we need +u
    set +u
    [[ $VIRTUAL_ENV = $WORKSPACE/dlrnapi_venv ]] && deactivate
}

Use venv module if virtualenv not installed
Use venv module if virtualenv not installed

In Centos9, virtualenv is not installed on default image.
With python3, We don't need virtualenv and we can use
"python3 -m venv".

Before moving entirely to "python3 -m venv" we should enforce
use of python3 for promoter, Some efforts were made in past
to do that[1].

Once we "enforce the use of python3 for promoter" we can just
use "python3 -m venv" instead of relying on virtualenv.

[1] https://review.rdoproject.org/r/c/rdo-infra/ci-config/+/28208

Change-Id: I46bdb1063cca414e7a9093f6c17347fb69e976b9
