find_python_environments -> find_system_environments

This commit is contained in:
Dave Halter
2018-04-14 15:46:16 +02:00
parent 45fb770033
commit 336087fcf8
5 changed files with 15 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ from functools import partial
import pytest
import jedi
from jedi.api.environment import get_default_environment, get_python_environment
from jedi.api.environment import get_default_environment, get_system_environment
from jedi._compatibility import py_version
collect_ignore = [
@@ -94,7 +94,7 @@ def environment(request):
if int(version) == py_version:
return get_default_environment()
return get_python_environment('python%s.%s' % tuple(version))
return get_system_environment('python%s.%s' % tuple(version))
@pytest.fixture(scope='session')

View File

@@ -41,7 +41,7 @@ __version__ = '0.12.0'
from jedi.api import Script, Interpreter, set_debug_function, \
preload_module, names
from jedi import settings
from jedi.api.environment import find_virtualenvs, find_python_environments, \
from jedi.api.environment import find_virtualenvs, find_system_environments, \
get_default_environment, InvalidPythonEnvironment, create_environment, \
get_python_environment
get_system_environment
from jedi.api.exceptions import InternalError

View File

@@ -153,7 +153,7 @@ def get_default_environment():
if virtual_env is not None:
return virtual_env
for environment in find_python_environments():
for environment in find_system_environments():
return environment
# If no Python Environment is found, use the environment we're already
@@ -207,7 +207,7 @@ def find_virtualenvs(paths=None, **kwargs):
return py27_comp(paths, **kwargs)
def find_python_environments():
def find_system_environments():
"""
Ignores virtualenvs and returns the Python versions that were installed on
your system. This might return nothing, if you're running Python e.g. from
@@ -217,7 +217,7 @@ def find_python_environments():
"""
for version_string in _SUPPORTED_PYTHONS:
try:
yield get_python_environment('python' + version_string)
yield get_system_environment('python' + version_string)
except InvalidPythonEnvironment:
pass
@@ -241,7 +241,7 @@ def _get_python_prefix(executable):
# TODO: this function should probably return a list of environments since
# multiple Python installations can be found on a system for the same version.
def get_python_environment(name):
def get_system_environment(name):
"""
Return the first Python environment found for a given path or for a string
of the form 'pythonX.Y' where X and Y are the major and minor versions of
@@ -328,7 +328,7 @@ def _is_safe(executable_path):
# Just check the list of known Python versions. If it's not in there,
# it's likely an attacker or some Python that was not properly
# installed in the system.
for environment in find_python_environments():
for environment in find_system_environments():
if environment.executable == real_path:
return True

View File

@@ -125,7 +125,7 @@ from jedi._compatibility import unicode, is_py3
from jedi.api.classes import Definition
from jedi.api.completion import get_user_scope
from jedi import parser_utils
from jedi.api.environment import get_default_environment, get_python_environment
from jedi.api.environment import get_default_environment, get_system_environment
TEST_COMPLETIONS = 0
@@ -435,7 +435,7 @@ if __name__ == '__main__':
return 1
if arguments['--env']:
environment = get_python_environment('python' + arguments['--env'])
environment = get_system_environment('python' + arguments['--env'])
else:
# Will be 3.6.
environment = get_default_environment()

View File

@@ -6,15 +6,15 @@ import pytest
import jedi
from jedi._compatibility import py_version
from jedi.api.environment import get_default_environment, find_virtualenvs, \
InvalidPythonEnvironment, find_python_environments, get_python_environment
InvalidPythonEnvironment, find_system_environments, get_system_environment
def test_sys_path():
assert get_default_environment().get_sys_path()
def test_find_python_environments():
envs = list(find_python_environments())
def test_find_system_environments():
envs = list(find_system_environments())
assert len(envs)
for env in envs:
assert env.version_info
@@ -29,7 +29,7 @@ def test_find_python_environments():
)
def test_versions(version):
try:
env = get_python_environment('python' + version)
env = get_system_environment('python' + version)
except InvalidPythonEnvironment:
if int(version.replace('.', '')) == py_version:
# At least the current version has to work