Function: python-shell--calculate-process-environment

python-shell--calculate-process-environment is a byte-compiled function defined in python.el.gz.

Signature

(python-shell--calculate-process-environment)

Documentation

Return a list of entries to add to the process-environment.

Prepends python-shell-process-environment, sets extra pythonpaths from python-shell-extra-pythonpaths and sets a few virtualenv related vars.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell--calculate-process-environment ()
  "Return a list of entries to add to the `process-environment'.
Prepends `python-shell-process-environment', sets extra
pythonpaths from `python-shell-extra-pythonpaths' and sets a few
virtualenv related vars."
  (let* ((virtualenv (when python-shell-virtualenv-root
                       (directory-file-name python-shell-virtualenv-root)))
         (res python-shell-process-environment))
    (push "PYTHON_BASIC_REPL=1" res)
    (when python-shell-unbuffered
      (push "PYTHONUNBUFFERED=1" res))
    (when python-shell-extra-pythonpaths
      (push (concat "PYTHONPATH=" (python-shell-calculate-pythonpath)) res))
    (if (not virtualenv)
        nil
      (push "PYTHONHOME" res)
      (push (concat "VIRTUAL_ENV=" virtualenv) res))
    res))