Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion on non-global python module in virtualenv #316

Open
nrsaty opened this issue Sep 5, 2018 · 1 comment
Open

Completion on non-global python module in virtualenv #316

nrsaty opened this issue Sep 5, 2018 · 1 comment

Comments

@nrsaty
Copy link

nrsaty commented Sep 5, 2018

I setup my emacs for specific python virtual environment, named ahone. But jediepcserver
can not complete that environment's module name.

I use emacs 26.09 and python 3.6.5 on Windows/10. My configuration is:

(setq jedi:environment-root         "~/.emacs.d/site-lisp/jedi/env")
(setq jedi:complete-on-dot t)
(setq jedi:use-shortcuts nil)
(setq jedi:server-args `("--virtual-env" "~/ahone/Lib/site-packages"
      		                     "--sys-path"    "~/ahone"))
(require 'jedi-core)
(require 'company-jedi)
(setq python-shell-interpreter      "ipython")
(setq python-shell-interpreter-args "--simple-prompt -i")
(setq python-indent-offset          2)
(setq python-indent-guess-indent-offset nil)
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook
          (lambda ()
            (set (make-local-variable 'company-backends)
                 '((company-jedi company-dabbrev-code company-yasnippet)))))

I did not activate ahone environment before starting emacs. But only specified the
environment in --virtual-env parameter of jdeiepcserver as above. It's seems that this
way is not good for specify python's virtual environment. Does anyone show me the
correct way?

By the way, I glanced at codes, and found jedi.api.Script class has sys_path parameter
in init(). Why jediepcserver did not use this? I'm not expert, and not sure that
jedi module can handle this option correctly. But according to the comment, use this
option is easy way to use with virtualenv, I feel.

In jediepcserver.py

    def jedi_script(source, line, column, source_path):
     	:
        return jedi.Script(source, line, column, source_path or '')

will be something like this

    def jedi_script(source, line, column, source_path):
     	:
        if (< Is jediepcserver has --virtual-env option? >) :
            return jedi.Script(source, line, column, source_path or ''
                               'utf-8' <current sys.path of jediepcserver>)
        else:
            return jedi.Script(source, line, column, source_path or '')

Does I misunderstand something?

@immerrr
Copy link
Collaborator

immerrr commented Oct 23, 2018

@nrsaty please try expanding tildes, they have no special meaning in how jedi or emacs-jedi treat file paths (expand-file-name is the elisp function if I read my configurations correctly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants