{"action":"created","comment":{"url":"https://api.github.com/repos/davidhalter/jedi/pulls/comments/29482416","id":29482416,"diff_hunk":"@@ -108,7 +110,11 @@ def __init__(self, source=None, line=None, column=None, path=None,\n         self._user_context = UserContext(self.source, self._pos)\n         self._parser = UserContextParser(self._grammar, self.source, path,\n                                          self._pos, self._user_context)\n-        self._evaluator = Evaluator(self._grammar)\n+        if sys_path is None:\n+            venv = os.getenv('VIRTUAL_ENV')\n+            if venv:\n+                sys_path = list(get_venv_path(venv)) + sys.path","path":"jedi/api/__init__.py","position":26,"original_position":26,"commit_id":"e26583bf6a153e84db7b9c7036bc00149a7f262f","original_commit_id":"c0ea4379dac1f7b1789163636046c629c32dff4f","user":{"login":"davidhalter","id":748594,"avatar_url":"https://avatars.githubusercontent.com/u/748594?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhalter","html_url":"https://github.com/davidhalter","followers_url":"https://api.github.com/users/davidhalter/followers","following_url":"https://api.github.com/users/davidhalter/following{/other_user}","gists_url":"https://api.github.com/users/davidhalter/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhalter/subscriptions","organizations_url":"https://api.github.com/users/davidhalter/orgs","repos_url":"https://api.github.com/users/davidhalter/repos","events_url":"https://api.github.com/users/davidhalter/events{/privacy}","received_events_url":"https://api.github.com/users/davidhalter/received_events","type":"User","site_admin":false},"body":"However that `VIRTUAL_ENV` variable will not change, just because you're activating a virtualenv. So this logic effectively doesn't do anything else than loading the same `sys.path`?!\r\n\r\nOr are you thinking about changing the environment variable before each Jedi Script invocation? In that case I would rather add another parameter to Script.","created_at":"2015-05-01T00:13:49Z","updated_at":"2015-05-01T00:13:49Z","html_url":"https://github.com/davidhalter/jedi/pull/562#discussion_r29482416","pull_request_url":"https://api.github.com/repos/davidhalter/jedi/pulls/562","_links":{"self":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/comments/29482416"},"html":{"href":"https://github.com/davidhalter/jedi/pull/562#discussion_r29482416"},"pull_request":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/562"}}},"pull_request":{"url":"https://api.github.com/repos/davidhalter/jedi/pulls/562","id":32647022,"html_url":"https://github.com/davidhalter/jedi/pull/562","diff_url":"https://github.com/davidhalter/jedi/pull/562.diff","patch_url":"https://github.com/davidhalter/jedi/pull/562.patch","issue_url":"https://api.github.com/repos/davidhalter/jedi/issues/562","number":562,"state":"open","locked":false,"title":"Improve virtualenv support & egg-link resolution","user":{"login":"immerrr","id":579798,"avatar_url":"https://avatars.githubusercontent.com/u/579798?v=3","gravatar_id":"","url":"https://api.github.com/users/immerrr","html_url":"https://github.com/immerrr","followers_url":"https://api.github.com/users/immerrr/followers","following_url":"https://api.github.com/users/immerrr/following{/other_user}","gists_url":"https://api.github.com/users/immerrr/gists{/gist_id}","starred_url":"https://api.github.com/users/immerrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/immerrr/subscriptions","organizations_url":"https://api.github.com/users/immerrr/orgs","repos_url":"https://api.github.com/users/immerrr/repos","events_url":"https://api.github.com/users/immerrr/events{/privacy}","received_events_url":"https://api.github.com/users/immerrr/received_events","type":"User","site_admin":false},"body":"AFAIU, it is generally considered ok to mix jedi's own sys.path and virtualenv paths, but recently I have run into a conflict between setuptools/distribute found in:\r\n- jedi's virtualenv\r\n- user site directory (`$HOME/.local/lib/pythonX.X/site-packages`)\r\n- virtualenv I was actually using\r\n\r\nThis conflict caused problems in resolving something as simple as `setuptools.setup` and made me rethink module resolution towards \"purity\". \r\n\r\nThis PR adds the following:\r\n- add sys_path= kwarg to Script & Evaluator constructors\r\n- store sys_path for each evaluator instance (closes #384)\r\n- add get_venv_path(venv) function to determine virtualenv's path:\r\n  - by default, dump path from live python interpreter\r\n  - use old path extension variant for fallback\r\n  - in old variant, use addsitedir to load .pth extension files (closes #443)\r\n- look for egg-link files in all directories in path\r\n\r\nSeveral discussion questions here:\r\n- starting python interpreter from the virtualenv is the most precise way to know its sys.path, but are there drawbacks besides process startup overhead? e.g. should we clean `PYTHONSTARTUP` env var?\r\n- if running python interpreter is ok, how do we test it? \r\n- as path resolution grows more and more heavy (.pth, egg-links, now subprocesses), do we need to cache it somehow? and for a long-running jedi process, like ycmd, how do we flush the cache to reflect package installation/removal.\r\n- is there a use case for removing `site.USER_SITE` from lookups, too?","created_at":"2015-04-05T10:36:41Z","updated_at":"2015-05-01T00:13:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4217105ba57a77fcd1d80b2433fb447cd67d80aa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/davidhalter/jedi/pulls/562/commits","review_comments_url":"https://api.github.com/repos/davidhalter/jedi/pulls/562/comments","review_comment_url":"https://api.github.com/repos/davidhalter/jedi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/davidhalter/jedi/issues/562/comments","statuses_url":"https://api.github.com/repos/davidhalter/jedi/statuses/e26583bf6a153e84db7b9c7036bc00149a7f262f","head":{"label":"immerrr:virtualenv-per-evaluator","ref":"virtualenv-per-evaluator","sha":"e26583bf6a153e84db7b9c7036bc00149a7f262f","user":{"login":"immerrr","id":579798,"avatar_url":"https://avatars.githubusercontent.com/u/579798?v=3","gravatar_id":"","url":"https://api.github.com/users/immerrr","html_url":"https://github.com/immerrr","followers_url":"https://api.github.com/users/immerrr/followers","following_url":"https://api.github.com/users/immerrr/following{/other_user}","gists_url":"https://api.github.com/users/immerrr/gists{/gist_id}","starred_url":"https://api.github.com/users/immerrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/immerrr/subscriptions","organizations_url":"https://api.github.com/users/immerrr/orgs","repos_url":"https://api.github.com/users/immerrr/repos","events_url":"https://api.github.com/users/immerrr/events{/privacy}","received_events_url":"https://api.github.com/users/immerrr/received_events","type":"User","site_admin":false},"repo":{"id":22290617,"name":"jedi","full_name":"immerrr/jedi","owner":{"login":"immerrr","id":579798,"avatar_url":"https://avatars.githubusercontent.com/u/579798?v=3","gravatar_id":"","url":"https://api.github.com/users/immerrr","html_url":"https://github.com/immerrr","followers_url":"https://api.github.com/users/immerrr/followers","following_url":"https://api.github.com/users/immerrr/following{/other_user}","gists_url":"https://api.github.com/users/immerrr/gists{/gist_id}","starred_url":"https://api.github.com/users/immerrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/immerrr/subscriptions","organizations_url":"https://api.github.com/users/immerrr/orgs","repos_url":"https://api.github.com/users/immerrr/repos","events_url":"https://api.github.com/users/immerrr/events{/privacy}","received_events_url":"https://api.github.com/users/immerrr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/immerrr/jedi","description":"Awesome autocompletion library for python.","fork":true,"url":"https://api.github.com/repos/immerrr/jedi","forks_url":"https://api.github.com/repos/immerrr/jedi/forks","keys_url":"https://api.github.com/repos/immerrr/jedi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/immerrr/jedi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/immerrr/jedi/teams","hooks_url":"https://api.github.com/repos/immerrr/jedi/hooks","issue_events_url":"https://api.github.com/repos/immerrr/jedi/issues/events{/number}","events_url":"https://api.github.com/repos/immerrr/jedi/events","assignees_url":"https://api.github.com/repos/immerrr/jedi/assignees{/user}","branches_url":"https://api.github.com/repos/immerrr/jedi/branches{/branch}","tags_url":"https://api.github.com/repos/immerrr/jedi/tags","blobs_url":"https://api.github.com/repos/immerrr/jedi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/immerrr/jedi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/immerrr/jedi/git/refs{/sha}","trees_url":"https://api.github.com/repos/immerrr/jedi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/immerrr/jedi/statuses/{sha}","languages_url":"https://api.github.com/repos/immerrr/jedi/languages","stargazers_url":"https://api.github.com/repos/immerrr/jedi/stargazers","contributors_url":"https://api.github.com/repos/immerrr/jedi/contributors","subscribers_url":"https://api.github.com/repos/immerrr/jedi/subscribers","subscription_url":"https://api.github.com/repos/immerrr/jedi/subscription","commits_url":"https://api.github.com/repos/immerrr/jedi/commits{/sha}","git_commits_url":"https://api.github.com/repos/immerrr/jedi/git/commits{/sha}","comments_url":"https://api.github.com/repos/immerrr/jedi/comments{/number}","issue_comment_url":"https://api.github.com/repos/immerrr/jedi/issues/comments{/number}","contents_url":"https://api.github.com/repos/immerrr/jedi/contents/{+path}","compare_url":"https://api.github.com/repos/immerrr/jedi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/immerrr/jedi/merges","archive_url":"https://api.github.com/repos/immerrr/jedi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/immerrr/jedi/downloads","issues_url":"https://api.github.com/repos/immerrr/jedi/issues{/number}","pulls_url":"https://api.github.com/repos/immerrr/jedi/pulls{/number}","milestones_url":"https://api.github.com/repos/immerrr/jedi/milestones{/number}","notifications_url":"https://api.github.com/repos/immerrr/jedi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/immerrr/jedi/labels{/name}","releases_url":"https://api.github.com/repos/immerrr/jedi/releases{/id}","created_at":"2014-07-26T16:14:32Z","updated_at":"2014-07-26T09:29:34Z","pushed_at":"2015-04-08T17:48:17Z","git_url":"git://github.com/immerrr/jedi.git","ssh_url":"git@github.com:immerrr/jedi.git","clone_url":"https://github.com/immerrr/jedi.git","svn_url":"https://github.com/immerrr/jedi","homepage":"http://jedi.jedidjah.ch/","size":7194,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"davidhalter:dev","ref":"dev","sha":"4bb41b609648767b7e489a457bcd25b84d43067a","user":{"login":"davidhalter","id":748594,"avatar_url":"https://avatars.githubusercontent.com/u/748594?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhalter","html_url":"https://github.com/davidhalter","followers_url":"https://api.github.com/users/davidhalter/followers","following_url":"https://api.github.com/users/davidhalter/following{/other_user}","gists_url":"https://api.github.com/users/davidhalter/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhalter/subscriptions","organizations_url":"https://api.github.com/users/davidhalter/orgs","repos_url":"https://api.github.com/users/davidhalter/repos","events_url":"https://api.github.com/users/davidhalter/events{/privacy}","received_events_url":"https://api.github.com/users/davidhalter/received_events","type":"User","site_admin":false},"repo":{"id":3489194,"name":"jedi","full_name":"davidhalter/jedi","owner":{"login":"davidhalter","id":748594,"avatar_url":"https://avatars.githubusercontent.com/u/748594?v=3","gravatar_id":"","url":"https://api.github.com/users/davidhalter","html_url":"https://github.com/davidhalter","followers_url":"https://api.github.com/users/davidhalter/followers","following_url":"https://api.github.com/users/davidhalter/following{/other_user}","gists_url":"https://api.github.com/users/davidhalter/gists{/gist_id}","starred_url":"https://api.github.com/users/davidhalter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidhalter/subscriptions","organizations_url":"https://api.github.com/users/davidhalter/orgs","repos_url":"https://api.github.com/users/davidhalter/repos","events_url":"https://api.github.com/users/davidhalter/events{/privacy}","received_events_url":"https://api.github.com/users/davidhalter/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/davidhalter/jedi","description":"Awesome autocompletion and static analysis library for python.","fork":false,"url":"https://api.github.com/repos/davidhalter/jedi","forks_url":"https://api.github.com/repos/davidhalter/jedi/forks","keys_url":"https://api.github.com/repos/davidhalter/jedi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/davidhalter/jedi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/davidhalter/jedi/teams","hooks_url":"https://api.github.com/repos/davidhalter/jedi/hooks","issue_events_url":"https://api.github.com/repos/davidhalter/jedi/issues/events{/number}","events_url":"https://api.github.com/repos/davidhalter/jedi/events","assignees_url":"https://api.github.com/repos/davidhalter/jedi/assignees{/user}","branches_url":"https://api.github.com/repos/davidhalter/jedi/branches{/branch}","tags_url":"https://api.github.com/repos/davidhalter/jedi/tags","blobs_url":"https://api.github.com/repos/davidhalter/jedi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/davidhalter/jedi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/davidhalter/jedi/git/refs{/sha}","trees_url":"https://api.github.com/repos/davidhalter/jedi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/davidhalter/jedi/statuses/{sha}","languages_url":"https://api.github.com/repos/davidhalter/jedi/languages","stargazers_url":"https://api.github.com/repos/davidhalter/jedi/stargazers","contributors_url":"https://api.github.com/repos/davidhalter/jedi/contributors","subscribers_url":"https://api.github.com/repos/davidhalter/jedi/subscribers","subscription_url":"https://api.github.com/repos/davidhalter/jedi/subscription","commits_url":"https://api.github.com/repos/davidhalter/jedi/commits{/sha}","git_commits_url":"https://api.github.com/repos/davidhalter/jedi/git/commits{/sha}","comments_url":"https://api.github.com/repos/davidhalter/jedi/comments{/number}","issue_comment_url":"https://api.github.com/repos/davidhalter/jedi/issues/comments{/number}","contents_url":"https://api.github.com/repos/davidhalter/jedi/contents/{+path}","compare_url":"https://api.github.com/repos/davidhalter/jedi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/davidhalter/jedi/merges","archive_url":"https://api.github.com/repos/davidhalter/jedi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/davidhalter/jedi/downloads","issues_url":"https://api.github.com/repos/davidhalter/jedi/issues{/number}","pulls_url":"https://api.github.com/repos/davidhalter/jedi/pulls{/number}","milestones_url":"https://api.github.com/repos/davidhalter/jedi/milestones{/number}","notifications_url":"https://api.github.com/repos/davidhalter/jedi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/davidhalter/jedi/labels{/name}","releases_url":"https://api.github.com/repos/davidhalter/jedi/releases{/id}","created_at":"2012-02-19T23:12:30Z","updated_at":"2015-04-30T09:21:47Z","pushed_at":"2015-04-28T16:59:02Z","git_url":"git://github.com/davidhalter/jedi.git","ssh_url":"git@github.com:davidhalter/jedi.git","clone_url":"https://github.com/davidhalter/jedi.git","svn_url":"https://github.com/davidhalter/jedi","homepage":"http://jedi.jedidjah.ch/","size":10142,"stargazers_count":1500,"watchers_count":1500,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":111,"mirror_url":null,"open_issues_count":70,"forks":111,"open_issues":70,"watchers":1500,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/562"},"html":{"href":"https://github.com/davidhalter/jedi/pull/562"},"issue":{"href":"https://api.github.com/repos/davidhalter/jedi/issues/562"},"comments":{"href":"https://api.github.com/repos/davidhalter/jedi/issues/562/comments"},"review_comments":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/562/comments"},"review_comment":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/davidhalter/jedi/pulls/562/commits"},"statuses":{"href":"https://api.github.com/repos/davidhalter/jedi/statuses/e26583bf6a153e84db7b9c7036bc00149a7f262f"}}}}