Bug 920353 - Use PYCOMMANDPATH paths as site packages in pymake. r=gps
--- a/pymake/process.py
+++ b/pymake/process.py
@@ -1,16 +1,17 @@
"""
Skipping shell invocations is good, when possible. This wrapper around subprocess does dirty work of
parsing command lines into argv and making sure that no shell magic is being used.
"""
#TODO: ship pyprocessing?
import multiprocessing
import subprocess, shlex, re, logging, sys, traceback, os, imp, glob
+import site
from collections import deque
# XXXkhuey Work around http://bugs.python.org/issue1731717
subprocess._cleanup = lambda: None
import command, util
if sys.platform=='win32':
import win32process
_log = logging.getLogger('pymake.process')
@@ -342,38 +343,29 @@ class PythonException(Exception):
self.message = message
self.exitcode = exitcode
def __str__(self):
return self.message
def load_module_recursive(module, path):
"""
- Emulate the behavior of __import__, but allow
- passing a custom path to search for modules.
+ Like __import__, but allow passing a custom path to search for modules.
"""
- bits = module.split('.')
oldsyspath = sys.path
- for i, bit in enumerate(bits):
- dotname = '.'.join(bits[:i+1])
- try:
- f, path, desc = imp.find_module(bit, path)
- # Add the directory the module was found in to sys.path
- if path != '':
- abspath = os.path.abspath(path)
- if not os.path.isdir(abspath):
- abspath = os.path.dirname(path)
- sys.path = [abspath] + sys.path
- m = imp.load_module(dotname, f, path, desc)
- if f is None:
- path = m.__path__
- except ImportError:
- return
- finally:
- sys.path = oldsyspath
+ sys.path = []
+ for p in path:
+ site.addsitedir(p)
+ sys.path.extend(oldsyspath)
+ try:
+ __import__(module)
+ except ImportError:
+ return
+ finally:
+ sys.path = oldsyspath
class PythonJob(Job):
"""
A job that calls a Python method.
"""
def __init__(self, module, method, argv, env, cwd, pycommandpath=None):
self.module = module
self.method = method