pip-tools

7.5.3 · active · verified Sun Mar 29

pip-tools is a set of command-line tools, primarily `pip-compile` and `pip-sync`, designed to help manage Python project dependencies by pinning them to exact versions. It aims to ensure deterministic and reproducible builds by generating fully-pinned `requirements.txt` files from abstract `requirements.in` files (or `pyproject.toml`). The library is currently at version 7.5.3 and actively maintained, though its release cadence can sometimes be irregular, with recent updates catching up after periods of inactivity.

Warnings

Install

Imports

Quickstart

The typical workflow involves defining your top-level dependencies in a `requirements.in` file (or `pyproject.toml`), then using `pip-compile` to generate a fully-pinned `requirements.txt`. Finally, `pip-sync` is used to install, upgrade, and remove packages in your virtual environment to precisely match the generated `requirements.txt` file. Remember to activate your virtual environment before running `pip-tools` commands.

# 1. Create your input file (e.g., requirements.in)
# requirements.in
# requests
# black~=23.0

# 2. Compile your requirements to a pinned requirements.txt
pip-compile requirements.in

# The above generates a requirements.txt like:
# #
# # This file is autogenerated by pip-compile
# # To update, run:
# #
# #    pip-compile requirements.in
# #
# black==23.12.1 # via -r requirements.in
# certifi==2024.2.2 # via requests
# charset-normalizer==3.3.2 # via requests
# click==8.1.7 # via black
# idna==3.6 # via requests
# mypy-extensions==1.0.0 # via black
# packaging==23.2 # via black
# pathspec==0.12.1 # via black
# platformdirs==4.1.0 # via black
# requests==2.31.0 # via -r requirements.in
# urllib3==2.2.1 # via requests

# 3. Synchronize your virtual environment to match requirements.txt
pip-sync requirements.txt

view raw JSON →