uv_manager
flavor.packaging.python.uv_manager
¶
TODO: Add module docstring.
Classes¶
UVManager
¶
Bases: BaseToolManager
UV tool manager extending Foundation's BaseToolManager.
Handles UV-specific operations with proper platform support for fast Python package management operations.
CRITICAL: This class is for UV-specific operations where speed matters. For complex dependency resolution, use PyPaPipManager instead.
DO NOT REPLACE PyPA pip commands with uv pip - they have different capabilities!
Initialize the UV manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
BaseConfig | None
|
Foundation configuration (can be None for default) |
None
|
Source code in flavor/packaging/python/uv_manager.py
Functions¶
compile_requirements
¶
compile_requirements(
input_file: Path,
output_file: Path,
python_version: str | None = None,
) -> None
Compile requirements file using UV pip-compile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_file
|
Path
|
Input requirements.in file |
required |
output_file
|
Path
|
Output requirements.txt file |
required |
python_version
|
str | None
|
Target Python version |
None
|
Source code in flavor/packaging/python/uv_manager.py
create_venv
¶
Create virtual environment using UV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venv_path
|
Path
|
Path where venv should be created |
required |
python_version
|
str | None
|
Specific Python version constraint |
None
|
Source code in flavor/packaging/python/uv_manager.py
download_uv_binary
¶
Download UV binary for packaging (manylinux2014 on Linux).
CRITICAL: This downloads the UV binary itself, not packages using UV. UV cannot download itself - this uses PyPA pip or direct download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest_dir
|
Path
|
Directory to save UV binary to |
required |
python_exe
|
Path | None
|
Python executable to use for pip (optional) |
None
|
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to UV binary if successful, None otherwise |
Retries
Up to 3 attempts with exponential backoff for network errors
Source code in flavor/packaging/python/uv_manager.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
find_system_uv
¶
Find system-installed UV executable.
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to UV executable if found, None otherwise |
Source code in flavor/packaging/python/uv_manager.py
get_available_versions
¶
Get list of available UV versions from GitHub releases.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of version strings available for download |
Source code in flavor/packaging/python/uv_manager.py
get_metadata
¶
Get metadata for a specific UV version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
UV version string |
required |
Returns:
| Type | Description |
|---|---|
ToolMetadata
|
ToolMetadata with UV download information |
Raises:
| Type | Description |
|---|---|
ToolNotFoundError
|
If version metadata cannot be retrieved |
Source code in flavor/packaging/python/uv_manager.py
get_uv_executable
¶
Get path to UV executable, installing if necessary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str | None
|
Specific version to use (None for system UV) |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to UV executable |
Raises:
| Type | Description |
|---|---|
ToolNotFoundError
|
If UV cannot be found or installed |
Source code in flavor/packaging/python/uv_manager.py
install_packages_fast
¶
install_packages_fast(
venv_python: Path,
packages: list[str],
requirements_file: Path | None = None,
) -> None
Install packages using UV pip for speed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venv_python
|
Path
|
Python executable in target venv |
required |
packages
|
list[str]
|
List of package names to install |
required |
requirements_file
|
Path | None
|
Optional requirements file |
None
|