Browse code

Merge "Just use constraints everywhere"

Jenkins authored on 2015/08/19 08:07:53
Showing 6 changed files
... ...
@@ -28,7 +28,6 @@
28 28
 # - ``REQUIREMENTS_DIR``
29 29
 # - ``STACK_USER``
30 30
 # - ``TRACK_DEPENDS``
31
-# - ``UNDO_REQUIREMENTS``
32 31
 # - ``http_proxy``, ``https_proxy``, ``no_proxy``
33 32
 #
34 33
 
... ...
@@ -67,7 +67,6 @@ function pip_install_gr {
67 67
 # Wrapper for ``pip install`` to set cache and proxy environment variables
68 68
 # Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``,
69 69
 # ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``,
70
-# ``USE_CONSTRAINTS``
71 70
 # pip_install package [package ...]
72 71
 function pip_install {
73 72
     local xtrace=$(set +o | grep xtrace)
... ...
@@ -105,11 +104,8 @@ function pip_install {
105 105
     fi
106 106
 
107 107
     cmd_pip="$cmd_pip install"
108
-
109
-    # Handle a constraints file, if needed.
110
-    if [[ "$USE_CONSTRAINTS" == "True" ]]; then
111
-        cmd_pip="$cmd_pip -c $REQUIREMENTS_DIR/upper-constraints.txt"
112
-    fi
108
+    # Always apply constraints
109
+    cmd_pip="$cmd_pip -c $REQUIREMENTS_DIR/upper-constraints.txt"
113 110
 
114 111
     local pip_version=$(python -c "import pip; \
115 112
                         print(pip.__version__.strip('.')[0])")
... ...
@@ -187,13 +183,13 @@ function setup_dev_lib {
187 187
 # use this, especially *oslo* ones
188 188
 function setup_install {
189 189
     local project_dir=$1
190
-    setup_package_with_req_sync $project_dir
190
+    setup_package_with_constraints_edit $project_dir
191 191
 }
192 192
 
193 193
 # this should be used for projects which run services, like all services
194 194
 function setup_develop {
195 195
     local project_dir=$1
196
-    setup_package_with_req_sync $project_dir -e
196
+    setup_package_with_constraints_edit $project_dir -e
197 197
 }
198 198
 
199 199
 # determine if a project as specified by directory is in
... ...
@@ -209,32 +205,16 @@ function is_in_projects_txt {
209 209
 # ``pip install -e`` the package, which processes the dependencies
210 210
 # using pip before running `setup.py develop`
211 211
 #
212
-# Updates the dependencies in project_dir from the
213
-# openstack/requirements global list before installing anything.
212
+# Updates the constraints from REQUIREMENTS_DIR to reflect the
213
+# future installed state of this package. This ensures when we
214
+# install this package we get the from source version.
214 215
 #
215
-# Uses globals ``TRACK_DEPENDS``, ``REQUIREMENTS_DIR``, ``UNDO_REQUIREMENTS``
216
+# Uses globals ``REQUIREMENTS_DIR``
216 217
 # setup_develop directory
217
-function setup_package_with_req_sync {
218
+function setup_package_with_constraints_edit {
218 219
     local project_dir=$1
219 220
     local flags=$2
220 221
 
221
-    # Don't update repo if local changes exist
222
-    # Don't use buggy "git diff --quiet"
223
-    # ``errexit`` requires us to trap the exit code when the repo is changed
224
-    local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed")
225
-
226
-    if [[ $update_requirements != "changed" && "$USE_CONSTRAINTS" == "False" ]]; then
227
-        if is_in_projects_txt $project_dir; then
228
-            (cd $REQUIREMENTS_DIR; \
229
-                ./.venv/bin/python update.py $project_dir)
230
-        else
231
-            # soft update projects not found in requirements project.txt
232
-            echo "$project_dir not a constrained repository, soft enforcing requirements"
233
-            (cd $REQUIREMENTS_DIR; \
234
-                ./.venv/bin/python update.py -s $project_dir)
235
-        fi
236
-    fi
237
-
238 222
     if [ -n "$REQUIREMENTS_DIR" ]; then
239 223
         # Constrain this package to this project directory from here on out.
240 224
         local name=$(awk '/^name.*=/ {print $3}' $project_dir/setup.cfg)
... ...
@@ -245,19 +225,6 @@ function setup_package_with_req_sync {
245 245
 
246 246
     setup_package $project_dir $flags
247 247
 
248
-    # We've just gone and possibly modified the user's source tree in an
249
-    # automated way, which is considered bad form if it's a development
250
-    # tree because we've screwed up their next git checkin. So undo it.
251
-    #
252
-    # However... there are some circumstances, like running in the gate
253
-    # where we really really want the overridden version to stick. So provide
254
-    # a variable that tells us whether or not we should UNDO the requirements
255
-    # changes (this will be set to False in the OpenStack ci gate)
256
-    if [ $UNDO_REQUIREMENTS = "True" ]; then
257
-        if [[ $update_requirements != "changed" ]]; then
258
-            (cd $project_dir && git reset --hard)
259
-        fi
260
-    fi
261 248
 }
262 249
 
263 250
 # ``pip install -e`` the package, which processes the dependencies
... ...
@@ -22,7 +22,6 @@ set +o xtrace
22 22
 # Defaults
23 23
 # --------
24 24
 GITDIR["pbr"]=$DEST/pbr
25
-REQUIREMENTS_DIR=$DEST/requirements
26 25
 
27 26
 # Entry Points
28 27
 # ------------
... ...
@@ -688,9 +688,6 @@ save_stackenv $LINENO
688 688
 echo_summary "Installing package prerequisites"
689 689
 source $TOP_DIR/tools/install_prereqs.sh
690 690
 
691
-# Normalise USE_CONSTRAINTS
692
-USE_CONSTRAINTS=$(trueorfalse False USE_CONSTRAINTS)
693
-
694 691
 # Configure an appropriate Python environment
695 692
 if [[ "$OFFLINE" != "True" ]]; then
696 693
     PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
... ...
@@ -152,13 +152,6 @@ DATABASE_QUERY_LOGGING=$(trueorfalse False DATABASE_QUERY_LOGGING)
152 152
 # Zero disables timeouts
153 153
 GIT_TIMEOUT=${GIT_TIMEOUT:-0}
154 154
 
155
-# Constraints mode
156
-# - False (default) : update git projects dependencies from global-requirements.
157
-#
158
-# - True : use upper-constraints.txt to constrain versions of packages intalled
159
-#          and do not edit projects at all.
160
-USE_CONSTRAINTS=$(trueorfalse False USE_CONSTRAINTS)
161
-
162 155
 # Repositories
163 156
 # ------------
164 157
 
... ...
@@ -166,6 +159,9 @@ USE_CONSTRAINTS=$(trueorfalse False USE_CONSTRAINTS)
166 166
 # Another option is https://git.openstack.org
167 167
 GIT_BASE=${GIT_BASE:-git://git.openstack.org}
168 168
 
169
+# The location of REQUIREMENTS once cloned
170
+REQUIREMENTS_DIR=$DEST/requirements
171
+
169 172
 # Which libraries should we install from git instead of using released
170 173
 # versions on pypi?
171 174
 #
... ...
@@ -630,9 +626,6 @@ USE_SCREEN=${SCREEN_DEV:-$USE_SCREEN}
630 630
 # Set default screen name
631 631
 SCREEN_NAME=${SCREEN_NAME:-stack}
632 632
 
633
-# Undo requirements changes by global requirements
634
-UNDO_REQUIREMENTS=${UNDO_REQUIREMENTS:-True}
635
-
636 633
 # Allow the use of an alternate protocol (such as https) for service endpoints
637 634
 SERVICE_PROTOCOL=${SERVICE_PROTOCOL:-http}
638 635
 
... ...
@@ -20,7 +20,7 @@ TOP_DIR=`cd $TOOLS_DIR/..; pwd`
20 20
 cd $TOP_DIR
21 21
 
22 22
 # Import common functions
23
-source $TOP_DIR/functions
23
+source $TOP_DIR/stackrc
24 24
 
25 25
 FILES=$TOP_DIR/files
26 26