diff --git a/epylint.py b/epylint.py index 24baa61e9..13449b2e4 100755 --- a/epylint.py +++ b/epylint.py @@ -83,7 +83,18 @@ def lint(filename, options=None): options = options or ['--disable=C,R,I'] cmd = [sys.executable, lint_path] + options + ['--msg-template', '{path}:{line}: [{symbol}, {obj}] {msg}', '-r', 'n', child_path] - process = Popen(cmd, stdout=PIPE, cwd=parent_path, universal_newlines=True) + # Extracts the environment PYTHONPATH and appends the current sys.path to + # those. + env = dict(os.environ) + pythonpath = env.get('PYTHONPATH', '') + currentpaths = os.pathsep.join(sys.path) + if pythonpath: + pythonpath += os.pathsep + currentpaths + else: + pythonpath = currentpaths + env['PYTHONPATH'] = pythonpath + process = Popen(cmd, stdout=PIPE, cwd=parent_path, env=env, + universal_newlines=True) # The parseable line format is '%(path)s:%(line)s: [%(sigle)s%(obj)s] %(msg)s' # NOTE: This would be cleaner if we added an Emacs reporter to pylint.reporters.text .. @@ -157,9 +168,20 @@ def py_run(command_options='', return_std=False, stdout=None, stderr=None, stderr = PIPE else: stderr = sys.stderr + # Extracts the environment PYTHONPATH and appends the current sys.path to + # those. + env = dict(os.environ) + pythonpath = env.get('PYTHONPATH', '') + currentpaths = os.pathsep.join(sys.path) + if pythonpath: + pythonpath += os.pathsep + currentpaths + else: + pythonpath = currentpaths + env['PYTHONPATH'] = pythonpath + # Call pylint in a subprocess p = Popen(command_line, shell=True, stdout=stdout, stderr=stderr, - universal_newlines=True) + env=env, universal_newlines=True) p.wait() # Return standart output and error if return_std: @@ -179,4 +201,3 @@ def Run(): if __name__ == '__main__': Run() -