Giter Site home page Giter Site logo

pipenv.el's Introduction

pipenv.el

https://circleci.com/gh/pwalsh/pipenv.el.svg?style=svg

https://melpa.org/packages/pipenv-badge.svg

A Pipenv porcelain inside Emacs.

Overview

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. Open an issue for discussion, or submit a PR for consideration.

Installation

Melpa

pipenv.el is available on Melpa.

Spacemacs

pipenv.el has been integrated in the Python layer.

Manual

Download the code with git or as a 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.

(use-package pipenv
  :hook (python-mode . pipenv-mode)
  :init
  (setq
   pipenv-projectile-after-switch-function
   #'pipenv-projectile-after-switch-extended))

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:

(setq pipenv-with-flycheck nil)

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:

(setq pipenv-with-projectile nil)

The 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.

(setq pipenv-projectile-after-switch-function #'pipenv-projectile-after-switch-extended)

Pyvenv

pipenv.el relies on pyvenv to switch between different virtual environments (pipenv-activate and pipenv-deactivate).

pipenv.el's People

Contributors

conao3 avatar giuscri avatar immerrr avatar inpefess avatar jackkamm avatar juergenhoetzel avatar kaiwk avatar pwalsh avatar ralexstokes avatar rickysaurav avatar vspinu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pipenv.el's Issues

Pipenv v10.0.0 support

Description

v10.0.0 is out, and has some improved commands.

Tasks

  • Support new commands (e.g.: pipenv sync)
  • Leverage improved responses (e.g.: pipenv --version)
  • Add basic handling to support Pipenv version changes going forward (v.10.0.0 forward)
  • Expand the high-level interface, e.g.: pipenv-packages, pipenv-locked-packages, pipenv-dev-packages (ref.)

Support all Pipenv commands

Description

I've implemented most of Pipenv's interface, but not all of it.

Tasks

  • --envs
  • --rm
  • --bare
  • --completion
  • --two
  • --three
  • --python
  • open
  • run
  • shell

Looking for a new maintainer

Hi all,

I don't plan on continuing to work on pipenv.el.

The reason for this is that I am not using Pipenv anymore. Using Pipenv has been a pretty frustrating experience for me generally, and while I was excited about the potential for Python packaging, I find the implementation sub par, the dynamics on the Pipenv issue tracker not welcoming, and the original messaging about it implying it was the officially recommended Python packaging tool misleading.

I've simply moved over to pip-tools which solidly works with no weird bugs for my use cases

I'm happy to transfer the repo to anyone interested in maintaining this package going forward.

Activating the pipenv sometimes hangs

Sometimes (pipenv-activate) hangs. It appears to happen in the (pipenv--force-wait (pipenv-venv)) call. The while loop in pipenv--force-wait spins forever when it happens but it doesn't always happen. At first it appears that emacs locks up but I can get back control with a C-g. I put a (message "waiting...") in that loop and that seemed to fix it or at least caused it to happen less often so it feels kind of like a race condition.

How to use pipenv-venv

I'm running in a pipenv venv, and I run M-x pipenv-venv, and I get a message that says Finished pipenv --venv, but I don't see the result of pipenv --venv anywhere. What's the right way to use this?

Run shell commands async

Description

Shell command calls to pipenv currently run synchronously. This is not fun. For example, running (pipenv-update) blocks Emacs until it is done, which is a non-trivial length of time even for a couple of dependencies.

Tasks

  • Run shell-command-to-string asynchronously
  • Set up a pipenv buffer to log messages?

Trailing color codes Issue

The problem is I got tailing color code like ^[[0m in the pipenv venv responses.

For example:

In the case, it's not going to consider this response as a directory. A quick fix is:

  (defun pipenv--clean-response (response)
    "Clean up RESPONSE from shell command."
    (replace-regexp-in-string "\n�\\[0m$" "" (s-chomp response)))

But maybe there are more color codes need to be deleted. And I don't know how to prevent this happening.

Fix pipenv-where and similar functions output

pipenv-where – no output, simple:

Finished /Users/netsu/Library/Python/2.7/bin/pipenv --where

in *Messages*.


Maybe, there's needed also something like pipenv-exec to run commands like scripts, but pipenv-run use for interactive shell only (not sure, which one it should be, iterm, or so).

Flycheck race condition with Projectile

If I switch projects (C-c p p) and then select a .py file, I correctly get a buffer with the right environment activated, the right flycheck executable paths, but all checkers disabled. Everything is fine if I open another Python file afterward. I suspect there's a race between when flycheck is enabled and when the executable path is updated, causing the checkers to be disabled on the first buffer.

Is there something that I might have misconfigured, is this expected, or is there something pipenv.el can do to toggle flycheck on/off or re-enable the Python checkers after hooking the executable path?

Missing pyvenv dependency

Missing pyvenv depency gives the following error on loading pipenv-mode :
File mode specification error: (file-missing Cannot open load file No such file or directory pyvenv)

Flycheck integration

@pwalsh First of all, thank you for plugin.

It would be convenient to set flycheck python executables automatically (or update PATH for it) to avoid setup it like pipenv run flake8 (which fragile, because depend on current CMD).

Also consider possibility for better projectile integration.

(pipenv-venv) claims that no virutalenv has been created when it has

Problem: Calling M-x pipenv-activate in a buffer in a valid pipenv project fails to configure anything. Eval-ing (pipenv-venv) in that same buffer results in the process exiting with code 1, and reporting
'No virtualenv has been created for this project yet!'

Emacs: 26.0.90
OS: macOS 10.13.4
pipenv: 11.10.1

Tests and CI

Description

The code is currently a spike solution for my needs. Before it is inflicted on others, there needs to be reasonable test coverage, and CI.

Tasks

  • Basic tests
  • Configure CircleCI

After reopening the file within emacs session pipenv stops working

Hi, running a recent develop version of Spacemacs I'm observing the following problem:
After adding this option into python layer

'python-pipenv-activate t'

and opening a python file within properly configured virtualenv everything works as expected and virt. environment gets initialized properly.
When I kill the buffer and reopen the same file I'm not getting into the virt. env and even if I run pipenv-activate manually nothing changes, all I receive is message
pipenv --venv finished File mode specification error: (user-error /home/cqs/.local/bin/pylint is no executable)
When I run flycheck verify setup it cannot find any executable either, even though I have them installed in both, virt. env as well as host system.

Except error I've already mentioned I haven't spotted any suspicious messages.
Any help appreciated. Thanks

Integration with pyvenv

There's this package pyvenv that is basically an Emacs alternative to virtualenvwrapper with its pyvenv-activate command and its easier to use pyvenv-workon counterpart. I wonder if there's benefit in integrating pipenv.el with pyvenv or even offloading the activation command completely and use a more established package to do a thing as tricky as path management.

C-c C-c not working...

Hi:

When I enable pipenv, with (add-hook 'python-mode-hook #'pipenv-mode). I get
5File mode specification error: (void-function pipenv-mode)
Hit C-c C-c:
6run-hooks: Symbol's function definition is void: pipenv-mode

so I attempted:

(use-package pipenv
  :hook (python-mode . pipenv-mode)
  :init
(setq
   pipenv-projectile-after-switch-function
   #'pipenv-projectile-after-switch-extended))

-UU-:----F1 tst.py Top (1,0) (Python Undo-Tree) ----------------------------------------------
1Warning (initialization): An error occurred while loading /home/hoon/.emacs.d/init.el': 2 3Symbol's function definition is void: use-package 4 5To ensure normal operation, you should investigate and remove the 6cause of the error in your initialization file. Start Emacs with 7the --debug-init' option to view a complete error backtrace.

on:
GNU Emacs 24.5.1
(simulation-RVBo82bs) ~/warehousing$ uname -a
Linux 4.13.0-1019-gcp #23-Ubuntu SMP Thu May 31 16:13:34 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu 16.04 on gCloud
I am also using evil mode.

Is there way to get my python C-c C-c back with pipenv.el?
Thank u much,

SHY

Add prefix key customization

By default, C-c C-p runs the command run-python under python mode. It would be better to allow users to define the prefix key by themselves.

(pipenv-executable-find "python") not working on Windows

On Windows,

(pipenv-executable-find "python")

is nil whereas

(pipenv-executable-find "python.exe")

evaluates to the correct path. Is this intended?
Plus, now it looks like flycheck is working well even when pipenv-with-flycheck is set to nil.
I've tested it with Emacs 26.1 both on Ubuntu 18.04 and Windows 10.

Tidy responses that are text

Description

Some responses from Pipenv are chunks of text proper (e.g.: (pipenv-graph)). How they display depends on where you call from (e.g.: responses are currently nice in eshell, not so nice in ielm). Fix display for reasonable cases.

Tasks

  • Fix display of text responses.

Using pipenv from inside a subdirectory

I have the following in my emacs init file:

(use-package pipenv
  :hook (python-mode . pipenv-mode)
  :diminish)

Now, I visit the file a.py in a directory structure:

.:
Pipfile  GRTAGS  GTAGS  GPATH  x/

./x:
y/

./x/y:
a.py

and try to do pipenv-activate. It ends with:

No virtualenv has been created for this project yet!
Process Pipenv exited abnormally with code 1

I have projectile mode enabled. Shouldn't activation happen at project root?

Documenting installing dev packages

Hi, a nice package you have here :)
I didn't find an intended way of installing dev-packages, but from observing the source code I was able to do it this way:

M-x pipenv-install
# it asks then
Which Python packages should be installed (separate with space)?

And then I provide --dev package1 package2 ... packageN, which works just fine, packages appear in the [dev-packages] section.

The question is - did you intended to allow this, or it's an accidental side effect of how things are implemented?

If it's intended (or if it's not, but you think it's ok to do it this way) - we should document that it's possible to pass additional args this way.

Cheers!

Flycheck integration doesn't work?

Hello,
Projectile integration does not work to me. I have to activate pipenv manually. In addition, to activate flycheck integration I have to close the file and reopen it.
Here is my configuration:

;; projectile
;; https://github.com/bbatsov/projectile
(use-package projectile
  :delight '(:eval (concat " " (projectile-project-name)))
  :defer 1
  :init (setq projectile-keymap-prefix (kbd "<menu>"))
  :config
  (projectile-mode)
  (add-to-list 'projectile-project-root-files "platformio.ini")
  (setq projectile-completion-system 'ivy
		projectile-enable-caching t
		projectile-track-known-projects-automatically nil
		projectile-files-cache-expire 2592000))


;; flycheck
;; http://www.flycheck.org
;; Dep pylint, clang, tidy, csslint
(use-package flycheck
  :defer 1
  :bind (:map flycheck-mode-map ("C-c ! !" . hydra-flycheck/body))
  :config
  (global-flycheck-mode)
  (setq-default flycheck-global-modes '(not org-mode)
                flycheck-disabled-checkers '(python-flake8))
  (defhydra hydra-flycheck
    (:pre (progn (setq hydra-lv t) (flycheck-list-errors))
          :post (progn (setq hydra-lv nil) (quit-windows-on "*Flycheck errors*"))
          :hint nil)
    "Errors"
    ("f"  flycheck-error-list-set-filter  "Filter")
    ("n"  flycheck-next-error             "Next")
    ("p"  flycheck-previous-error         "Previous")
    ("q"  nil                             "Quit")))


;; pipenv.el
;; https://github.com/pwalsh/pipenv.el
;; Dep pipenv
(use-package pipenv
  :hook (python-mode . pipenv-mode)
  :config
  (setq pipenv-projectile-after-switch-function #'pipenv-projectile-after-switch-extended))

pipenv-activate hanging

Calling pipenv-activate will often hang my emacs indefinitely. I started noticing this when I last updated a week or 2 ago.

I believe the problem is a race condition in pipenv--force-wait, if the process finishes before the sentinel is set then it will never be called.

A reliable way to reproduce this problem is to add a sit-for at the top of pipenv--force-wait, so that the process finishes before the sentinel is set. Then the sentinel is never called and we get stuck in the infinite while loop.

run-python

Thank you for this new plugin, progress amazes.
I'm trying to test it a little now.

M-x run-python

apply: Searching for program: No such file or directory, ipython

However, pipenv-run RET ipython works (not as interactive shell, as may be expected, but it find ipython at least).

No such file or directory pipenv

Emacs 27.2
pipenv, version 2021.5.29 installed via pip
Python 3.9.6 on Fedora 34

Config:

(use-package pipenv
  :hook (python-mode . pipenv-mode)
  :init
  (setq
   pipenv-projectile-after-switch-function
   #'pipenv-projectile-after-switch-extended))

Whenever I enter a python file or activate pipenv-mode I get:
Cannot open load file: No such file or directory, pipenv

Pipenv is executable from the cli and is on my shell PATH.

Shell spawned by pipenv shell prints issued command before command output

See how a ls -la is printed before the actual command output.

(thesis-W6OBZlR6) [g@x220 thesis]$ ls -la
ls -la
total 156
drwxr-xr-x 10 g g  4096 Jul 18 17:44 .
drwx------ 25 g g  4096 Jul 18 19:41 ..
-rw-r--r--  1 g g  2226 Jul 14 17:15 attacks.py
drwxr-xr-x  2 g g  4096 Jul 16 12:02 bin
-rw-r--r--  1 g g    21 Jun 12 02:59 .coveragerc
-rw-r--r--  1 g g    46 Jun 10 11:51 .coveralls.yml
-rw-r--r--  1 g g  2330 Jul 15 12:18 datasets.py
-rw-r--r--  1 g g   533 Jun 15 00:20 Dockerfile
...

pipenv.el bombs *Messages* and blocks minibuffer

Hi, when I'm installing (or uninstalling) packages, pipenv.el bombs minbuffer and *Messages* buffer with status messages, effectively blocking me from using another M-x commands for a while (10 seconds easily).
Samples from *Messages*:
After installing:

Finished pipenv install --dev pylint objgraph [18 times]
Reverting buffer ‘Pipfile’.
Finished pipenv install --dev pylint objgraph [52 times]
Reverting buffer ‘Pipfile’.
Finished pipenv install --dev pylint objgraph [8 times]

After uninstalling:

Finished pipenv uninstall pylint objgraph [2 times]
Reverting buffer ‘Pipfile’.
Finished pipenv uninstall pylint objgraph [5 times]
Reverting buffer ‘Pipfile’.
Finished pipenv uninstall pylint objgraph [2 times]

pipenv-activate doesn't load the virtual environment for all other commands

I'm running spacemacs on the syl20bnr/spacemacs@0fa3658 of the develop branch. When I run the pipenv-shell function, it properly launches a shell in the appropriate environment, which I can verify by running pip freeze and viewing installed libraries.

When I run pipenv-activate, it doesn't seem like much of anything happens. I do get some output to two buffers:

  • *Pipenv*

/home/bill/.local/share/virtualenvs/{valid-path-to-my-venv}
Process Pipenv finished

  • *Messages*

Finished pipenv --venv

My virtual environment's packages are not available to emacs, and running pip freeze from the editor confirms this. Dropping down to the pyvenv functions does work.

I'd provide more information, but this about the extent of my emacs-lisp debugging experience.

Integration hooks and keymap

Description

This is currently just a set of functions. What I need, and others too, is delivery as a proper minor mode for python, and integration with projectile and anaconda.

Tasks

  • Minor mode
  • Key mapping
  • Projectile
  • Anaconda
  • Flycheck

pipenv--f-parent: Symbol’s function definition is void: f-expand

The function f-expand is called in line 182 of pipenv.el. This results in the following error message if the f.el package isn't installed.

pipenv--f-parent: Symbol’s function definition is void: f-expand

It appears this was missed when f.el was removed as a dependency.

el-get recipe

Please, add to Installation subsection for el-get

Here's recipe (until it not in recipes repository yet):

(:name pipenv
       :type github
       :pkgname "pwalsh/pipenv.el"
       :description "Manage Pythons with Pipenv in Emacs."
       :depends (s f))

Integration with live-py-mode not working

Having originally filed an issue with the spacemacs project, I have been asked to file the same here.

Having activated my pipenv virtualenv (pipenv-activate), entering live-py-mode fails to use the active virtualenv.

Eg: Attempting to import a module which is installed in the virtualenv fails.

Note that if I execute a local file (python-execute-file-focus) the code runs inside my virtualenv, and works as expected

No such file or directory, pipenv. And (executable-find "pipenv") returns nil

Running pipenv-activate in buffer in pipenv project returns: Searching for program: No such file or directory, pipenv.

I saw #59 and ran (executable-find "pipenv") which return nil.

I ensured the pipenv.el as well as pipenv are installed and that pipenv is on path.

Info:

  • macOS Big Sur
  • DOOM Emacs 28.1
  • python 3.9 a
  • pipenv 2022.6.7

Thanks

Use Pythonic?

Description

Pythonic is a mature library with a range of utility functions around managing Python processes, setting vars for Python environments, etc.

Tasks

  • Check if Pipenv's way of managing things can leverage Pythonic
  • Identify specific functions to rebase on Pythonic functionality

Control commands spawned by pipenv-run

Hi.
First of all, thanks for the effort with pipenv.el.
I work with python and a JS frontend. I have a command in npm that starts the python server on a port. When I use pipenv, I usually run pipenv run npm run start to execute the server in the virtualenv. I tried to do the same in emacs with pipenv.el and it works, but, I have no simple way to kill or restart the process (and it blocks a port). I had to kill the Pipenv buffer.

Right now I'm using pipenv-shell to run npm run start. I'm not sure if it would be a good idea to add a way to cancel the process running with pipenv-run.

Thanks. I had been expecting a package for pipenv for a couple of months.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.