def find_python_script(python_path, script):
"""Return the path to the given script, or None if not found."""
if sublime.platform() in ('osx', 'linux'):
pyenv = which('pyenv')
if pyenv:
out = run_shell_cmd((os.environ['SHELL'], '-l', '-c',
'echo ""; {} which {}'.format(pyenv, script))).strip().decode().split('\n')[-1]
if os.path.isfile(out):
return out
return which(script)
else:
# On Windows, scripts may be .exe files or .py files in <python directory>/Scripts
scripts_path = os.path.join(os.path.dirname(python_path), 'Scripts')
script_path = os.path.join(scripts_path, script + '.exe')
if os.path.exists(script_path):
return script_path
script_path = os.path.join(scripts_path, script + '-script.py')
if os.path.exists(script_path):
return script_path
return None
评论列表
文章目录