Browse Source

Merge "Add options for development bindep install"

Zuul 2 months ago
parent
commit
f3302dcee3
4 changed files with 95 additions and 13 deletions
  1. 29
    0
      functions-common
  2. 54
    13
      inc/python
  3. 5
    0
      stack.sh
  4. 7
    0
      stackrc

+ 29
- 0
functions-common View File

@@ -1389,6 +1389,35 @@ function zypper_install {
1389 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.
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
+
1392 1421
 function write_user_unit_file {
1393 1422
     local service=$1
1394 1423
     local command="$2"

+ 54
- 13
inc/python View File

@@ -428,7 +428,14 @@ function setup_lib {
428 428
 # another project.
429 429
 #
430 430
 # use this for non namespaced libraries
431
+#
432
+# setup_dev_lib [-bindep] <name>
431 433
 function setup_dev_lib {
434
+    local bindep
435
+    if [[ $1 == -bindep* ]]; then
436
+        bindep="${1}"
437
+        shift
438
+    fi
432 439
     local name=$1
433 440
     local dir=${GITDIR[$name]}
434 441
     if python3_enabled; then
@@ -438,10 +445,10 @@ function setup_dev_lib {
438 445
         # of Python.
439 446
         echo "Installing $name again without Python 3 enabled"
440 447
         USE_PYTHON3=False
441
-        setup_develop $dir
448
+        setup_develop $bindep $dir
442 449
         USE_PYTHON3=True
443 450
     fi
444
-    setup_develop $dir
451
+    setup_develop $bindep $dir
445 452
 }
446 453
 
447 454
 # this should be used if you want to install globally, all libraries should
@@ -452,11 +459,17 @@ function setup_dev_lib {
452 459
 # extras: comma-separated list of optional dependencies to install
453 460
 #         (e.g., ldap,memcache).
454 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 463
 # The command is like "pip install <project_dir>[<extras>]"
456 464
 function setup_install {
465
+    local bindep
466
+    if [[ $1 == -bindep* ]]; then
467
+        bindep="${1}"
468
+        shift
469
+    fi
457 470
     local project_dir=$1
458 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 475
 # this should be used for projects which run services, like all services
@@ -468,9 +481,14 @@ function setup_install {
468 481
 #         See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
469 482
 # The command is like "pip install -e <project_dir>[<extras>]"
470 483
 function setup_develop {
484
+    local bindep
485
+    if [[ $1 == -bindep* ]]; then
486
+        bindep="${1}"
487
+        shift
488
+    fi
471 489
     local project_dir=$1
472 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 494
 # ``pip install -e`` the package, which processes the dependencies
@@ -489,6 +507,11 @@ function setup_develop {
489 507
 #         See https://docs.openstack.org/pbr/latest/user/using.html#extra-requirements
490 508
 # The command is like "pip install <flags> <project_dir>[<extras>]"
491 509
 function _setup_package_with_constraints_edit {
510
+    local bindep
511
+    if [[ $1 == -bindep* ]]; then
512
+        bindep="${1}"
513
+        shift
514
+    fi
492 515
     local project_dir=$1
493 516
     local flags=$2
494 517
     local extras=$3
@@ -509,7 +532,7 @@ function _setup_package_with_constraints_edit {
509 532
             "$flags file://$project_dir#egg=$name"
510 533
     fi
511 534
 
512
-    setup_package $project_dir "$flags" $extras
535
+    setup_package $bindep $project_dir "$flags" $extras
513 536
 
514 537
     # If this project is in LIBS_FROM_GIT, verify it was actually installed
515 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 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 550
 # 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
534 562
 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
535 571
     local project_dir=$1
536 572
     local flags=$2
537 573
     local extras=$3
@@ -547,6 +583,11 @@ function setup_package {
547 583
         extras="[$extras]"
548 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 591
     pip_install $flags "$project_dir$extras"
551 592
     # ensure that further actions can do things like setup.py sdist
552 593
     if [[ "$flags" == "-e" ]]; then

+ 5
- 0
stack.sh View File

@@ -801,6 +801,11 @@ fi
801 801
 # Install required infra support libraries
802 802
 install_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 809
 # Extras Pre-install
805 810
 # ------------------
806 811
 # Phase: pre-install

+ 7
- 0
stackrc View File

@@ -143,6 +143,13 @@ export PYTHON3_VERSION=${PYTHON3_VERSION:-${_DEFAULT_PYTHON3_VERSION:-3.5}}
143 143
 _DEFAULT_PYTHON2_VERSION="$(_get_python_version python2)"
144 144
 export PYTHON2_VERSION=${PYTHON2_VERSION:-${_DEFAULT_PYTHON2_VERSION:-2.7}}
145 145
 
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
+
146 153
 # allow local overrides of env variables, including repo config
147 154
 if [[ -f $RC_DIR/localrc ]]; then
148 155
     # Old-style user-supplied config

Loading…
Cancel
Save