fix(core): make uuid-utils optional for pyodide/emscripten support#36065
Closed
Vikash sharma (Vikx001) wants to merge 1 commit intolangchain-ai:masterfrom
Closed
fix(core): make uuid-utils optional for pyodide/emscripten support#36065Vikash sharma (Vikx001) wants to merge 1 commit intolangchain-ai:masterfrom
Vikash sharma (Vikx001) wants to merge 1 commit intolangchain-ai:masterfrom
Conversation
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
|
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:
|
Author
|
Hi Eugene Yurtsev (@eyurtsev) can you please assign me to this issue, thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #35881
langchain-coredepends onuuid-utils, a Rust-compiled package that hasno Pyodide/WebAssembly wheel. When users try to install
langchaininPyodide (CPython on WebAssembly/Emscripten),
micropipfails with:Changes
pyproject.toml: Addedsys_platform != 'emscripten'marker to theuuid-utilsdependency so it is skipped on Pyodide, wheresys.platform == 'emscripten'.langchain_core/utils/uuid.py: Changed theuuid-utilsimport to atry/except ImportErrorguard and added a pure-Python UUIDv7 fallback(
_uuid7_python). The fallback implements RFC 9562 §5.7 Method 1 with amonotonic 42-bit counter, thread-safe clock-regression handling, and a
32-bit random tail — matching the behaviour of the
uuid-utilsimplementation.tests/unit_tests/utils/test_uuid_utils.py: Added 6 new tests coveringthe pure-Python fallback (timestamp accuracy, version/variant fields, return
type, monotonicity, same-millisecond ordering, and clock-regression handling).
Areas needing review
_uuid7_python— specifically thecounter split (12-bit
counter_hi/ 30-bitcounter_lo) and the variantbits should be verified against RFC 9562 §5.7.
langsmithalso requiresuuid-utilsandorjson, andlanggraph-checkpointrequiresormsgpack— full Pyodide support willadditionally require changes in those external repos.