[PATCH] New module to set appropriate sys.path for scripts.

Guilherme Salgado guilherme.salgado at linaro.org
Tue Mar 22 04:33:29 EST 2011


This is so that we don't have to write a wrapper shell script for every python
script we have in app/patchwork/bin/.

Signed-off-by: Guilherme Salgado <guilherme.salgado at linaro.org>
---
 apps/patchwork/bin/_pythonpath.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
 create mode 100644 apps/patchwork/bin/_pythonpath.py

diff --git a/apps/patchwork/bin/_pythonpath.py b/apps/patchwork/bin/_pythonpath.py
new file mode 100644
index 0000000..0d8845d
--- /dev/null
+++ b/apps/patchwork/bin/_pythonpath.py
@@ -0,0 +1,15 @@
+"""Add the <patchwork>/apps and <patchwork>/lib/python directories to
+sys.path.
+
+Also sets the DJANGO_SETTINGS_MODULE environment variable to 'settings'.
+"""
+import os
+import sys
+
+
+patchwork_bin = os.path.dirname(__file__)
+patchwork_base = os.path.abspath(
+    os.path.join(patchwork_bin, '..', '..', '..'))
+sys.path.insert(0, '%s/lib/python' % patchwork_base)
+sys.path.insert(0, '%s/apps' % patchwork_base)
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'



More information about the Patchwork mailing list