Function: python-shell-package-enable
python-shell-package-enable is an interactive and byte-compiled
function defined in python.el.gz.
Signature
(python-shell-package-enable DIRECTORY PACKAGE)
Documentation
Add DIRECTORY parent to $PYTHONPATH and enable PACKAGE.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defun python-shell-package-enable (directory package)
"Add DIRECTORY parent to $PYTHONPATH and enable PACKAGE."
(interactive
(let* ((dir (expand-file-name
(read-directory-name
"Package root: "
(file-name-directory
(or (buffer-file-name) default-directory)))))
(name (completing-read
"Package: "
(python-util-list-packages
dir python-shell--package-depth))))
(list dir name)))
(python-shell-send-string
(format
(concat
"import os.path;import sys;"
"sys.path.append(os.path.dirname(os.path.dirname(%s)));"
"__package__ = %s;"
"import %s")
(python-shell--encode-string directory)
(python-shell--encode-string package)
package)
(python-shell-get-process)))