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

src_file
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

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

Constraints and Overrides

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

Optional Dependencies

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

Resolver Options

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

Output Formatting

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

Hash Generation

--generate-hashes
Include distribution hashes in output.

Python Environment

-p, --python
string
Python interpreter for building source distributions.Also determines minimum Python version unless --python-version is provided.
Environment: UV_PYTHON
--system
Use system Python instead of virtual environment.
Environment: UV_SYSTEM_PYTHON
--python-version
version
Minimum Python version to support (e.g., 3.8 or 3.8.17).
--python-platform
triple
Target platform triple (e.g., x86_64-unknown-linux-gnu).
--universal
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

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

Index Options

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

Version Constraints

--exclude-newer
date
Exclude packages uploaded after the specified date.
Environment: UV_EXCLUDE_NEWER
--exclude-newer-package
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

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

Cache Options

--refresh
Refresh all cached data.
--refresh-package
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: