Utility functions for writing pythonic emacs package.
You can install this package form Melpa
M-x package-install RET pythonic RET
This library provide function for convenient running python on
different platforms on local and remote hosts including Docker
containers and Vagrant virtual machines. To use pythonic
with
Docker you need to install
docker-tramp Emacs
package.
You can use remote interpreter from the tramp buffer.
(cd "/ssh:user@host:/home/user/")
;; or
(cd "/docker:root@container:/root/")
Pythonic wrapper around call-process
.
FILE is the input file. BUFFER is the output destination. DISPLAY
specifies to redisplay BUFFER on new output. ARGS is the list of
arguments passed to call-process
. CWD will be working directory for
running process.
(pythonic-call-process :buffer "*Pythonic*"
:args '("-V")
:cwd "~")
Pythonic wrapper around start-process
.
PROCESS is a name of the created process. BUFFER is a output
destination. ARGS are the list of args passed to start-process
. CWD
will be working directory for running process. FILTER must be a
symbol of process filter function if necessary. SENTINEL must be a
symbol of process sentinel function if necessary. QUERY-ON-EXIT will
be corresponding process flag.
(pythonic-start-process :process "pythonic"
:buffer "*Pythonic*"
:args '("-c" "print('PING')")
:cwd "~"
:filter (lambda (process output) (message output))
:sentinel (lambda (process event) (message "Done."))
:query-on-exit nil)
Determine remote or local virtual environment.
(pythonic-remote-p)
Determine docker remote virtual environment.
(pythonic-remote-docker-p)
Determine vagrant remote virtual environment.
(pythonic-remote-vagrant-p)
Get user of the connection to the remote python interpreter.
(pythonic-remote-user)
Get host of the connection to the remote python interpreter.
(pythonic-remote-host)
Get port of the connection to the remote python interpreter.
(pythonic-remote-port)
Activate python virtual environment. Tramp paths are supported.
Deactivate python virtual environment.
You can change the default docker-compose file name and set a default service name to run the pythonic commands.
Add these lines to the .dir-locals.el
file in the project root
directory.
((python . ((pythonic-docker-compose-filename . "local.yml")
(pythonic-docker-compose-service-name . "web"))))
You can change the interpreter that pythonic uses. This is especially useful when you have set your python-shell-interpreter
to something like jupyter-console
. By default, it'll use python-shell-interpreter
.
To change it:
(setq pythonic-interpreter "python")