Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
fix: add tool repository credentials to uv build in tool publish (#5223)
alex-clawd2e2fae02d26f
diff --git a/lib/crewai/src/crewai/cli/tools/main.py b/lib/crewai/src/crewai/cli/tools/main.pyindex 72c1e6e25..67a508e64 100644--- a/lib/crewai/src/crewai/cli/tools/main.py+++ b/lib/crewai/src/crewai/cli/tools/main.py@@ -21,6 +21,7 @@ from crewai.cli.utils import (get_project_description,get_project_name,get_project_version,+ read_toml,tree_copy,tree_find_and_replace,)@@ -116,11 +117,26 @@ class ToolCommand(BaseCommand, PlusAPIMixin):self._print_tools_preview(tools_metadata)self._print_current_organization()+ build_env = os.environ.copy()+ try:+ pyproject_data = read_toml()+ sources = pyproject_data.get("tool", {}).get("uv", {}).get("sources", {})++ for source_config in sources.values():+ if isinstance(source_config, dict):+ index = source_config.get("index")+ if index:+ index_env = build_env_with_tool_repository_credentials(index)+ build_env.update(index_env)+ except Exception: # noqa: S110+ pass+with tempfile.TemporaryDirectory() as temp_build_dir:subprocess.run( # noqa: S603["uv", "build", "--sdist", "--out-dir", temp_build_dir], # noqa: S607check=True,capture_output=False,+ env=build_env,)tarball_filename = next(diff --git a/lib/crewai/tests/cli/tools/test_main.py b/lib/crewai/tests/cli/tools/test_main.pyindex aba6f1075..31032a072 100644--- a/lib/crewai/tests/cli/tools/test_main.py+++ b/lib/crewai/tests/cli/tools/test_main.py@@ -218,6 +218,7 @@ def test_publish_when_not_in_sync_and_force(["uv", "build", "--sdist", "--out-dir", unittest.mock.ANY],check=True,capture_output=False,+ env=unittest.mock.ANY,)mock_open.assert_called_with(unittest.mock.ANY, "rb")mock_publish.assert_called_with(@@ -279,6 +280,7 @@ def test_publish_success(["uv", "build", "--sdist", "--out-dir", unittest.mock.ANY],check=True,capture_output=False,+ env=unittest.mock.ANY,)mock_open.assert_called_with(unittest.mock.ANY, "rb")mock_publish.assert_called_with(