pipenv: Evolution of pip

by , under Uncategorized

pipenv is an evolution of pip designed to solve these two main problems of pip and add virtual env to it. There is no reason to continue using pip directly. Added bonus is that pycharm has built-in support for this. You can now create new project with interpreter as pipenv and plugins for Pipfile and Pipfile.lock.

Here is the basic life cycle of using pipenv..

  1. Install project dependencies using pipenv install <dependency>
    • This will create Pipfile and Pipfile.lock (deterministic build + hash for security)
  2. Now once your dev is complete and everything tested. It’s time to check and lock.
    • pipenv check (for pep508)
    • pipenv lock (update the Pipfile.lock)
  3. Use the lock file for install or upgrade in prod or other env.
    • pipenv sync

It does provide support for other essentials features of dependency management such as…

  1. insights into the dependencies graph
    • pipenv graph
    • pipenv graph –reverse
  2. uninstalling and clean dependencies that you don’t need anymore or add incorrectly etc.,
    • pipenv uninstall <dependency> ==> to uninstall and remove from Pipfile
    • pipenv update ==> To update the lock file after removing dependency
    • pipenv clean ===> Remove all indirect dependencies not in the Pipfile lock file.
  3. The Pipfile format allows to have dev specific dependencies. So for things like pytest you do the following…
    • pipenv install pytest –dev

Overall this is a very nice and robust evolution of pip that we can now stop using pip directly for new projects. Read this guide for complete usage instructions of pipenv.

Note: There are lot of noises about the quality of the pipenv and people recommending Poetry as other alternative. However i’ve not had any major issues with my django or cherry-py projects. In a worse scenario, we could go straight to using pip without too much overhead which seems like not the case with Poetry though. Over the years we will know the winner but for now i’m sticking with pipenv.

Leave a Reply