From 7acf6b45b524781e0679bff724ac75554d699351 Mon Sep 17 00:00:00 2001 From: Greyson Lalonde Date: Wed, 6 May 2026 01:55:39 +0800 Subject: [PATCH] fix(cli): ship crewai-cli by default and restore crewai.cli imports --- lib/cli/pyproject.toml | 2 +- lib/crewai/pyproject.toml | 14 +----- lib/crewai/src/crewai/cli/__init__.py | 66 +++++++++++++++++++++++++++ uv.lock | 12 ++--- 4 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 lib/crewai/src/crewai/cli/__init__.py diff --git a/lib/cli/pyproject.toml b/lib/cli/pyproject.toml index 080104cf8..193998192 100644 --- a/lib/cli/pyproject.toml +++ b/lib/cli/pyproject.toml @@ -21,7 +21,7 @@ dependencies = [ "tomli-w~=1.1.0", "packaging>=23.0", "python-dotenv>=1.2.2,<2", - "uv~=0.9.13", + "uv~=0.11.6", ] [project.urls] diff --git a/lib/crewai/pyproject.toml b/lib/crewai/pyproject.toml index fc087673f..0ee41f12d 100644 --- a/lib/crewai/pyproject.toml +++ b/lib/crewai/pyproject.toml @@ -8,8 +8,8 @@ authors = [ ] requires-python = ">=3.10, <3.14" dependencies = [ - # Shared utilities (version, paths, user_data, telemetry, printer) - "crewai-core", + "crewai-core==1.14.5a2", + "crewai-cli==1.14.5a2", # Core Dependencies "pydantic>=2.11.9,<2.13", "openai>=2.30.0,<3", @@ -42,7 +42,6 @@ dependencies = [ "pydantic-settings~=2.10.1", "httpx~=0.28.1", "mcp~=1.26.0", - "uv~=0.11.6", "aiosqlite~=0.21.0", "pyyaml~=6.0", "aiofiles~=24.1.0", @@ -110,20 +109,11 @@ a2a = [ file-processing = [ "crewai-files", ] -cli = [ - "crewai-cli", -] qdrant-edge = [ "qdrant-edge-py>=0.6.0", ] -# CLI entry point has moved to the crewai-cli package. -# Install it via: pip install crewai[cli] -# [project.scripts] -# crewai = "crewai.cli.cli:crewai" - - [tool.uv] exclude-newer = "3 days" diff --git a/lib/crewai/src/crewai/cli/__init__.py b/lib/crewai/src/crewai/cli/__init__.py new file mode 100644 index 000000000..90121677c --- /dev/null +++ b/lib/crewai/src/crewai/cli/__init__.py @@ -0,0 +1,66 @@ +"""Backward-compat shim — re-export ``crewai_cli`` as ``crewai.cli``. + +The CLI was extracted into the standalone ``crewai-cli`` package. Legacy +``from crewai.cli.X import Y`` imports are intercepted here and resolved to +the corresponding ``crewai_cli.X`` module so downstream code keeps working. +""" + +from __future__ import annotations + +from collections.abc import Sequence +import importlib +import importlib.abc +import importlib.machinery +import sys +from types import ModuleType + + +_PREFIX = "crewai.cli" +_TARGET = "crewai_cli" + + +class _ShimLoader(importlib.abc.Loader): + """Returns an already-imported ``crewai_cli`` submodule without re-executing it.""" + + def __init__(self, target_name: str) -> None: + self._target_name = target_name + + def create_module(self, spec: importlib.machinery.ModuleSpec) -> ModuleType: + return importlib.import_module(self._target_name) + + def exec_module(self, module: ModuleType) -> None: + return None + + +class _ShimFinder(importlib.abc.MetaPathFinder): + """Maps ``crewai.cli[.X]`` imports onto ``crewai_cli[.X]``.""" + + def find_spec( + self, + fullname: str, + path: Sequence[str] | None, + target: ModuleType | None = None, + ) -> importlib.machinery.ModuleSpec | None: + if fullname != _PREFIX and not fullname.startswith(_PREFIX + "."): + return None + + mapped = _TARGET + fullname[len(_PREFIX) :] + try: + module = importlib.import_module(mapped) + except ImportError: + return None + + spec = importlib.machinery.ModuleSpec( + name=fullname, + loader=_ShimLoader(mapped), + origin=getattr(module, "__file__", None), + is_package=hasattr(module, "__path__"), + ) + if hasattr(module, "__path__"): + spec.submodule_search_locations = [] + return spec + + +_finder = _ShimFinder() +if _finder not in sys.meta_path: + sys.meta_path.insert(0, _finder) diff --git a/uv.lock b/uv.lock index 8d767547d..a64bd562e 100644 --- a/uv.lock +++ b/uv.lock @@ -1281,6 +1281,7 @@ dependencies = [ { name = "appdirs" }, { name = "chromadb" }, { name = "click" }, + { name = "crewai-cli" }, { name = "crewai-core" }, { name = "httpx" }, { name = "instructor" }, @@ -1306,7 +1307,6 @@ dependencies = [ { name = "tokenizers" }, { name = "tomli" }, { name = "tomli-w" }, - { name = "uv" }, ] [package.optional-dependencies] @@ -1330,9 +1330,6 @@ azure-ai-inference = [ bedrock = [ { name = "boto3" }, ] -cli = [ - { name = "crewai-cli" }, -] docling = [ { name = "docling" }, ] @@ -1388,7 +1385,7 @@ requires-dist = [ { name = "boto3", marker = "extra == 'bedrock'", specifier = "~=1.42.79" }, { name = "chromadb", specifier = "~=1.1.0" }, { name = "click", specifier = "~=8.1.7" }, - { name = "crewai-cli", marker = "extra == 'cli'", editable = "lib/cli" }, + { name = "crewai-cli", editable = "lib/cli" }, { name = "crewai-core", editable = "lib/crewai-core" }, { name = "crewai-files", marker = "extra == 'file-processing'", editable = "lib/crewai-files" }, { name = "crewai-tools", marker = "extra == 'tools'", editable = "lib/crewai-tools" }, @@ -1428,10 +1425,9 @@ requires-dist = [ { name = "tokenizers", specifier = ">=0.21,<1" }, { name = "tomli", specifier = "~=2.0.2" }, { name = "tomli-w", specifier = "~=1.1.0" }, - { name = "uv", specifier = "~=0.11.6" }, { name = "voyageai", marker = "extra == 'voyageai'", specifier = "~=0.3.5" }, ] -provides-extras = ["a2a", "anthropic", "aws", "azure-ai-inference", "bedrock", "cli", "docling", "embeddings", "file-processing", "google-genai", "litellm", "mem0", "openpyxl", "pandas", "qdrant", "qdrant-edge", "tools", "voyageai", "watson"] +provides-extras = ["a2a", "anthropic", "aws", "azure-ai-inference", "bedrock", "docling", "embeddings", "file-processing", "google-genai", "litellm", "mem0", "openpyxl", "pandas", "qdrant", "qdrant-edge", "tools", "voyageai", "watson"] [[package]] name = "crewai-cli" @@ -1468,7 +1464,7 @@ requires-dist = [ { name = "rich", specifier = ">=13.7.1" }, { name = "tomli", specifier = "~=2.0.2" }, { name = "tomli-w", specifier = "~=1.1.0" }, - { name = "uv", specifier = "~=0.9.13" }, + { name = "uv", specifier = "~=0.11.6" }, ] [[package]]