Python libraries

From WikEmacs
Jump to: navigation, search

Here we'll take notes on libraries and best practices on how to write Emacs packages that use Python tools (like Elpy).

Libraries

Install and access pip dependencies in their own virtual env with python-environment

Let's say you write an Emacs plugin which uses Python scripts. Then you would want to setup Python modules for that script easily from Emacs. This is the problem emacs-python-environment solves, an important and recurrent problem in emacs packages using python tools.

For example, Elpy relies on a few python dependencies, found in pypi: jedi, yapf, importmagic, etc. When we install Elpy we must install them too. And where should we do it ? Python's best practices tell us to do so in our virtual env. Fine, but as soon as we switch to another project, we should install them again in this other venv. We could install them globally, but then we need to modify the creation of our virtual envs, that by default do *not* use system-wide packages. We could… well, it's cumbersome. This package solves that.

It's actually simple to use. For an example, see emacs-traad.