dist_manager
flavor.packaging.python.dist_manager
¶
TODO: Add module docstring.
Classes¶
PythonDistManager
¶
Python distribution manager for FlavorPack packaging.
Handles creation and management of Python distributions including: - Virtual environment creation and management - Package installation from wheels - Distribution validation and preparation - Site-packages optimization for packaging
Initialize the Python distribution manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
python_version
|
str
|
Target Python version for distributions |
'3.11'
|
use_uv_for_venv
|
bool
|
Whether to use UV for fast venv creation |
True
|
Source code in flavor/packaging/python/dist_manager.py
Functions¶
create_python_environment
¶
create_python_environment(
venv_path: Path,
python_exe: Path | None = None,
copy_python: bool = False,
) -> Path
Create a Python virtual environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venv_path
|
Path
|
Path where venv should be created |
required |
python_exe
|
Path | None
|
Specific Python executable to use |
None
|
copy_python
|
bool
|
Whether to copy Python binary instead of symlink |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the Python executable in the created venv |
Source code in flavor/packaging/python/dist_manager.py
create_standalone_distribution
¶
create_standalone_distribution(
project_dir: Path,
output_dir: Path,
requirements_file: Path | None = None,
extra_packages: list[str] | None = None,
python_exe: Path | None = None,
) -> dict[str, Any]
Create a complete standalone Python distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
Path
|
Project source directory |
required |
output_dir
|
Path
|
Directory for distribution output |
required |
requirements_file
|
Path | None
|
Optional requirements file |
None
|
python_exe
|
Path | None
|
Specific Python executable to use |
None
|
extra_packages
|
list[str] | None
|
Additional packages to include |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with distribution information and paths |
Source code in flavor/packaging/python/dist_manager.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 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 | |
install_wheels_to_environment
¶
install_wheels_to_environment(
venv_python: Path,
wheel_files: list[Path],
force_reinstall: bool = False,
) -> None
Install wheel files to a Python environment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venv_python
|
Path
|
Python executable in target environment |
required |
wheel_files
|
list[Path]
|
List of wheel files to install |
required |
force_reinstall
|
bool
|
Whether to force reinstall packages |
False
|
Source code in flavor/packaging/python/dist_manager.py
prepare_site_packages
¶
Prepare site-packages directory for packaging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
venv_python
|
Path
|
Python executable in environment |
required |
optimization_level
|
int
|
Python bytecode optimization level |
1
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to the prepared site-packages directory |
Source code in flavor/packaging/python/dist_manager.py
validate_distribution
¶
Validate a created distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dist_info
|
dict[str, Any]
|
Distribution information dictionary |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if distribution is valid, False otherwise |