Skip to content

Commit b65c8b6

Browse files
authored
uprev Pyodide to 0.27.6 (#1944)
1 parent ae0c3ce commit b65c8b6

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ jobs:
247247

248248
- run: make lint-js
249249

250-
- run: uv run --package mcp-run-python pytest mcp-run-python -v
250+
- run: uv run --package mcp-run-python pytest mcp-run-python -v --durations=100
251251

252252
- run: deno task dev warmup
253253
working-directory: mcp-run-python

mcp-run-python/deno.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pydantic/mcp-run-python",
3-
"version": "0.0.14",
3+
"version": "0.0.15",
44
"license": "MIT",
55
"nodeModulesDir": "auto",
66
"exports": {
@@ -16,7 +16,8 @@
1616
"@modelcontextprotocol/sdk": "npm:@modelcontextprotocol/sdk@^1.8.0",
1717
"@std/cli": "jsr:@std/cli@^1.0.15",
1818
"@std/path": "jsr:@std/path@^1.0.8",
19-
"pyodide": "npm:pyodide@0.27.3",
19+
// do NOT upgrade above this version until there is a workaround for https://github.com/pyodide/pyodide/pull/5621
20+
"pyodide": "npm:pyodide@0.27.6",
2021
"zod": "npm:zod@^3.24.2"
2122
},
2223
"fmt": {

mcp-run-python/deno.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mcp-run-python/src/runCode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function runCode(
1313
files: CodeFile[],
1414
log: (level: LoggingLevel, data: string) => void,
1515
): Promise<RunSuccess | RunError> {
16-
// remove once https://github.com/pyodide/pyodide/pull/5514 is released
16+
// remove once we can upgrade to pyodide 0.27.7 and console.log is no longer used.
1717
const realConsoleLog = console.log
1818
// deno-lint-ignore no-explicit-any
1919
console.log = (...args: any[]) => log('debug', args.join(' '))

mcp-run-python/test_mcp_servers.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from __future__ import annotations as _annotations
22

33
import asyncio
4+
import re
45
import subprocess
56
from collections.abc import AsyncIterator
7+
from pathlib import Path
68
from typing import TYPE_CHECKING
79

810
import pytest
@@ -161,3 +163,43 @@ async def test_run_python_code(mcp_session: ClientSession, code: list[str], expe
161163
content = result.content[0]
162164
assert isinstance(content, types.TextContent)
163165
assert content.text == expected_output
166+
167+
168+
async def test_install_run_python_code() -> None:
169+
node_modules = Path(__file__).parent / 'node_modules'
170+
if node_modules.exists():
171+
# shutil.rmtree can't delete node_modules :-(
172+
subprocess.run(['rm', '-r', node_modules], check=True)
173+
174+
logs: list[str] = []
175+
176+
async def logging_callback(params: types.LoggingMessageNotificationParams) -> None:
177+
logs.append(f'{params.level}: {params.data}')
178+
179+
server_params = StdioServerParameters(command='deno', args=[*DENO_ARGS, 'stdio'])
180+
async with stdio_client(server_params) as (read, write):
181+
async with ClientSession(read, write, logging_callback=logging_callback) as mcp_session:
182+
await mcp_session.initialize()
183+
await mcp_session.set_logging_level('debug')
184+
result = await mcp_session.call_tool(
185+
'run_python_code', {'python_code': 'import numpy\nnumpy.array([1, 2, 3])'}
186+
)
187+
assert len(result.content) == 1
188+
content = result.content[0]
189+
assert isinstance(content, types.TextContent)
190+
expected_output = """\
191+
<status>success</status>
192+
<dependencies>["numpy"]</dependencies>
193+
<return_value>
194+
[
195+
1,
196+
2,
197+
3
198+
]
199+
</return_value>\
200+
"""
201+
assert content.text == expected_output
202+
assert len(logs) >= 18
203+
assert re.search(
204+
r"debug: Didn't find package numpy\S+?\.whl locally, attempting to load from", '\n'.join(logs)
205+
)

0 commit comments

Comments
 (0)