tkf / emacs-python-environment

Python virtualenv API for Emacs Lisp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RFC: python-environment.el API

tkf opened this issue · comments

I made an Emacs Lisp wrapper for virtualenv to solve problems in emacs-jedi (tkf/emacs-jedi#72). As I think it would be useful for other Python related Emacs packages, I would like to hear some comments if you have some, before fixing the API.

Here is the API. See also the README.

(defcustom python-environment-root
  (locate-user-emacs-file "python-environment")
  "Path to default Python virtual environment."
  :group 'python-environment)

(defcustom python-environment-virtualenv
  (list "virtualenv" "--system-site-packages")
  "virtualenv command to use."
  :group 'python-environment)

(defun python-environment-make (&optional root virtualenv)
  "Make virtualenv at ROOT asynchronously and return a deferred object.
If VIRTUALENV (list of string) is specified, it is used instead of
`python-environment-virtualenv'."
  ...)

(defun python-environment-exists-p (&optional root)
  "Return non-`nil' if virtualenv at ROOT exists."
  ...)

(defun python-environment-bin (path &optional root)
  "Return full path to ``ROOT/bin/PATH`` or ``ROOT/Script/PATH`` if exists.
``Script`` is used instead of ``bin`` in typical Windows case."
  ...)

(defun python-environment-lib (path &optional root)
  "Return full path to ``ROOT/lib/PATH`` or ``ROOT/Lib/PATH`` if exists.
``Lib`` is used instead of ``lib`` in typical Windows case."
  ...)

(defun python-environment-run (command &optional root virtualenv)
  "Run COMMAND installed in Python virtualenv located at ROOT.
asynchronously and return a deferred object.
If ROOT is not specified, shared virtual environment specified by
`python-environment-root' is used.
If VIRTUALENV (list of string) is specified, it is used instead of
`python-environment-virtualenv'.

Use `python-environment-run-block' if you want to wait until
the command exit."
  ...)

(defun python-environment-run-block (command &optional root virtualenv)
  "Blocking version of `python-environment-run'."
  ...)

Note that plugin authors should not set or let-bound defcustom. It's for users.

Hey, joining late to the party. For me the API looks good I'm +1.