Browse code

Use "pip list" in check_libs_from_git

As described in the change, "pip freeze" has issues with the way
zuulv3 clones repos without a remote. This is an attempt to use "pip
list" to check for local install

Change-Id: I33d25f86b6afcadb4b190a0f6c53311111c64521

Ian Wienand authored on 2017/09/29 09:16:47
Showing 2 changed files
... ...
@@ -386,7 +386,20 @@ function use_library_from_git {
386 386
 # determine if a package was installed from git
387 387
 function lib_installed_from_git {
388 388
     local name=$1
389
-    pip freeze 2>/dev/null | grep -- "$name" | grep -q -- '-e git'
389
+    # Note "pip freeze" doesn't always work here, because it tries to
390
+    # be smart about finding the remote of the git repo the package
391
+    # was installed from.  This doesn't work with zuul which clones
392
+    # repos with no remote.
393
+    #
394
+    # The best option seems to be to use "pip list" which will tell
395
+    # you the path an editable install was installed from; for example
396
+    # in response to something like
397
+    #  pip install -e 'git+http://git.openstack.org/openstack-dev/bashate#egg=bashate'
398
+    # pip list shows
399
+    #  bashate (0.5.2.dev19, /tmp/env/src/bashate)
400
+    # Thus we look for "path after a comma" to indicate we were
401
+    # installed from some local place
402
+    pip list 2>/dev/null | grep -- "$name" | grep -q -- ', .*)$'
390 403
 }
391 404
 
392 405
 # check that everything that's in LIBS_FROM_GIT was actually installed
... ...
@@ -1389,11 +1389,7 @@ service_check
1389 1389
 
1390 1390
 # ensure that all the libraries we think we installed from git,
1391 1391
 # actually were.
1392
-#
1393
-# NOTE(ianw) 2017-09-27 : "pip freeze" is currently having issues
1394
-# with zuulv3 and the way it clones remotes.  We will restore this
1395
-# with a slightly different check soon
1396
-#check_libs_from_git
1392
+check_libs_from_git
1397 1393
 
1398 1394
 
1399 1395
 # Configure nova cellsv2