better handling for installing config file in virtualenv
[tools/mic.git] / mic / conf.py
index e29bd3b..45485d8 100644 (file)
@@ -27,13 +27,10 @@ DEFAULT_GSITECONF = '/etc/mic/mic.conf'
 
 
 def get_siteconf():
-    mic_path = os.path.dirname(__file__)
-
-    m = re.match(r"(?P<prefix>.*)\/lib(64)?\/.*", mic_path)
-    if m and m.group('prefix') != "/usr":
-        return os.path.join(m.group('prefix'), "etc/mic/mic.conf")
-
-    return DEFAULT_GSITECONF
+    if hasattr(sys, 'real_prefix'):
+        return os.path.join(sys.prefix, "etc/mic/mic.conf")
+    else:
+        return DEFAULT_GSITECONF
 
 class ConfigMgr(object):
     prefer_backends = ["zypp", "yum"]