|  | 
| 34 | 34 | 
 | 
| 35 | 35 | (defconst python-environment-version "0.0.0") | 
| 36 | 36 | 
 | 
| 37 |  | -(defcustom python-environment-root | 
| 38 |  | - (locate-user-emacs-file "python-environment") | 
| 39 |  | - "Path to default Python virtual environment." | 
|  | 37 | +(defcustom python-environment-directory | 
|  | 38 | + (locate-user-emacs-file "python-environments") | 
|  | 39 | + "Path to directory to store all Python virtual environments" | 
|  | 40 | + :group 'python-environment) | 
|  | 41 | + | 
|  | 42 | +(defcustom python-environment-default-root-name "default" | 
|  | 43 | + "Default Python virtual environment name. | 
|  | 44 | +This is a name of directory relative to `python-environment-directory'. | 
|  | 45 | +Thus, typically the default virtual environment path is | 
|  | 46 | +``~/.emacs.d/python-environments/default``." | 
| 40 | 47 |  :group 'python-environment) | 
| 41 | 48 | 
 | 
| 42 | 49 | (defcustom python-environment-virtualenv | 
|  | 
| 74 | 81 |  (unless (= exit-code 0) | 
| 75 | 82 |  (error "Command %S exits with error code %S." command exit-code)))) | 
| 76 | 83 | 
 | 
|  | 84 | + | 
|  | 85 | +(defun python-environment-root-path (&optional root) | 
|  | 86 | + (expand-file-name (or root python-environment-default-root-name) | 
|  | 87 | + python-environment-directory)) | 
|  | 88 | + | 
| 77 | 89 | (defun python-environment--make-with-runner (proc-runner root virtualenv) | 
| 78 |  | - (let ((path (convert-standard-filename (expand-file-name | 
| 79 |  | -  (or root python-environment-root)))) | 
|  | 90 | + (let ((path (convert-standard-filename | 
|  | 91 | + (python-environment-root-path root))) | 
| 80 | 92 |  (virtualenv (or virtualenv python-environment-virtualenv))) | 
| 81 | 93 |  (unless (executable-find (car virtualenv)) | 
| 82 | 94 |  (error "Program named %S does not exist." (car virtualenv))) | 
| @@ -108,7 +120,7 @@ For reason, see `python-environment-run-block'" | 
| 108 | 120 | (defun python-environment--existing (root &rest paths) | 
| 109 | 121 |  (when paths | 
| 110 | 122 |  (let ((full-path (expand-file-name (car paths) | 
| 111 |  | - (or root python-environment-root)))) | 
|  | 123 | + (python-environment-root-path root)))) | 
| 112 | 124 |  (if (file-exists-p full-path) | 
| 113 | 125 |  full-path | 
| 114 | 126 |  (python-environment--existing (cdr paths)))))) | 
| @@ -147,7 +159,7 @@ For reason, see `python-environment-run-block'" | 
| 147 | 159 |  "Run COMMAND installed in Python virtualenv located at ROOT | 
| 148 | 160 | asynchronously and return a deferred object. | 
| 149 | 161 | If ROOT is not specified, shared virtual environment specified by | 
| 150 |  | -`python-environment-root' is used. | 
|  | 162 | +`python-environment-default-root-name' is used. | 
| 151 | 163 | If VIRTUALENV (list of string) is specified, it is used instead of | 
| 152 | 164 | `python-environment-virtualenv'. | 
| 153 | 165 | 
 | 
|  | 
0 commit comments