From 20654e6a0605d30ff636f9319fb5b6557fa2ccdf Mon Sep 17 00:00:00 2001 From: lmancini Date: Tue, 15 Jun 2010 12:44:40 +0000 Subject: [PATCH] Prepend pathex to the current PYTHONPATH before executing an external statement. git-svn-id: http://svn.pyinstaller.org/trunk@850 8dd32b29-ccff-0310-8a9a-9233e24343b1 --- hooks/hookutils.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/hooks/hookutils.py b/hooks/hookutils.py index d45f081..34dcad1 100644 --- a/hooks/hookutils.py +++ b/hooks/hookutils.py @@ -17,7 +17,21 @@ def exec_statement(stat): cmd = 'echo on && "%s" -c "%s" > "%s"' % (exe, stat, fnm) else: cmd = '"%s" -c "%s" > "%s"' % (exe, stat, fnm) - os.system(cmd) + + # Prepend PYTHONPATH with pathex + pp = ':'.join(sys.pathex) + old_pp = os.environ.get('PYTHONPATH', '') + if old_pp: + pp = ':'.join([pp, old_pp]) + os.environ["PYTHONPATH"] = pp + try: + # Actually execute the statement + os.system(cmd) + finally: + if old_pp: + os.environ["PYTHONPATH"] = old_pp + else: + del os.environ["PYTHONPATH"] txt = open(fnm, 'r').read()[:-1] os.remove(fnm) @@ -74,4 +88,3 @@ def find_django_root(dir): if "manage.py" in dir_entities and "settings.py" in dir_entities and "urls.py" in dir_entities: django_root_directories.append(path_to_analyze) return django_root_directories -