Import constraints.txt into pyproject.toml as tool.uv.constraint-dependencies
Project description
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) |
--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
Behavior
Replace Mode (Default)
By default, all existing constraint-dependencies 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
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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uv_import_constraint_dependencies-0.1.1.tar.gz.
File metadata
- Download URL: uv_import_constraint_dependencies-0.1.1.tar.gz
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc25799cb2a2043c7a13bf2f44b61910b5c59e7f654c40cfb3f9008d73396f1c
|
|
| MD5 |
aeb19bc0b6837843908b7dffb0f3de51
|
|
| BLAKE2b-256 |
2e970ea6546a7c1c6eec5306d2678a99bdca8659b2920dbf63d28c05caee76d8
|
File details
Details for the file uv_import_constraint_dependencies-0.1.1-py3-none-any.whl.
File metadata
- Download URL: uv_import_constraint_dependencies-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb1ffa405afbd146af1d7787d73895b94f8c071ccd6beb4271c57c7da4f16898
|
|
| MD5 |
55a7f47d4512eaa685f64ca05bd081f9
|
|
| BLAKE2b-256 |
0e86ae10d9a222fbb7310b96dcc13a7918fd6ee38e2185d6713547589b4a9b41
|