summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Vázquez Acosta <mva.led@gmail.com>2014-01-06 15:31:19 -0500
committerManuel Vázquez Acosta <mva.led@gmail.com>2014-01-06 15:31:19 -0500
commit2da336b446b6bf7410527c9a16531a0defb27845 (patch)
tree33f270e4bd564b76a2c3aa9e77a2ec630d46d5bc
parent6560940f32e06d526ff66586f1bf80d7a69bd3c1 (diff)
downloadpylint-git-2da336b446b6bf7410527c9a16531a0defb27845.tar.gz
Injects the current sys.path into `lint.py` subprocess env
This allows installing pylint in a buildout setup and *see* the eggs in the buildout. Since buildout modifies the installed scripts (like epyling) by prepending and assignment to ``sys.path[0:0]`` all the eggs, we need to make sure those path are the ones seen by pylint.
-rwxr-xr-xepylint.py27
1 files changed, 24 insertions, 3 deletions
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()
-