mirror of
https://github.com/davidhalter/jedi.git
synced 2026-02-23 21:38:32 +08:00
Improve virtualenv support & egg-link resolution
- add sys_path= kwarg to Script & Evaluator constructors - store sys_path for each evaluator instance - replace get_sys_path with get_venv_path - get_venv_path: use addsitedir to load .pth extension files - get_venv_path: look for egg-link files in all directories in path
This commit is contained in:
@@ -61,6 +61,7 @@ that are not used are just being ignored.
|
||||
"""
|
||||
|
||||
import copy
|
||||
import sys
|
||||
from itertools import chain
|
||||
|
||||
from jedi.parser import tree
|
||||
@@ -79,7 +80,7 @@ from jedi.evaluate import helpers
|
||||
|
||||
|
||||
class Evaluator(object):
|
||||
def __init__(self, grammar):
|
||||
def __init__(self, grammar, sys_path=None):
|
||||
self.grammar = grammar
|
||||
self.memoize_cache = {} # for memoize decorators
|
||||
# To memorize modules -> equals `sys.modules`.
|
||||
@@ -88,6 +89,13 @@ class Evaluator(object):
|
||||
self.recursion_detector = recursion.RecursionDetector()
|
||||
self.execution_recursion_detector = recursion.ExecutionRecursionDetector()
|
||||
self.analysis = []
|
||||
if sys_path is None:
|
||||
sys_path = sys.path
|
||||
self.sys_path = copy.copy(sys_path)
|
||||
try:
|
||||
self.sys_path.remove('')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def wrap(self, element):
|
||||
if isinstance(element, tree.Class):
|
||||
|
||||
Reference in New Issue
Block a user