Skip to content

Instantly share code, notes, and snippets.

Created May 9, 2017
What would you like to do?
Run pylint using first virtualenv named 'env' in a parent directory
# Placed at /usr/local/bin/python
# Expects pylint executable at /usr/bin/pylint
import os
import sys
def get_python_exec():
if len(sys.argv) < 2:
return ""
filepath = sys.argv[1]
dirname = os.path.realpath(os.path.expanduser(filepath))
if not os.path.isdir(dirname):
dirname = os.path.dirname(dirname)
while True:
env_path = os.path.join(dirname, "env", "bin", "python")
if os.path.exists(env_path):
return env_path
old_dirname = dirname
dirname = os.path.dirname(dirname)
if old_dirname == dirname:
return ""
os.system(get_python_exec() + ' /usr/bin/pylint ' + ' '.join(sys.argv[1:]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment