Skip to contentSkip to conversation

bitbake: toaster: skip virtualenv when searching for django apps

PATCH Superseded Michael Wood 1 participant 2 messages Oct 27, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: toaster: skip virtualenv when searching for django apps

If we are using a virtualenv in the current search path we end up trying to add modules to the django apps list which do not have the correct load path or are internal to other modules. Fix this by skipping the virtualenv path.

[YOCTO #6896]

---
 bitbake/lib/toaster/toastermain/settings.py | 4 ++++
 1 file changed, 4 insertions(+)
bitbake/lib/toaster/toastermain/settings.py +4 -0
index 42581f2..65f1991 100644
@@ -260,6 +260,10 @@ import os
 currentdir = os.path.dirname(__file__)
 for t in os.walk(os.path.dirname(currentdir)):
     modulename = os.path.basename(t[0])
+    #if we have a virtualenv skip it to avoid incorrect imports
+    if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
+        continue
+
     if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS:
         INSTALLED_APPS = INSTALLED_APPS + (modulename,)
 
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 bitbake: toaster: skip virtualenv when searching for django apps

If we are using a virtualenv in the current search path we end up trying to add modules to the django apps list which do not have the correct load path or are internal to other modules. Fix this by skipping the virtualenv path.

[YOCTO #6896]

---
 bitbake/lib/toaster/toastermain/settings.py | 4 ++++
 bitbake/lib/toaster/toastermain/urls.py     | 4 ++++
 2 files changed, 8 insertions(+)
bitbake/lib/toaster/toastermain/settings.py +4 -0
index 42581f2..65f1991 100644
@@ -260,6 +260,10 @@ import os
 currentdir = os.path.dirname(__file__)
 for t in os.walk(os.path.dirname(currentdir)):
     modulename = os.path.basename(t[0])
+    #if we have a virtualenv skip it to avoid incorrect imports
+    if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
+        continue
+
     if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS:
         INSTALLED_APPS = INSTALLED_APPS + (modulename,)
 
bitbake/lib/toaster/toastermain/urls.py +4 -0
index 1ae6245..549fda1 100644
@@ -55,6 +55,10 @@ if toastermain.settings.MANAGED:
 import os
 currentdir = os.path.dirname(__file__)
 for t in os.walk(os.path.dirname(currentdir)):
+    #if we have a virtualenv skip it to avoid incorrect imports
+    if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]:
+        continue
+
     if "urls.py" in t[2] and t[0] != currentdir:
         modulename = os.path.basename(t[0])
         urlpatterns.append( url(r'^' + modulename + '/', include ( modulename + '.urls')))
Signature · 1 line
1.9.1