2fdb729e04
Currently, if USE_VENV=True, PROJECT_VENVs are initialized using the tools/build_venv.sh script; this script depends on the virtualenv module, which is much less commonly available than the built-in venv module which we already use many places. This changes the build_venv.sh script to use `python -m venv` instead. Needed-By: https://review.opendev.org/c/openstack/ironic/+/930776 Change-Id: I89fa2c0c4261e715064e77a766d98a34299532b3
48 lines
1010 B
Bash
Executable File
48 lines
1010 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# **tools/build_venv.sh** - Build a Python Virtual Envirnment
|
|
#
|
|
# build_venv.sh venv-path [package [...]]
|
|
#
|
|
# Installs basic common prereq packages that require compilation
|
|
# to allow quick copying of resulting venv as a baseline
|
|
#
|
|
# Assumes:
|
|
# - a useful pip is installed
|
|
# - virtualenv will be installed by pip
|
|
|
|
|
|
VENV_DEST=${1:-.venv}
|
|
shift
|
|
|
|
MORE_PACKAGES="$@"
|
|
|
|
# If ``TOP_DIR`` is set we're being sourced rather than running stand-alone
|
|
# or in a sub-shell
|
|
if [[ -z "$TOP_DIR" ]]; then
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
|
|
# Keep track of the DevStack directory
|
|
TOP_DIR=$(cd $(dirname "$0")/.. && pwd)
|
|
FILES=$TOP_DIR/files
|
|
|
|
# Import common functions
|
|
source $TOP_DIR/functions
|
|
|
|
GetDistro
|
|
|
|
source $TOP_DIR/stackrc
|
|
|
|
fi
|
|
|
|
# Build new venv
|
|
python$PYTHON3_VERSION -m venv --system-site-packages $VENV_DEST
|
|
|
|
# Install modern pip
|
|
PIP_VIRTUAL_ENV=$VENV_DEST pip_install -U pip
|
|
|
|
# Install additional packages
|
|
PIP_VIRTUAL_ENV=$VENV_DEST pip_install ${MORE_PACKAGES}
|