Skip to content

Commit

Permalink
Check for ensurepip during virtualenv creation
Browse files Browse the repository at this point in the history
  • Loading branch information
galaunay committed Mar 23, 2020
1 parent 1454956 commit 581a40a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions elpy-rpc.el
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,11 @@ binaries used to create the virtualenv."
(kill-buffer elpy-venv-buffname-visible))
(with-elpy-rpc-virtualenv-activated
(cond
((= 0 (call-process elpy-rpc-python-command nil nil nil
"-m" "venv" "-h"))
((and (= 0 (call-process elpy-rpc-python-command nil nil nil
"-m" "venv" "-h"))
;; see https://github.com/jorgenschaefer/elpy/issues/1756
(= 0 (call-process elpy-rpc-python-command nil nil nil
"-m" "ensurepip" "-h")))
(with-current-buffer (get-buffer-create elpy-venv-buffname)
(insert (concat "Running '" elpy-rpc-python-command " -m venv "
rpc-venv-path "':\n\n"))
Expand All @@ -384,7 +387,7 @@ binaries used to create the virtualenv."
(setq success (call-process "virtualenv" nil t t "-p"
elpy-rpc-python-command rpc-venv-path))))
(t
(error "Elpy necessitates the 'virtualenv' python package, please install it with `pip install virtualenv`"))))
(error "Elpy needs the 'virtualenv' or 'venv' python packages to create its virtualenv. Please install one of them or disable the dedicated virtualenv with `(setq elpy-rpc-virtualenv-path 'current)`"))))
;; warn us if something wrong happened
(unless (= 0 success)
(with-current-buffer elpy-venv-buffname
Expand Down

0 comments on commit 581a40a

Please sign in to comment.