lang/python: add support for more env managers
+ Rewritten +conda support + Adds +pyenv and +pyvenv flags with support. + New +ipython flag to enable ipython REPL support + Added pipenv support. This is the new default, instead of pyenv, and isn't hidden behind a module flag because it is officially endorsed by python. Addresses #736
This commit is contained in:
parent
85af18a04d
commit
560d16d651
5 changed files with 112 additions and 88 deletions
|
@ -5,3 +5,25 @@
|
|||
"Open the Python REPL."
|
||||
(interactive)
|
||||
(process-buffer (run-python nil t t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +python-version ()
|
||||
"Return the currently installed version of python on your system or active in
|
||||
the current pipenv.
|
||||
|
||||
This is not necessarily aware of env management tools like virtualenv, pyenv or
|
||||
pipenv, unless those tools have modified the PATH that Emacs picked up when you
|
||||
started it."
|
||||
(let* ((command (if (pipenv-project-p)
|
||||
"pipenv run python --version"
|
||||
"python --version"))
|
||||
(bin (car (split-string command " "))))
|
||||
(unless (executable-find bin)
|
||||
(user-error "Couldn't find %s executable in PATH" bin))
|
||||
(with-temp-buffer
|
||||
(let ((p (apply #'call-process bin nil (current-buffer) nil
|
||||
(cdr (split-string command " " t))))
|
||||
(output (string-trim (buffer-string))))
|
||||
(unless (zerop p)
|
||||
(user-error "'%s' failed: %s" command output))
|
||||
(nth 1 (split-string output " " t))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue