I'm reading about this new shiny tool called pipenv
and can't understand what is the use case of this tool.
setup.py
and requirements.txt
.tox
and virtualenv
.pip
, because pipenv devs don't care about this feature
So what's the point of yet another tool and config files with different syntax? What problem does pipenv
solve?
All of the functions of setup.py
, tox
, requirements
, virtualenv
, etc. are critical for someone distributing a library that needs to be built and tested against multiple versions of Python and possibly multiple versions of their requirements.
The docs mention this, but I'll reiterate. Pipenv is aimed at application developers and service providers. In those cases, you're typically building a single configuration, and your aggressively updating your version set. In addition, you need to be able to roll back easily to a prior version set.
What you got with requirements.txt
was version pinning, so you could roll back, but pip never enforced version consistency, so you could construct a requirements.txt
that had contradictory versions. It's python, so most of the time you can get away with it, but having consistent versions does mitigate that class of problems.
pip-tools can construct consistent version sets, but you're now dealing with three separate utilities: pip
, pip-tools
and virtualenv
. This is great if everyone is always careful to run all three to keep things up to date, and of course they don't.
What pipenv adds is combining the management of all three of those and enforcing version consistency at all times.
If you do something as simple as git checkout
, all you have to do is run pipenv sync --dev
to update your virtualenv.
With pip, you'd have to blow away the virtualenv entirely and rerun pip install
as pip won't remove existing packages.
If you set up your Pipfile to have "yourpackage" = {path=".", editable=true}
, then you can update a requirement in setup.py
and pipenv update
will ensure your virtualenv is updated accordingly, or report an error.
To be clear, there is no use case that is handled by pipenv alone; you can do it with other tools. But it does have an audience in mind, application developers, and it is differentiated by providing a much more consistent experience for users. I've also found that, in practice, it's quite helpful for library development too, as a test suite is an application in itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With