uv-import-constraint-dependencies
A CLI tool to import constraints.txt files into pyproject.toml as tool.uv.constraint-dependencies.
Overview
This tool reads a pip constraints file (local or remote) and adds the pinned dependencies to your pyproject.toml in the format expected by the uv package manager.
Installation
uv tool install uv-import-constraint-dependencies
Or with pip:
pip install uv-import-constraint-dependencies
Usage
Basic Usage
Import constraints from a local file:
uv-import-constraint-dependencies -c constraints.txt
Import constraints from a remote URL:
uv-import-constraint-dependencies -c https://example.com/constraints.txt
Options
| Option | Short | Description |
|---|---|---|
--constraints |
-c |
Path or URI to constraints.txt file (required) |
--pyproject |
-p |
Path to pyproject.toml file (default: pyproject.toml) |
--custom-constraints |
--cc |
Path to local custom constraints file for overriding base constraints |
--merge |
Merge with existing constraint-dependencies instead of replacing | |
--version |
Show version information | |
--help |
Show help message |
Examples
Custom pyproject.toml path:
uv-import-constraint-dependencies -c constraints.txt -p path/to/pyproject.toml
Merge with existing constraints instead of replacing:
uv-import-constraint-dependencies -c constraints.txt --merge
Override base constraints with local customizations:
uv-import-constraint-dependencies -c https://example.com/constraints.txt --cc custom-constraints.txt
Behavior
Replace Mode (Default)
By default, all existing constraint-dependencies in pyproject.toml are replaced with the new ones from the constraints file.
Merge Mode (--merge)
When using --merge, new constraints are merged with existing ones in tool.uv.constraint-dependencies:
- New packages are added
- Existing packages are updated with the new version specifier
- Packages not in the new constraints file are preserved
- Constraints are sorted alphabetically
Custom Constraints (--cc)
The --cc (or --custom-constraints) option allows you to override specific packages from the base constraints file with local customizations. This is useful when:
- You use a shared/remote constraints file but need different versions for specific packages
- You want to test newer versions of certain dependencies without modifying the base file
How it works:
- Base constraints are loaded from
-c(can be local or remote) - Custom constraints from
--ccare merged on top (custom takes precedence) - The combined result is then merged with or replaces existing pyproject.toml constraints (depending on
--no-merge)
Example workflow:
# Remote base constraints + local overrides
uv-import-constraint-dependencies -c https://example.com/constraints.txt --cc custom-constraints.txt
Example custom-constraints.txt:
# Override requests version from base constraints
requests==2.32.0
# Add a package not in base constraints
my-internal-package==1.0.0
Constraints File Format
The tool supports standard pip constraints file format:
# Comments are ignored
requests==2.31.0
flask>=2.0.0,<3.0.0
numpy==1.24.3 ; python_version >= "3.9" # Inline comments are stripped
urllib3>=1.26.0
# Include directives are skipped
-r requirements.txt
-c other-constraints.txt
Output Format
The constraints are written to pyproject.toml as:
[tool.uv]
constraint-dependencies = [
"flask>=2.0.0,<3.0.0",
"numpy==1.24.3 ; python_version >= \"3.9\"",
"requests==2.31.0",
"urllib3>=1.26.0",
]
Requirements
- Python >= 3.10
Dependencies
License
MIT
Metadata
Release files for uv-import-constraint-dependencies 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uv_import_constraint_dependencies-0.1.3.tar.gz | 50.6 kB | Without provenance | Details for uv_import_constraint_dependencies-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uv_import_constraint_dependencies-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for uv_import_constraint_dependencies-0.1.3-py3-none-any.whl |
Total release size: 63.4 kB
Release files / uv_import_constraint_dependencies-0.1.3.tar.gz
| Download URL | uv_import_constraint_dependencies-0.1.3.tar.gz |
|---|---|
| Size | 50.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e5738fe2107394db7c81238d209bd5b392426c65c6864bb95270ba275cd7dd4
|
|
BLAKE2b-256 checksum How to use checksums |
b580e0935a0c61c13a55eb82765498879b4699de3f4d1469dff701d0e1304c2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / uv_import_constraint_dependencies-0.1.3-py3-none-any.whl
| Download URL | uv_import_constraint_dependencies-0.1.3-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c359326b99711336c666d1ea33868bfd331956a68027406ecde3118a4fe447bb
|
|
BLAKE2b-256 checksum How to use checksums |
ddcf36873a9835b21296e5865e9a0430776897b12bfbed6aa21dea632af7f321
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Security for uv-import-constraint-dependencies 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.