Generate requirements[-dev].txt from Pipfile using pipenv
Project description
Generate requirements[-dev].txt from Pipfile (using pipenv). Used in my modern Python module project cookiecutter. template.
Free software: MIT
Documentation: https://pipenv-to-requirements.readthedocs.org/en/latest/
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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pipenv-to-requirements-0.8.2.tar.gz
.
File metadata
- Download URL: pipenv-to-requirements-0.8.2.tar.gz
- Upload date:
- Size: 28.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 115390158232f53983f1d989f922d890adbdaaaa95c8b2357a77b9f5fe647862 |
|
MD5 | 19a25c13bd989441dfa5540da331e687 |
|
BLAKE2b-256 | 6321ba56f3368920853e8b348895a9e732293f6927d7dad4df928291b105b295 |
File details
Details for the file pipenv_to_requirements-0.8.2-py2.py3-none-any.whl
.
File metadata
- Download URL: pipenv_to_requirements-0.8.2-py2.py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b7349e76d2c511e8b4a723495311b310e4e33bb716437b30cc18ecb0b0b5e29 |
|
MD5 | 46e4e239f387166b16830a962a98a806 |
|
BLAKE2b-256 | eeb8c403c830f3c07a81780b37cdb39c16b07d95b2973124bfdbdae91c1da1d0 |