Skip to content

fix(core): make uuid-utils optional for pyodide/emscripten support#36065

Closed
Vikash sharma (Vikx001) wants to merge 1 commit intolangchain-ai:masterfrom
Vikx001:fix/core-pyodide-uuid-utils-optional
Closed

fix(core): make uuid-utils optional for pyodide/emscripten support#36065
Vikash sharma (Vikx001) wants to merge 1 commit intolangchain-ai:masterfrom
Vikx001:fix/core-pyodide-uuid-utils-optional

Conversation

@Vikx001
Copy link
Copy Markdown

Why

Fixes #35881

langchain-core depends on uuid-utils, a Rust-compiled package that has
no Pyodide/WebAssembly wheel. When users try to install langchain in
Pyodide (CPython on WebAssembly/Emscripten),
micropip fails with:

ValueError: Can't find a pure Python 3 wheel for: 'uuid-utils<1.0,>=0.12.0'

Changes

  • pyproject.toml: Added sys_platform != 'emscripten' marker to the
    uuid-utils dependency so it is skipped on Pyodide, where
    sys.platform == 'emscripten'.

  • langchain_core/utils/uuid.py: Changed the uuid-utils import to a
    try/except ImportError guard and added a pure-Python UUIDv7 fallback
    (_uuid7_python). The fallback implements RFC 9562 §5.7 Method 1 with a
    monotonic 42-bit counter, thread-safe clock-regression handling, and a
    32-bit random tail — matching the behaviour of the uuid-utils implementation.

  • tests/unit_tests/utils/test_uuid_utils.py: Added 6 new tests covering
    the pure-Python fallback (timestamp accuracy, version/variant fields, return
    type, monotonicity, same-millisecond ordering, and clock-regression handling).

Areas needing review

  • The pure-Python UUIDv7 bit layout in _uuid7_python — specifically the
    counter split (12-bit counter_hi / 30-bit counter_lo) and the variant
    bits should be verified against RFC 9562 §5.7.
  • Note: langsmith also requires uuid-utils and orjson, and
    langgraph-checkpoint requires ormsgpack — full Pyodide support will
    additionally require changes in those external repos.

This contribution was developed with the assistance of GitHub Copilot (AI).

Add sys_platform != 'emscripten' marker to the uuid-utils dependency
so it is skipped when installing in Pyodide (WebAssembly/Emscripten),
where Rust-compiled wheels are unavailable.

Add a pure-Python UUIDv7 fallback (_uuid7_python) that is used
automatically when uuid-utils cannot be imported. The fallback
implements RFC 9562 §5.7 Method 1 with a monotonic 42-bit counter,
thread-safe clock-regression handling, and 32-bit random tail.

Closes langchain-ai#35881
@github-actions github-actions Bot added core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) fix For PRs that implement a fix size: S 50-199 LOC labels Mar 18, 2026
@github-actions
Copy link
Copy Markdown

This PR has been automatically closed because you are not assigned to the linked issue.

External contributors must be assigned to an issue before opening a PR for it. Please:

  1. Comment on the linked issue to request assignment from a maintainer
  2. Once assigned, edit your PR description and the PR will be reopened automatically

@github-actions github-actions Bot closed this Mar 18, 2026
@Vikx001
Copy link
Copy Markdown
Author

Hi Eugene Yurtsev (@eyurtsev) can you please assign me to this issue, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core `langchain-core` package issues & PRs dependencies Pull requests that update a dependency file (e.g. `pyproject.toml` or `uv.lock`) external fix For PRs that implement a fix missing-issue-link new-contributor size: S 50-199 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

support run langchain in pyodide

2 participants