From 929036b470d1a5924b70cb21b943c3050cbc8b70 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Thu, 17 May 2012 00:03:27 -0300 Subject: [PATCH] Enhancements to `python-shell-calculate-process-environment' The `python-shell-extra-pythonpaths' variable have been introduced as simple way of adding paths to the PYTHONPATH without affecting existing values. --- lisp/progmodes/python.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 28b5eeaa33f..1c05048512a 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -122,6 +122,10 @@ ;; (setq python-shell-virtualenv-path "/path/to/env/") +;; Also the `python-shell-extra-pythonpaths' variable have been +;; introduced as simple way of adding paths to the PYTHONPATH without +;; affecting existing values. + ;; Pdb tracking: when you execute a block of code that contains some ;; call to pdb (or ipdb) it will prompt the block of code and will ;; follow the execution of pdb marking the current line with an arrow. @@ -1146,6 +1150,14 @@ the default `process-environment'." :group 'python :safe 'listp) +(defcustom python-shell-extra-pythonpaths nil + "List of extra pythonpaths for Python shell. +The values of this variable are added to the existing value of +PYTHONPATH in the `process-environment' variable." + :type '(repeat string) + :group 'python + :safe 'listp) + (defcustom python-shell-exec-path nil "List of path to search for binaries. This variable follows the same rules as `exec-path' since it @@ -1237,11 +1249,20 @@ uniqueness for different types of configurations." (virtualenv (if python-shell-virtualenv-path (directory-file-name python-shell-virtualenv-path) nil))) + (when python-shell-extra-pythonpaths + (setenv "PYTHONPATH" + (format "%s%s%s" + (mapconcat 'identity + python-shell-extra-pythonpaths + path-separator) + path-separator + (or (getenv "PYTHONPATH") "")))) (if (not virtualenv) process-environment (setenv "PYTHONHOME" nil) (setenv "PATH" (format "%s/bin%s%s" - virtualenv path-separator (getenv "PATH"))) + virtualenv path-separator + (or (getenv "PATH") ""))) (setenv "VIRTUAL_ENV" virtualenv)) process-environment)) -- 2.39.5