aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorSam Steingold2014-08-20 11:33:10 -0400
committerSam Steingold2014-08-20 11:33:10 -0400
commit3f05baa175c2cc9d3e0ae6865dc974d102036d12 (patch)
treeb003c990b42425d803a4b035c2f2fdf4d03710de /lisp/progmodes/python.el
parenta558cd1cc4031e811a8b0af951095d3042ca06d0 (diff)
downloademacs-3f05baa175c2cc9d3e0ae6865dc974d102036d12.tar.gz
emacs-3f05baa175c2cc9d3e0ae6865dc974d102036d12.zip
Extract python-new-pythonpath to handle PYTHONPATH in user code
* lisp/progmodes/python.el (python-new-pythonpath): Extract from `python-shell-calculate-process-environment'.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el18
1 files changed, 11 insertions, 7 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 4ed24a4a4c6..4f645ad64c8 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2069,6 +2069,16 @@ uniqueness for different types of configurations."
2069 (executable-find python-shell-interpreter) 2069 (executable-find python-shell-interpreter)
2070 python-shell-interpreter-args))) 2070 python-shell-interpreter-args)))
2071 2071
2072(defun python-new-pythonpath ()
2073 "Calculate the new PYTHONPATH value from `python-shell-extra-pythonpaths'."
2074 (let ((pythonpath (getenv "PYTHONPATH"))
2075 (extra (mapconcat 'identity
2076 python-shell-extra-pythonpaths
2077 path-separator)))
2078 (if pythonpath
2079 (concat extra path-separator pythonpath)
2080 extra)))
2081
2072(defun python-shell-calculate-process-environment () 2082(defun python-shell-calculate-process-environment ()
2073 "Calculate process environment given `python-shell-virtualenv-path'." 2083 "Calculate process environment given `python-shell-virtualenv-path'."
2074 (let ((process-environment (append 2084 (let ((process-environment (append
@@ -2078,13 +2088,7 @@ uniqueness for different types of configurations."
2078 (directory-file-name python-shell-virtualenv-path) 2088 (directory-file-name python-shell-virtualenv-path)
2079 nil))) 2089 nil)))
2080 (when python-shell-extra-pythonpaths 2090 (when python-shell-extra-pythonpaths
2081 (setenv "PYTHONPATH" 2091 (setenv "PYTHONPATH" (python-new-pythonpath)))
2082 (format "%s%s%s"
2083 (mapconcat 'identity
2084 python-shell-extra-pythonpaths
2085 path-separator)
2086 path-separator
2087 (or (getenv "PYTHONPATH") ""))))
2088 (if (not virtualenv) 2092 (if (not virtualenv)
2089 process-environment 2093 process-environment
2090 (setenv "PYTHONHOME" nil) 2094 (setenv "PYTHONHOME" nil)