Reputation: 3929
How can I configure Elpy to use dev dependencies like Black, Jedi, and flake8 that are installed in a Poetry project virtual environment rather than those that are installed systemwide?
Upvotes: 5
Views: 2889
Reputation: 3929
Use the poetry.el
Emacs package with poetry-tracking-mode
enabled by add-hook
ing it to elpy-mode-hook
. Elpy will automatically detect the Poetry virtual environment and check for those dev tools in that environment.
Jan 2021 update: I've since stopped using Elpy and switched to lsp-mode
and lsp-python-ms
- it's a far better development experience. The only caveat is that it can only discover virtualenvs local to the project, so Poetry has to be configured to create venvs locally (poetry config virtualenvs.in-project true
).
Upvotes: 4
Reputation: 21
If you use emacs -nw
, then another option is
poetry add -D virtualenvwrapper
.M-x elpy-config' to find dependencies. So
poetry add -D jedi rope autopep8 yapf black flake8`. This can also be done when elpy prompts you, but then it will probably install as a normal dependency and not just dev dependency.(setq elpy-rpc-virtualenv-path 'current)
so that elpy uses the poetry virtual env for Virtualenv, Interactive Python, RPC virtual env.poetry run emacs -nw
You need to do this for each poetry project. There should be way to install some of these globally in pyenv and have poetry and the project virtual env pick it up. However, doing it for each project keeps dependencies isolated, even for dev stuff.
Upvotes: 0