Skip to main content

Generate requirements[-dev].txt from Pipfile using pipenv

Project description Pypi package MIT licensed

Generate requirements[-dev].txt from Pipfile (using pipenv). Used in my modern Python module project cookiecutter. template.


Pipfile and its sibling Pipfile.lock are clearly superior tools defining clear dependencies or a package. Pipfile is to be maintained by the package’s developer while Pipfile.lock represent a clear image of what is currently installed on the current system, guarantying full reproductibility of the setup. See more information about Pipfile format here. Most of the time, Pipfile.lock should be ignored (ie, not tracked in your git) for packages published on Pypi.

pipenv is a great tool to maintain Pipfile, but developers might be stuck with backward compatibility issues for tools and services that still use requirements.txt and does not know how to handle Pipfile or Pipfile.lock yet.

For examples:

  • ReadTheDocs
  • Pyup (experimental support is arriving )
  • Any library that uses PBR (*)
  • pip install (if you install a package with pip that does not have a requirements.txt, its dependencies won’t be installed, even if you use Pipfile)

(*): for the moment, I recommend to generate at least requirements.txt (without version freeze) for the libraries using PBR that you publish on Pypi. Remember PBR automatically synchronize the content of requirements.txt found at the root of a package with of this package. This allows automatic installation of the very dependencies of your package. Without this file, your package will be installed by pip, but its dependencies will be ignored. Support in PBR may be added in the future (see this this patch ).


Just before building source/binary/wheel package of your python module, only of the following commands:

  • To generate requirements files (ie, dependencies are described eventually by range), typically for libraries:

    pipenv run pipenv_to_requirements
  • To generate frozen requirements (ie, all dependencies have their version frozen), typically for applications:

    pipenv run pipenv_to_requirements -f

It will generate requirements.txt and, if applicable, requirements-dev.txt, in the current directory.

Example using a Makefile:

    pipenv install --dev
    pipenv run pip install -e .

dists: requirements sdist bdist wheels

    # For a library, use:
    pipenv run pipenv_to_requirements
    # For an application, use:
    # pipenv run pipenv_to_requirements -f

sdist: requirements
    pipenv run python sdist

bdist: requirements
    pipenv run python bdist

wheels: requirements
    pipenv run python bdist_wheel

Just use make requirements to refresh the requirements.txt.


Simply commit these files in your tree so that readthedocs, and ensure they are synchronized each time you change your Pipfile. Do not forget to ask ReadTheDocs to use requirements-dev.txt when building the documentation.


Create your development environment with

$ make dev

Execute unit tests:

$ make test

Code formatter:

$ make style

Code Style Checks:

$ make check

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pipenv_to_requirements-0.5.1-py2.py3-none-any.whl (9.1 kB) Copy SHA256 hash SHA256 Wheel py2.py3 Jun 19, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page