Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pwalsh/pipenv.el
A Pipenv porcelain inside Emacs.
https://github.com/pwalsh/pipenv.el
emacs pipenv pipfile python virtualenv
Last synced: 9 days ago
JSON representation
A Pipenv porcelain inside Emacs.
- Host: GitHub
- URL: https://github.com/pwalsh/pipenv.el
- Owner: pwalsh
- Created: 2017-12-09T20:35:39.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-10T01:50:27.000Z (over 2 years ago)
- Last Synced: 2024-11-22T22:35:17.604Z (about 1 month ago)
- Topics: emacs, pipenv, pipfile, python, virtualenv
- Language: Emacs Lisp
- Homepage:
- Size: 62.5 KB
- Stars: 169
- Watchers: 7
- Forks: 23
- Open Issues: 11
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* pipenv.el
#+ATTR_HTML: :alt CircleCI image :title CircleCI
[[https://circleci.com/gh/pwalsh/pipenv.el][https://circleci.com/gh/pwalsh/pipenv.el.svg?style=svg]][[https://melpa.org/#/pipenv][file:https://melpa.org/packages/pipenv-badge.svg]]
A [[https://pipenv.readthedocs.io/en/latest/][Pipenv]] porcelain inside Emacs.
** Overview
[[https://pipenv.readthedocs.io/en/latest/][Pipenv]] is a tool that aims to bring the best of all packaging worlds to the Python world. It manages virtual environments, adds and removes packages, and enables deterministic build dependencies.
=pipenv.el= makes Pipenv a first-class citizen in your Emacs-driven Python development workflow with a range of interactive commands wrapping the Pipenv, a minor mode to accompany =python-mode= with a keymap for the most useful commands, and a high-level =pipenv-activate= / =pipenv-deactivate= interface for virtual environment integration with your Emacs session.
** Contributing
Contributions to documentation and code are welcome. [[https://github.com/pwalsh/pipenv.el/issues/new][Open an issue]] for discussion, or [[https://github.com/pwalsh/pipenv.el/compare][submit a PR]] for consideration.
** Installation
*** Melpa
=pipenv.el= is available on [[https://melpa.org/#/pipenv][Melpa]].
*** Spacemacs
=pipenv.el= [[https://github.com/syl20bnr/spacemacs/pull/10308][has been integrated]] in the [[http://spacemacs.org/layers/+lang/python/README.html][Python layer]].
*** Manual
Download the code with [[https://github.com/pwalsh/pipenv.el.git][git]] or as a [[https://github.com/pwalsh/pipenv.el/archive/master.zip][zip]], and then put =pipenv.el= on your Emacs load path.
** Configuration
Once installed, all Pipenv commands are available to be called interactively, and are prefixed with =pipenv-=. To add the minor mode for buffers with a Python major mode, use =(add-hook 'python-mode-hook #'pipenv-mode)=.
Here is an example of configuration with =use-package=.
#+BEGIN_SRC elisp
(use-package pipenv
:hook (python-mode . pipenv-mode)
:init
(setq
pipenv-projectile-after-switch-function
#'pipenv-projectile-after-switch-extended))
#+END_SRC** Features
*** Pipenv coverage
=pipenv.el= wraps the majority of the Pipenv CLI. See all commands prefixed with =pipenv-= after installation (=M-x pipenv-=).
**** =pipenv open=
=pipenv.el= reimplements Pipenv's =open= command in Emacs Lisp as =pipenv-open=, rather than shelling out to Pipenv for the logic. This is a design decision, ensuring that modules are opened in the current Emacs session, rather than in =$EDITOR= as per the Python implementation of =pipenv open=.
*** Activate and Deactivate
In addition to providing the majority of Pipenv commands, there are several custom functions available in =pipenv.el=. The most useful are =pipenv-activate= and =pipenv-deactivate=, which are used to manage the Python virtual environment for the current Emacs session.
=pipenv-activate= calls =pyvenv-activate= and sets the variable =python-shell-virtualenv-root= to that of the Pipenv project currently being visited, and =pipenv-deactivate= sets it back to the Emacs default and also calls =pyvenv-deactivate=.
*** Minor mode
The Pipenv minor mode is activated for buffers with a Python major mode. The minor mode exposes a number of key bindings for =pipenv.el= commands, prefixed by =M-p=.
- =C-c C-p a= is bound to =pipenv-activate=
- =C-c C-p d= is bound to =pipenv-deactivate=
- =C-c C-p s= is bound to =pipenv-shell=
- =C-c C-p o= is bound to =pipenv-open=
- =C-c C-p i= is bound to =pipenv-install=
- =C-c C-p u= is bound to =pipenv-uninstall=*** Integrations
**** Flycheck
Integration with Flycheck is enabled by default, if Flycheck is installed. The integration customises Flycheck's =flycheck-executable-find= function to search for executables in an activate Pipenv virtual environment.
Disable Flycheck integration with:
#+BEGIN_SRC elisp
(setq pipenv-with-flycheck nil)
#+END_SRC**** Projectile
Integration with Projectile is enabled by default, if Projectile is installed. The integration adds a hook to =projectile-after-switch-project-hook=, being =pipenv-projectile-after-switch-function=, which can be customized.
Disable Projectile integration with:
#+BEGIN_SRC elisp
(setq pipenv-with-projectile nil)
#+END_SRCThe default value for =pipenv-projectile-after-switch-function= is the function =pipenv-projectile-after-switch-default=, which simply activates the Pipenv virtual environment, if a Pipenv project is detected.
You can set your own function to =pipenv-projectile-after-switch-function= to customise this behaviour. An example function for this is included, called =pipenv-projectile-after-switch-extended=, which, in addition to setting the virtual environment, opens a Pipenv shell, and opens a Python interpreter with =run-python=.
#+BEGIN_SRC elisp
(setq pipenv-projectile-after-switch-function #'pipenv-projectile-after-switch-extended)
#+END_SRC
**** Pyvenv=pipenv.el= relies on [[https://stable.melpa.org/#/pyvenv/][pyvenv]] to switch between different virtual environments (=pipenv-activate= and =pipenv-deactivate=).