Python libraries

From WikEmacs
Revision as of 14:58, 4 May 2017 by Elvince (talk | contribs) (easy install and use of python packages in their venv)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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


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.