Skip to main content

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

Project description

https://travis-ci.org/gsemet/pipenv-to-requirements.svg?branch=master Pypi package MIT licensed

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

Rational

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:

  • Read the Docs

  • 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 setup.py 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 ).

Usage

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.

  • Also possible:

    pipenv run pipenv_to_requirements -d requirements-dev-custom.txt
    pipenv run pipenv_to_requirements -d requirements-dev-custom.txt -f
    pipenv run pipenv_to_requirements -o requirements-custom.txt
    pipenv run pipenv_to_requirements -o requirements-custom.txt -f
    pipenv run pipenv_to_requirements  -d requirements-dev-custom.txt -o requirements-custom.txt -f

Example using a Makefile:

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

dists: requirements sdist bdist wheels

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

sdist: requirements
    pipenv run python setup.py sdist

bdist: requirements
    pipenv run python setup.py bdist

wheels: requirements
    pipenv run python setup.py bdist_wheel

Just use make requirements to refresh the requirements.txt.

Read the Docs

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

Contributing

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.

Source Distribution

pipenv-to-requirements-0.7.1.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

pipenv_to_requirements-0.7.1-py2.py3-none-any.whl (11.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pipenv-to-requirements-0.7.1.tar.gz.

File metadata

  • Download URL: pipenv-to-requirements-0.7.1.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for pipenv-to-requirements-0.7.1.tar.gz
Algorithm Hash digest
SHA256 04dc5b1fedfea18858efe3f28d62ed70ac0cd04c34bc32a8c3531384d11be460
MD5 d35bd0e20a7e6943a6ac50c9c67404e9
BLAKE2b-256 abe305be50b8696517192d0b9ece6a5e289d8d6c049ef9a8cd83f0caef8d7216

See more details on using hashes here.

File details

Details for the file pipenv_to_requirements-0.7.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pipenv_to_requirements-0.7.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for pipenv_to_requirements-0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 44bfefa3f6ded62e3bdcc5a6bb4de7a821b2658f821c1126f6abc3bffecb2c1e
MD5 d9ac6a2a1d21908f8f75f39272747211
BLAKE2b-256 bc5097503a7268649fcd8c07dc9eb377cab73468b01230dbbe97ace24ef93f6c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page