Constraints files allow a global view of dependencies for devstack
without the side effect that requirements files have of installing
everything everytime. This is part of the cross project
requirements-management spec.
Change-Id: If089d30146629e6cf817edd634e5c2b80f1366dd
| ... | ... |
@@ -66,7 +66,8 @@ function pip_install_gr {
|
| 66 | 66 |
|
| 67 | 67 |
# Wrapper for ``pip install`` to set cache and proxy environment variables |
| 68 | 68 |
# Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``, |
| 69 |
-# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy`` |
|
| 69 |
+# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``, |
|
| 70 |
+# ``USE_CONSTRAINTS`` |
|
| 70 | 71 |
# pip_install package [package ...] |
| 71 | 72 |
function pip_install {
|
| 72 | 73 |
local xtrace=$(set +o | grep xtrace) |
| ... | ... |
@@ -103,6 +104,13 @@ function pip_install {
|
| 103 | 103 |
fi |
| 104 | 104 |
fi |
| 105 | 105 |
|
| 106 |
+ cmd_pip="$cmd_pip install" |
|
| 107 |
+ |
|
| 108 |
+ # Handle a constraints file, if needed. |
|
| 109 |
+ if [[ "$USE_CONSTRAINTS" == "True" ]]; then |
|
| 110 |
+ cmd_pip="$cmd_pip -c $REQUIREMENTS_DIR/upper-constraints.txt" |
|
| 111 |
+ fi |
|
| 112 |
+ |
|
| 106 | 113 |
local pip_version=$(python -c "import pip; \ |
| 107 | 114 |
print(pip.__version__.strip('.')[0])")
|
| 108 | 115 |
if (( pip_version<6 )); then |
| ... | ... |
@@ -116,7 +124,7 @@ function pip_install {
|
| 116 | 116 |
https_proxy="${https_proxy:-}" \
|
| 117 | 117 |
no_proxy="${no_proxy:-}" \
|
| 118 | 118 |
PIP_FIND_LINKS=$PIP_FIND_LINKS \ |
| 119 |
- $cmd_pip install $upgrade \ |
|
| 119 |
+ $cmd_pip $upgrade \ |
|
| 120 | 120 |
$@ |
| 121 | 121 |
|
| 122 | 122 |
# Also install test requirements |
| ... | ... |
@@ -128,7 +136,7 @@ function pip_install {
|
| 128 | 128 |
https_proxy=${https_proxy:-} \
|
| 129 | 129 |
no_proxy=${no_proxy:-} \
|
| 130 | 130 |
PIP_FIND_LINKS=$PIP_FIND_LINKS \ |
| 131 |
- $cmd_pip install $upgrade \ |
|
| 131 |
+ $cmd_pip $upgrade \ |
|
| 132 | 132 |
-r $test_req |
| 133 | 133 |
fi |
| 134 | 134 |
} |
| ... | ... |
@@ -215,7 +223,7 @@ function setup_package_with_req_sync {
|
| 215 | 215 |
# ``errexit`` requires us to trap the exit code when the repo is changed |
| 216 | 216 |
local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed") |
| 217 | 217 |
|
| 218 |
- if [[ $update_requirements != "changed" ]]; then |
|
| 218 |
+ if [[ $update_requirements != "changed" && "$USE_CONSTRAINTS" == "False" ]]; then |
|
| 219 | 219 |
if is_in_projects_txt $project_dir; then |
| 220 | 220 |
(cd $REQUIREMENTS_DIR; \ |
| 221 | 221 |
./.venv/bin/python update.py $project_dir) |
| ... | ... |
@@ -227,6 +235,12 @@ function setup_package_with_req_sync {
|
| 227 | 227 |
fi |
| 228 | 228 |
fi |
| 229 | 229 |
|
| 230 |
+ if [ -n "$REQUIREMENTS_DIR" ]; then |
|
| 231 |
+ # Constrain this package to this project directory from here on out. |
|
| 232 |
+ local name=$(awk '/^name.*=/ {print $3}' $project_dir/setup.cfg)
|
|
| 233 |
+ $REQUIREMENTS_DIR/.venv/bin/edit-constraints $REQUIREMENTS_DIR/upper-constraints.txt -- $name "$flags $project_dir" |
|
| 234 |
+ fi |
|
| 235 |
+ |
|
| 230 | 236 |
setup_package $project_dir $flags |
| 231 | 237 |
|
| 232 | 238 |
# We've just gone and possibly modified the user's source tree in an |
| ... | ... |
@@ -683,6 +683,9 @@ save_stackenv $LINENO |
| 683 | 683 |
echo_summary "Installing package prerequisites" |
| 684 | 684 |
source $TOP_DIR/tools/install_prereqs.sh |
| 685 | 685 |
|
| 686 |
+# Normalise USE_CONSTRAINTS |
|
| 687 |
+USE_CONSTRAINTS=$(trueorfalse False USE_CONSTRAINTS) |
|
| 688 |
+ |
|
| 686 | 689 |
# Configure an appropriate Python environment |
| 687 | 690 |
if [[ "$OFFLINE" != "True" ]]; then |
| 688 | 691 |
PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
|
| ... | ... |
@@ -149,6 +149,12 @@ DATABASE_QUERY_LOGGING=$(trueorfalse False DATABASE_QUERY_LOGGING) |
| 149 | 149 |
# Zero disables timeouts |
| 150 | 150 |
GIT_TIMEOUT=${GIT_TIMEOUT:-0}
|
| 151 | 151 |
|
| 152 |
+# Constraints mode |
|
| 153 |
+# - False (default) : update git projects dependencies from global-requirements. |
|
| 154 |
+# |
|
| 155 |
+# - True : use upper-constraints.txt to constrain versions of packages intalled |
|
| 156 |
+# and do not edit projects at all. |
|
| 157 |
+USE_CONSTRAINTS=${USE_CONSTRAINTS:-False}
|
|
| 152 | 158 |
|
| 153 | 159 |
# Repositories |
| 154 | 160 |
# ------------ |