paetzke / py-yapf.el

Use yapf to beautify a Python buffer
GNU General Public License v3.0
40 stars 12 forks source link

Auto install yapf in a virtualenv? #10

Open PythonNut opened 8 years ago

PythonNut commented 8 years ago

In general, it would be really cool if py-yapf could install yapf automatically on demand.

We could limit the side-effects of this operations by executing it in a virtual environment. This is a common strategy for packages like jedi, anaconda-mode and others. See the way anaconda-mode does it here.

ncouture commented 1 month ago

Hey @PythonNut, this sounds like a great idea for which we also have, I believe, a more complex implementation of in the anaconda-mode as you linked to in your initial issue description.

I for one (being an Elpy user) feel like the process of installing dependencies in each project is tedious and I would rather have this automated in the first place than doing it manually every time (though I may be missing something trivial -- do let me know if I'm doing this wrong 🐍)

I believe you want a similar function to the one your linked to that will install dependencies only after validating if they are already installed and perhaps up to date as it will behaves as a hook and possibly loaded and so executed upon loading python-mode.

(defvar py-yapf-mode-install-yapf-script "
import sys
import pip
directory = sys.argv[-2]
version = sys.argv[-1]
pip.main(['install', '-t', directory, 'yapf==' + version])
" "Install `yapf'.")