Skip to content

Commit f3302dc

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add options for development bindep install"
2 parents f127559 + 58243f6 commit f3302dc

4 files changed

Lines changed: 95 additions & 13 deletions

File tree

functions-common

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,35 @@ function zypper_install {
13891389
zypper --non-interactive install --auto-agree-with-licenses --no-recommends "$@"
13901390
}
13911391

1392+
# Run bindep and install packages it outputs
1393+
#
1394+
# Usage:
1395+
# install_bindep <path-to-bindep.txt> [profile,profile]
1396+
#
1397+
# Note unlike the bindep command itself, profile(s) specified should
1398+
# be a single, comma-separated string, no spaces.
1399+
function install_bindep {
1400+
local file=$1
1401+
local profiles=${2:-""}
1402+
local pkgs
1403+
1404+
if [[ ! -f $file ]]; then
1405+
die $LINENO "Can not find bindep file: $file"
1406+
fi
1407+
1408+
# converting here makes it much easier to work with passing
1409+
# arguments
1410+
profiles=${profiles/,/ /}
1411+
1412+
# Note bindep returns 1 when packages need to be installed, so we
1413+
# have to ignore it's return for "-e"
1414+
pkgs=$($DEST/bindep-venv/bin/bindep -b --file $file $profiles || true)
1415+
1416+
if [[ -n "${pkgs}" ]]; then
1417+
install_package ${pkgs}
1418+
fi
1419+
}
1420+
13921421
function write_user_unit_file {
13931422
local service=$1
13941423
local command="$2"

inc/python

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,14 @@ function setup_lib {
428428
# another project.
429429
#
430430
# use this for non namespaced libraries
431+
#
432+
# setup_dev_lib [-bindep] <name>
431433
function setup_dev_lib {
434+
local bindep
435+
if [[ $1 == -bindep* ]]; then
436+
bindep="${1}"
437+
shift
438+
fi
432439
local name=$1
433440
local dir=${GITDIR[$name]}
434441
if python3_enabled; then
@@ -438,10 +445,10 @@ function setup_dev_lib {
438445
# of Python.
439446
echo "Installing $name again without Python 3 enabled"
440447
USE_PYTHON3=False
441-
setup_develop $dir
448+
setup_develop $bindep $dir
442449
USE_PYTHON3=True
443450
fi
444-
setup_develop $dir
451+
setup_develop $bindep $dir
445452
}
446453

447454
# this should be used if you want to install globally, all libraries should
@@ -452,11 +459,17 @@ function setup_dev_lib {
452459
# extras: comma-separated list of optional dependencies to install
453460
# (e.g., ldap,memcache).
454461
# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
462+
# bindep: Set "-bindep" as first argument to install bindep.txt packages
455463
# The command is like "pip install <project_dir>[<extras>]"
456464
function setup_install {
465+
local bindep
466+
if [[ $1 == -bindep* ]]; then
467+
bindep="${1}"
468+
shift
469+
fi
457470
local project_dir=$1
458471
local extras=$2
459-
_setup_package_with_constraints_edit $project_dir "" $extras
472+
_setup_package_with_constraints_edit $bindep $project_dir "" $extras
460473
}
461474

462475
# this should be used for projects which run services, like all services
@@ -468,9 +481,14 @@ function setup_install {
468481
# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
469482
# The command is like "pip install -e <project_dir>[<extras>]"
470483
function setup_develop {
484+
local bindep
485+
if [[ $1 == -bindep* ]]; then
486+
bindep="${1}"
487+
shift
488+
fi
471489
local project_dir=$1
472490
local extras=$2
473-
_setup_package_with_constraints_edit $project_dir -e $extras
491+
_setup_package_with_constraints_edit $bindep $project_dir -e $extras
474492
}
475493

476494
# ``pip install -e`` the package, which processes the dependencies
@@ -489,6 +507,11 @@ function setup_develop {
489507
# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
490508
# The command is like "pip install <flags> <project_dir>[<extras>]"
491509
function _setup_package_with_constraints_edit {
510+
local bindep
511+
if [[ $1 == -bindep* ]]; then
512+
bindep="${1}"
513+
shift
514+
fi
492515
local project_dir=$1
493516
local flags=$2
494517
local extras=$3
@@ -509,7 +532,7 @@ function _setup_package_with_constraints_edit {
509532
"$flags file://$project_dir#egg=$name"
510533
fi
511534

512-
setup_package $project_dir "$flags" $extras
535+
setup_package $bindep $project_dir "$flags" $extras
513536

514537
# If this project is in LIBS_FROM_GIT, verify it was actually installed
515538
# correctly. This helps catch errors caused by constraints mismatches.
@@ -521,17 +544,30 @@ function _setup_package_with_constraints_edit {
521544
}
522545

523546
# ``pip install -e`` the package, which processes the dependencies
524-
# using pip before running `setup.py develop`
547+
# using pip before running `setup.py develop`. The command is like
548+
# "pip install <flags> <project_dir>[<extras>]"
525549
#
526550
# Uses globals ``STACK_USER``
527-
# setup_package project_dir [flags] [extras]
528-
# project_dir: directory of project repo (e.g., /opt/stack/keystone)
529-
# flags: pip CLI options/flags
530-
# extras: comma-separated list of optional dependencies to install
531-
# (e.g., ldap,memcache).
532-
# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
533-
# The command is like "pip install <flags> <project_dir>[<extras>]"
551+
#
552+
# Usage:
553+
# setup_package [-bindep[=profile,profile]] <project_dir> <flags> [extras]
554+
#
555+
# -bindep : Use bindep to install dependencies; select extra profiles
556+
# as comma separated arguments after "="
557+
# project_dir : directory of project repo (e.g., /opt/stack/keystone)
558+
# flags : pip CLI options/flags
559+
# extras : comma-separated list of optional dependencies to install
560+
# (e.g., ldap,memcache).
561+
# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
534562
function setup_package {
563+
local bindep=0
564+
local bindep_flag=""
565+
local bindep_profiles=""
566+
if [[ $1 == -bindep* ]]; then
567+
bindep=1
568+
IFS="=" read bindep_flag bindep_profiles <<< ${1}
569+
shift
570+
fi
535571
local project_dir=$1
536572
local flags=$2
537573
local extras=$3
@@ -547,6 +583,11 @@ function setup_package {
547583
extras="[$extras]"
548584
fi
549585

586+
# install any bindep packages
587+
if [[ $bindep == 1 ]]; then
588+
install_bindep $project_dir/bindep.txt $bindep_profiles
589+
fi
590+
550591
pip_install $flags "$project_dir$extras"
551592
# ensure that further actions can do things like setup.py sdist
552593
if [[ "$flags" == "-e" ]]; then

stack.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ fi
801801
# Install required infra support libraries
802802
install_infra
803803

804+
# Install bindep
805+
$VIRTUALENV_CMD $DEST/bindep-venv
806+
# TODO(ianw) : optionally install from zuul checkout?
807+
$DEST/bindep-venv/bin/pip install bindep
808+
804809
# Extras Pre-install
805810
# ------------------
806811
# Phase: pre-install

stackrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,13 @@ export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3.5}}
143143
_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
144144
export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}}
145145

146+
# Create a virtualenv with this
147+
if [[ ${USE_PYTHON3} == True ]]; then
148+
export VIRTUALENV_CMD="python3 -m venv"
149+
else
150+
export VIRTUALENV_CMD="virtualenv "
151+
fi
152+
146153
# allow local overrides of env variables, including repo config
147154
if [[ -f $RC_DIR/localrc ]]; then
148155
# Old-style user-supplied config

0 commit comments

Comments
 (0)