summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-06 16:34:56 +0000
committerGerrit Code Review <review@openstack.org>2019-02-06 16:34:57 +0000
commitf3302dcee3e11fb4283a28416e1bcf92514b6bf8 (patch)
treee2ee094c33c2db78d39ad2c134f22dd8cbd353a4
parentf1275599ad372e7715b5b825d6ab8649867b3679 (diff)
parent58243f6203f3385039fe7124b037d5abf7e1d59e (diff)
Merge "Add options for development bindep install"
-rw-r--r--functions-common29
-rw-r--r--inc/python67
-rwxr-xr-xstack.sh5
-rw-r--r--stackrc7
4 files changed, 95 insertions, 13 deletions
diff --git a/functions-common b/functions-common
index e5962db..2a8f19e 100644
--- a/functions-common
+++ b/functions-common
@@ -1389,6 +1389,35 @@ function zypper_install {
1389 zypper --non-interactive install --auto-agree-with-licenses --no-recommends "$@" 1389 zypper --non-interactive install --auto-agree-with-licenses --no-recommends "$@"
1390} 1390}
1391 1391
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.
1399function 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
1392function write_user_unit_file { 1421function write_user_unit_file {
1393 local service=$1 1422 local service=$1
1394 local command="$2" 1423 local command="$2"
diff --git a/inc/python b/inc/python
index f1df101..ec7eb5b 100644
--- a/inc/python
+++ b/inc/python
@@ -428,7 +428,14 @@ function setup_lib {
428# another project. 428# another project.
429# 429#
430# use this for non namespaced libraries 430# use this for non namespaced libraries
431#
432# setup_dev_lib [-bindep] <name>
431function setup_dev_lib { 433function setup_dev_lib {
434 local bindep
435 if [[ $1 == -bindep* ]]; then
436 bindep="${1}"
437 shift
438 fi
432 local name=$1 439 local name=$1
433 local dir=${GITDIR[$name]} 440 local dir=${GITDIR[$name]}
434 if python3_enabled; then 441 if python3_enabled; then
@@ -438,10 +445,10 @@ function setup_dev_lib {
438 # of Python. 445 # of Python.
439 echo "Installing $name again without Python 3 enabled" 446 echo "Installing $name again without Python 3 enabled"
440 USE_PYTHON3=False 447 USE_PYTHON3=False
441 setup_develop $dir 448 setup_develop $bindep $dir
442 USE_PYTHON3=True 449 USE_PYTHON3=True
443 fi 450 fi
444 setup_develop $dir 451 setup_develop $bindep $dir
445} 452}
446 453
447# this should be used if you want to install globally, all libraries should 454# this should be used if you want to install globally, all libraries should
@@ -452,11 +459,17 @@ function setup_dev_lib {
452# extras: comma-separated list of optional dependencies to install 459# extras: comma-separated list of optional dependencies to install
453# (e.g., ldap,memcache). 460# (e.g., ldap,memcache).
454# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements 461# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
462# bindep: Set "-bindep" as first argument to install bindep.txt packages
455# The command is like "pip install <project_dir>[<extras>]" 463# The command is like "pip install <project_dir>[<extras>]"
456function setup_install { 464function setup_install {
465 local bindep
466 if [[ $1 == -bindep* ]]; then
467 bindep="${1}"
468 shift
469 fi
457 local project_dir=$1 470 local project_dir=$1
458 local extras=$2 471 local extras=$2
459 _setup_package_with_constraints_edit $project_dir "" $extras 472 _setup_package_with_constraints_edit $bindep $project_dir "" $extras
460} 473}
461 474
462# this should be used for projects which run services, like all services 475# this should be used for projects which run services, like all services
@@ -468,9 +481,14 @@ function setup_install {
468# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements 481# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
469# The command is like "pip install -e <project_dir>[<extras>]" 482# The command is like "pip install -e <project_dir>[<extras>]"
470function setup_develop { 483function setup_develop {
484 local bindep
485 if [[ $1 == -bindep* ]]; then
486 bindep="${1}"
487 shift
488 fi
471 local project_dir=$1 489 local project_dir=$1
472 local extras=$2 490 local extras=$2
473 _setup_package_with_constraints_edit $project_dir -e $extras 491 _setup_package_with_constraints_edit $bindep $project_dir -e $extras
474} 492}
475 493
476# ``pip install -e`` the package, which processes the dependencies 494# ``pip install -e`` the package, which processes the dependencies
@@ -489,6 +507,11 @@ function setup_develop {
489# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements 507# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
490# The command is like "pip install <flags> <project_dir>[<extras>]" 508# The command is like "pip install <flags> <project_dir>[<extras>]"
491function _setup_package_with_constraints_edit { 509function _setup_package_with_constraints_edit {
510 local bindep
511 if [[ $1 == -bindep* ]]; then
512 bindep="${1}"
513 shift
514 fi
492 local project_dir=$1 515 local project_dir=$1
493 local flags=$2 516 local flags=$2
494 local extras=$3 517 local extras=$3
@@ -509,7 +532,7 @@ function _setup_package_with_constraints_edit {
509 "$flags file://$project_dir#egg=$name" 532 "$flags file://$project_dir#egg=$name"
510 fi 533 fi
511 534
512 setup_package $project_dir "$flags" $extras 535 setup_package $bindep $project_dir "$flags" $extras
513 536
514 # If this project is in LIBS_FROM_GIT, verify it was actually installed 537 # If this project is in LIBS_FROM_GIT, verify it was actually installed
515 # correctly. This helps catch errors caused by constraints mismatches. 538 # correctly. This helps catch errors caused by constraints mismatches.
@@ -521,17 +544,30 @@ function _setup_package_with_constraints_edit {
521} 544}
522 545
523# ``pip install -e`` the package, which processes the dependencies 546# ``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>]"
525# 549#
526# Uses globals ``STACK_USER`` 550# Uses globals ``STACK_USER``
527# setup_package project_dir [flags] [extras] 551#
528# project_dir: directory of project repo (e.g., /opt/stack/keystone) 552# Usage:
529# flags: pip CLI options/flags 553# setup_package [-bindep[=profile,profile]] <project_dir> <flags> [extras]
530# extras: comma-separated list of optional dependencies to install 554#
531# (e.g., ldap,memcache). 555# -bindep : Use bindep to install dependencies; select extra profiles
532# See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements 556# as comma separated arguments after "="
533# The command is like "pip install <flags> <project_dir>[<extras>]" 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
534function setup_package { 562function 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
535 local project_dir=$1 571 local project_dir=$1
536 local flags=$2 572 local flags=$2
537 local extras=$3 573 local extras=$3
@@ -547,6 +583,11 @@ function setup_package {
547 extras="[$extras]" 583 extras="[$extras]"
548 fi 584 fi
549 585
586 # install any bindep packages
587 if [[ $bindep == 1 ]]; then
588 install_bindep $project_dir/bindep.txt $bindep_profiles
589 fi
590
550 pip_install $flags "$project_dir$extras" 591 pip_install $flags "$project_dir$extras"
551 # ensure that further actions can do things like setup.py sdist 592 # ensure that further actions can do things like setup.py sdist
552 if [[ "$flags" == "-e" ]]; then 593 if [[ "$flags" == "-e" ]]; then
diff --git a/stack.sh b/stack.sh
index 54a4f98..022d5b9 100755
--- a/stack.sh
+++ b/stack.sh
@@ -801,6 +801,11 @@ fi
801# Install required infra support libraries 801# Install required infra support libraries
802install_infra 802install_infra
803 803
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
804# Extras Pre-install 809# Extras Pre-install
805# ------------------ 810# ------------------
806# Phase: pre-install 811# Phase: pre-install
diff --git a/stackrc b/stackrc
index d6f8606..53868f3 100644
--- a/stackrc
+++ b/stackrc
@@ -143,6 +143,13 @@ export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3.5}}
143_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)" 143_DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
144export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}} 144export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}}
145 145
146# Create a virtualenv with this
147if [[ ${USE_PYTHON3} == True ]]; then
148 export VIRTUALENV_CMD="python3 -m venv"
149else
150 export VIRTUALENV_CMD="virtualenv "
151fi
152
146# allow local overrides of env variables, including repo config 153# allow local overrides of env variables, including repo config
147if [[ -f $RC_DIR/localrc ]]; then 154if [[ -f $RC_DIR/localrc ]]; then
148 # Old-style user-supplied config 155 # Old-style user-supplied config