From 790a4a1a10ab336029a40731ea96f4b4e4b8c3b7 Mon Sep 17 00:00:00 2001 From: Josh Rogers Date: Wed, 27 May 2026 16:31:55 -0400 Subject: [PATCH] run pip check before edittable install --- libs/cli/langgraph_cli/config.py | 18 ++++++++---------- libs/cli/tests/unit_tests/test_config.py | 14 ++++++++++---- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/libs/cli/langgraph_cli/config.py b/libs/cli/langgraph_cli/config.py index 3fc00e119..16877d80a 100644 --- a/libs/cli/langgraph_cli/config.py +++ b/libs/cli/langgraph_cli/config.py @@ -66,16 +66,7 @@ def _get_pip_cleanup_lines( to_uninstall: tuple[str] | None, pip_installer: Literal["uv", "pip"], ) -> str: - commands = [ - ( - "# -- Ensure user deps didn't inadvertently overwrite langgraph-api\n" - "RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license && \\\n" - "touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py\n" - f"RUN PYTHONDONTWRITEBYTECODE=1 {install_cmd} --no-cache-dir --no-deps -e /api\n" - "# -- End of ensuring user deps didn't inadvertently overwrite langgraph-api --\n" - "# -- Validate installed dependencies are internally consistent --" - ) - ] + commands = ["# -- Validate installed dependencies are internally consistent --"] if pip_installer == "uv": commands.append( """RUN uv pip check --system || ( \ @@ -94,6 +85,13 @@ exit 1 \ ) commands.append( """# -- End dependency validation -- +# -- Ensure user deps didn't inadvertently overwrite langgraph-api +RUN mkdir -p /api/langgraph_api /api/langgraph_runtime /api/langgraph_license && \ +touch /api/langgraph_api/__init__.py /api/langgraph_runtime/__init__.py /api/langgraph_license/__init__.py +RUN PYTHONDONTWRITEBYTECODE=1 """ + + install_cmd + + """ --no-cache-dir --no-deps -e /api +# -- End of ensuring user deps didn't inadvertently overwrite langgraph-api -- # -- Removing build deps from the final image ~<:===~~~ --""" ) if to_uninstall: diff --git a/libs/cli/tests/unit_tests/test_config.py b/libs/cli/tests/unit_tests/test_config.py index 8e026f210..b0c9c3387 100644 --- a/libs/cli/tests/unit_tests/test_config.py +++ b/libs/cli/tests/unit_tests/test_config.py @@ -1386,6 +1386,9 @@ def test_get_pip_cleanup_lines_selects_check_command_by_installer(): ) assert "RUN uv pip check --system" in cleanup_uv assert "python -m pip check" not in cleanup_uv + assert cleanup_uv.index("RUN uv pip check --system") < cleanup_uv.index( + "RUN mkdir -p /api/langgraph_api" + ) cleanup_pip = _get_pip_cleanup_lines( install_cmd="pip install", @@ -1394,6 +1397,9 @@ def test_get_pip_cleanup_lines_selects_check_command_by_installer(): ) assert "RUN python -m pip check" in cleanup_pip assert "uv pip check --system" not in cleanup_pip + assert cleanup_pip.index("RUN python -m pip check") < cleanup_pip.index( + "RUN mkdir -p /api/langgraph_api" + ) def test_config_to_docker_uv_lock(): @@ -2518,7 +2524,7 @@ def test_config_to_compose_simple_config(): def test_config_to_compose_env_vars(): graphs = {"agent": "./agent.py:graph"} expected_compose_stdin = f""" OPENAI_API_KEY: "key" - + pull_policy: build build: context: . @@ -2601,7 +2607,7 @@ def test_config_to_compose_env_file(): def test_config_to_compose_watch(): graphs = {"agent": "./agent.py:graph"} expected_compose_stdin = f"""\ - + pull_policy: build build: context: . @@ -2627,7 +2633,7 @@ def test_config_to_compose_watch(): ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}' {textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")} WORKDIR /deps/outer-unit_tests/unit_tests - + develop: watch: - path: test_config.json @@ -2674,7 +2680,7 @@ def test_config_to_compose_end_to_end(): ENV LANGSERVE_GRAPHS='{{"agent": "/deps/outer-unit_tests/unit_tests/agent.py:graph"}}' {textwrap.indent(textwrap.dedent(FORMATTED_CLEANUP_LINES), " ")} WORKDIR /deps/outer-unit_tests/unit_tests - + develop: watch: - path: test_config.json