find the real path of binary script firstly
authorGui Chen <gui.chen@intel.com>
Wed, 29 Aug 2012 09:29:36 +0000 (17:29 +0800)
committerGui Chen <gui.chen@intel.com>
Fri, 31 Aug 2012 02:48:03 +0000 (10:48 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
mic/rt_util.py

index 16834f5..18ffc8a 100644 (file)
@@ -101,10 +101,25 @@ def get_bindmounts(cropts):
 
 
 def get_mic_binpath():
+    fp = None
     try:
-        fp = find_binary_path('mic')
+        # depends on 'setuptools'
+        import pkg_resources
+        dist = pkg_resources.get_distribution('mic')
+        # the real script is under EGG_INFO/scripts
+        if dist.has_metadata('scripts/mic'):
+            fp = os.path.join(dist.egg_info, "scripts/mic")
+
+    except:
+        pass
+
+    try:
+        # not found script if 'flat' egg installed
+        if not fp:
+            fp = find_binary_path('mic')
     except:
         raise errors.BootstrapError("Can't find mic binary in host OS")
+
     return fp
 
 def get_mic_modpath():