Update workspace dependency versions in pyproject.toml. Args: file_path: Path to pyproject.toml file. new_version: New version string. extra_packages: Additional package names to update beyond the defaults. Returns: True if any dependencies were updated, Fal
(
file_path: Path,
new_version: str,
extra_packages: list[str] | None = None,
)
| 338 | |
| 339 | |
| 340 | def update_pyproject_dependencies( |
| 341 | file_path: Path, |
| 342 | new_version: str, |
| 343 | extra_packages: list[str] | None = None, |
| 344 | ) -> bool: |
| 345 | """Update workspace dependency versions in pyproject.toml. |
| 346 | |
| 347 | Args: |
| 348 | file_path: Path to pyproject.toml file. |
| 349 | new_version: New version string. |
| 350 | extra_packages: Additional package names to update beyond the defaults. |
| 351 | |
| 352 | Returns: |
| 353 | True if any dependencies were updated, False otherwise. |
| 354 | """ |
| 355 | if not file_path.exists(): |
| 356 | return False |
| 357 | |
| 358 | content = file_path.read_text() |
| 359 | lines = content.splitlines() |
| 360 | updated = False |
| 361 | |
| 362 | workspace_packages = _DEFAULT_WORKSPACE_PACKAGES + (extra_packages or []) |
| 363 | |
| 364 | current_extra: str | None = None |
| 365 | extra_header = re.compile(r"^\s*([A-Za-z0-9_-]+)\s*=\s*\[") |
| 366 | |
| 367 | for i, line in enumerate(lines): |
| 368 | match = extra_header.match(line) |
| 369 | if match: |
| 370 | current_extra = match.group(1) |
| 371 | elif line.strip().startswith("]"): |
| 372 | current_extra = None |
| 373 | |
| 374 | for pkg in workspace_packages: |
| 375 | if pkg == "crewai-files" and current_extra == "file-processing": |
| 376 | continue |
| 377 | if f"{pkg}==" in line: |
| 378 | stripped = line.lstrip() |
| 379 | indent = line[: len(line) - len(stripped)] |
| 380 | |
| 381 | if '"' in line: |
| 382 | lines[i] = f'{indent}"{pkg}=={new_version}",' |
| 383 | elif "'" in line: |
| 384 | lines[i] = f"{indent}'{pkg}=={new_version}'," |
| 385 | else: |
| 386 | lines[i] = f"{indent}{pkg}=={new_version}," |
| 387 | |
| 388 | updated = True |
| 389 | |
| 390 | if updated: |
| 391 | file_path.write_text("\n".join(lines) + "\n") |
| 392 | return True |
| 393 | |
| 394 | return False |
| 395 | |
| 396 | |
| 397 | def add_docs_version(docs_json_path: Path, version: str) -> bool: |