forked from VimPlug/jedi
Replace distutils.spawn.find_executable with shutil.which
The distutils.spawn.find_executable function is not available on stock system Python 3 in recent Debian-based distributions. Since shutil.which is a better alternative but not available on Python 2.7, we include a copy of that function and use it in place of find_executable.
This commit is contained in:
@@ -9,11 +9,8 @@ import hashlib
|
||||
import filecmp
|
||||
from subprocess import PIPE
|
||||
from collections import namedtuple
|
||||
# When dropping Python 2.7 support we should consider switching to
|
||||
# `shutil.which`.
|
||||
from distutils.spawn import find_executable
|
||||
|
||||
from jedi._compatibility import GeneralizedPopen
|
||||
from jedi._compatibility import GeneralizedPopen, which
|
||||
from jedi.cache import memoize_method, time_cache
|
||||
from jedi.evaluate.compiled.subprocess import get_subprocess, \
|
||||
EvaluatorSameProcess, EvaluatorSubprocess
|
||||
@@ -276,7 +273,7 @@ def get_system_environment(version):
|
||||
:raises: :exc:`.InvalidPythonEnvironment`
|
||||
:returns: :class:`Environment`
|
||||
"""
|
||||
exe = find_executable('python' + version)
|
||||
exe = which('python' + version)
|
||||
if exe:
|
||||
if exe == sys.executable:
|
||||
return SameEnvironment()
|
||||
|
||||
Reference in New Issue
Block a user