/pyenv-binstubs

A pipenv plugin for pyenv

Primary LanguageShell

pyenv-binstubs: A Pipenv Plugin for pyenv

This plugin makes pyenv transparently aware of project-specific venv binaries created by pipenv.

This means you don't have to type pipenv run ${command} ever again!

Installation

To install pyenv-binstubs, clone this repository into your ~/.pyenv/plugins directory.

$ git clone https://github.com/madumlao/pyenv-binstubs.git "$(pyenv root)/plugins/pyenv-binstubs"

There is a known issue with pyenv-binstubs - if you have already installed pipenv using pyenv before, you may need to reinstall pipenv / created virtualenvs upon installing pyenv-binstubs. If you haven't used pipenv before installing pyenv-binstubs, this is not an issue.

$ rm -Rvf ~/.local/share/virtualenvs
$ pip uninstall pipenv
$ pip install pipenv

Then for each application directory run the following just once:

$ pipenv install [other stuff]

Normally, pipenv takes care of provisioning / linking to a virtualenv. However, to use the virtualenv, you have to spawn a pipenv subshell or use pipenv run. What a pain!

pipenv-binstubs simplifies this by detecting that a pipenv virtualenv exists, and using the pyenv-generated shims to forward to the executables in the virtualenv.

Usage

Simply type the name of the command you want to run! Thats all folks! Eg:

$ pip --version

This plugin searches from the current directory up towards root for a directory containing a Pipfile. If such a directory is found, then the plugin checks for the desired command in directory's virtualenv (effectively running 'pipenv run'), then in its python version.

To confirm that the pipenv binary is being used, run the command:

$ pyenv which COMMAND

To show which package pip will use, run the command:

$ pip show PACKAGE

You can disable the searching for pipenv binaries by setting the environment variable DISABLE_BINSTUBS to a non empty string:

$ DISABLE_BINSTUBS=1 pyenv which command

You can list the bundles (project directories) and their associated virtualenv directories using the command:

$ pyenv bundles

License

Copyright (c) 2018 Mark Dumlao - Released under the same terms as rbenv's MIT-License

Contributors

Thanks go to: