doomemacs/modules/lang/python/autoload/conda.el
Henrik Lissner 560d16d651
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
2018-07-31 15:51:25 +02:00

44 lines
2 KiB
EmacsLisp

;;; lang/python/autoload/conda.el -*- lexical-binding: t; -*-
;;;###if (featurep! +conda)
;;;###autoload
(defun +python/set-conda-home ()
"Set `conda-anaconda-home' (ANACONDA_HOME).
Usually it's `~/.anaconda3' on local machine, but it can be set to a remote
directory using TRAMP syntax, e.g. `/ssh:host:/usr/bin/anaconda3'. This way, you
can use a remote conda environment, including the corresponding remote python
executable and packages."
(interactive)
(require 'conda)
(when-let* ((home (read-directory-name "Set conda home: " "~" nil nil conda-anaconda-home)))
(setq conda-anaconda-home home)
(message "Successfully changed conda home to: %s" (abbreviate-file-name home))))
;;;###autoload
(defun +python-conda-env ()
"Add conda environment string to the major mode modeline segment."
(when conda-env-current-name
(format "conda:%s" conda-env-current-name)))
;;;###autoload
(defun +python*anaconda-mode-bootstrap-in-remote-environments (&optional callback)
"Advice to set up the anaconda-mode even in remote environment.
Original doc:
Run `anaconda-mode' server.
CALLBACK function will be called when `anaconda-mode-port' will
be bound."
(setq anaconda-mode-process
(start-pythonic :process anaconda-mode-process-name
:buffer anaconda-mode-process-buffer
:cwd (anaconda-mode-server-directory)
:filter (lambda (process output) (anaconda-mode-bootstrap-filter process output))
:sentinel 'anaconda-mode-bootstrap-sentinel
:query-on-exit nil
:args (list "-c"
anaconda-mode-server-command
(if (pythonic-remote-p)
"0.0.0.0" "127.0.0.1")
(or (pythonic-file-name pythonic-environment) ""))))
(process-put anaconda-mode-process 'server-directory (anaconda-mode-server-directory)))