Skip to main content
uv pip compile resolves dependencies and creates a locked requirements file. It is compatible with pip-compile from pip-tools but offers significantly faster performance.

Usage

Arguments

Input Sources

path[]
required
Input files to compile.Supported formats:
  • requirements.in or .txt
  • .py files with inline metadata
  • pylock.toml
  • pyproject.toml, setup.py, setup.cfg
Use - to read from stdin.

Output Options

path
Write compiled requirements to a file.If the file exists, its pinned versions are used as preferences during resolution (unless --upgrade is specified).
string
Output format: requirements-txt or pylock.Default: Inferred from --output-file extension, otherwise requirements-txt

Constraints and Overrides

path[]
Constrain package versions without requiring installation.
Environment: UV_CONSTRAINT
path[]
Override package versions, ignoring dependencies.
Environment: UV_OVERRIDE
path[]
Exclude packages from resolution.
Environment: UV_EXCLUDE
path[]
Constrain build dependencies when building from source.
Environment: UV_BUILD_CONSTRAINT

Optional Dependencies

string[]
Include optional dependencies (extras) from pyproject.toml.
Include all optional dependencies.
string[]
Include dependency groups from pyproject.toml.

Resolver Options

Upgrade all packages to the latest compatible versions.
requirement[]
Upgrade specific packages while keeping others pinned.
string
Resolution strategy: highest, lowest, or lowest-direct.Default: highest
Environment: UV_RESOLUTION
string
Pre-release handling: disallow, allow, if-necessary, explicit, or if-necessary-or-explicit.Default: if-necessary-or-explicit
Environment: UV_PRERELEASE
string
Version selection strategy: requires-python or fewest.Default: requires-pythonEnvironment: UV_FORK_STRATEGY
Only add explicitly listed packages, not their dependencies.

Output Formatting

Include extras in output file.By default, uv strips extras as dependencies are already included.
Include environment markers in output.
Exclude comments indicating package sources.
string
Annotation comment style: line, split.Default: split
Exclude the header comment from output.
string
Custom command for header (for build script wrappers).
Environment: UV_CUSTOM_COMPILE_COMMAND
Include --index-url and --extra-index-url in output.
Include --find-links in output.
Include --no-binary and --only-binary in output.
Include index source in comments.
package[]
Omit specific packages from output (but include dependencies).Equivalent to pip-compile’s --unsafe-package.

Hash Generation

Include distribution hashes in output.

Python Environment

string
Python interpreter for building source distributions.Also determines minimum Python version unless --python-version is provided.
Environment: UV_PYTHON
Use system Python instead of virtual environment.
Environment: UV_SYSTEM_PYTHON
version
Minimum Python version to support (e.g., 3.8 or 3.8.17).
triple
Target platform triple (e.g., x86_64-unknown-linux-gnu).
Create a universal resolution for all platforms and Python versions.The specified --python-version is treated as a lower bound.Implies --no-strip-markers.

Build Options

Don’t build source distributions. Only use pre-built wheels.Alias for --only-binary :all:
package[]
Build specific packages from source.
package[]
Only use pre-built wheels for specific packages.
key=value[]
Pass settings to the PEP 517 build backend.
package:key=value[]
Pass package-specific settings to build backends.
Disable build isolation. Assumes build dependencies are already installed.
Environment: UV_NO_BUILD_ISOLATION
package[]
Disable build isolation for specific packages.

Index Options

url[]
Package indexes to use (in addition to default).
Environment: UV_INDEX
url
Default package index (replaces PyPI).
Environment: UV_DEFAULT_INDEX
url
Deprecated: Use --default-index instead.Environment: UV_INDEX_URL
url[]
Deprecated: Use --index instead.Environment: UV_EXTRA_INDEX_URL
Additional locations to search for packages.
Environment: UV_FIND_LINKS
Ignore package indexes, only use --find-links.
string
Index selection strategy: first-index, unsafe-first-match, or unsafe-best-match.Default: first-indexEnvironment: UV_INDEX_STRATEGY
string
Keyring provider for authentication: disabled, subprocess.Default: disabledEnvironment: UV_KEYRING_PROVIDER

Version Constraints

date
Exclude packages uploaded after the specified date.
Environment: UV_EXCLUDE_NEWER
package=date[]
Exclude specific packages uploaded after dates.
Link mode for build environments: clone, copy, hardlink, symlink.Default: clone on macOS/Linux, hardlink on WindowsEnvironment: UV_LINK_MODE

uv Extensions

string
PyTorch backend: cpu, cu126, cu124, cu121, cu118, or auto.
Preview feature. May change in future releases.
Environment: UV_TORCH_BACKEND
Ignore tool.uv.sources in pyproject.toml.Environment: UV_NO_SOURCES
package[]
Ignore sources for specific packages.Environment: UV_NO_SOURCES_PACKAGE

Cache Options

Refresh all cached data.
package[]
Refresh cached data for specific packages.

Examples

Basic Compilation

With Extras

Upgrading Dependencies

Universal Resolution

With Constraints

Hash Generation

Custom Output Format

Custom Indexes

Cross-Platform

Build Options

pip-tools Compatibility

uv pip compile is designed to be compatible with pip-compile from pip-tools:

Differences from pip-compile

  1. Performance: uv is significantly faster (10-100x)
  2. Output file: uv requires explicit -o flag; pip-compile infers it
  3. Markers: uv strips markers by default; use --no-strip-markers for pip-compile behavior
  4. Extras: uv strips extras by default; use --no-strip-extras for pip-compile behavior
  5. Resolution: uv uses a more sophisticated resolver

Migration from pip-compile

Output Format

The default output is a requirements.txt file:
With --format pylock, output is in PEP 751 format: