Skip to content

RDkit pyodide support added#538

Open
stefdoerr wants to merge 7 commits intopyodide:mainfrom
stefdoerr:rdkit
Open

RDkit pyodide support added#538
stefdoerr wants to merge 7 commits intopyodide:mainfrom
stefdoerr:rdkit

Conversation

@stefdoerr
Copy link
Copy Markdown

@stefdoerr stefdoerr commented Mar 18, 2026

Added the rdkit package with tests. I tested it a decent bit and it seems to work fine.
For transparency, this is 99% 🤖-generated code with Claude, I mostly intervened to keep it in line with our requirements and asking it to simplify things.

These are probably the only missing features compared to the full RDKit PyPI build:

● ┌──────────────────────────┬─────────────────────────────────────────────────────────┬──────────────────────────────────────┐
  │         Feature          │                      What it does                       │        Why missing in Pyodide        │
  ├──────────────────────────┼─────────────────────────────────────────────────────────┼──────────────────────────────────────┤
  │ RDK_BUILD_THREADSAFE_SSS │ Thread-safe substructure searching                      │ WASM lacks pthreads in most browsers │
  ├──────────────────────────┼─────────────────────────────────────────────────────────┼──────────────────────────────────────┤
  │ RDK_OPTIMIZE_POPCNT      │ SSE4.2 popcount CPU instruction for faster fingerprints │ x86-specific, not available in WASM  │
  ├──────────────────────────┼─────────────────────────────────────────────────────────┼──────────────────────────────────────┤
  │ RDK_USE_BOOST_STACKTRACE │ Verbose stack traces on invariant violations            │ Linux-only, not applicable to WASM   │
  ├──────────────────────────┼─────────────────────────────────────────────────────────┼──────────────────────────────────────┤
  │ RDK_TEST_MULTITHREADED   │ Run multithreaded tests                                 │ No threading in WASM                 │
  └──────────────────────────┴─────────────────────────────────────────────────────────┴──────────────────────────────────────┘

@stefdoerr
Copy link
Copy Markdown
Author

stefdoerr commented Mar 18, 2026

This is interesting. It works on a Chrome browser which we tested yet fails here in the Chrome tests (Firefox tests and node passed). The error suggests that the core.so file at 22MB is too large to be loaded synchronously on Chrome so Claude now converted it to a dynlib so it can be loaded by pyodide asynchronously. To do that it had to split rdkit into rdkit and librdkit packages. Let's see if it's all in its imagination by running the tests here :P

[80](https://github.com/pyodide/pyodide-recipes/actions/runs/23238648273/job/67557269203#step:11:2881)
FAILED packages/rdkit/test_rdkit.py::test_smiles_parsing[chrome] - pyodide.ffi.JsException: RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 8MB. Use WebAssembly.compile, compile on a worker thread, or use the flag `--enable-features=WebAssemblyUnlimitedSyncCompilation`.[80](https://github.com/pyodide/pyodide-recipes/actions/runs/23238648273/job/67557269203#step:11:2881)
FAILED packages/rdkit/test_rdkit.py::test_smiles_parsing[chrome] - pyodide.ffi.JsException: RangeError: WebAssembly.Compile is disallowed on the main thread, if the buffer size is larger than 8MB. Use WebAssembly.compile, compile on a worker thread, or use the flag `--enable-features=WebAssemblyUnlimitedSyncCompilation`.

@stefdoerr
Copy link
Copy Markdown
Author

Works now! I'll try one more thing to simplify the linking

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 18, 2026

Package Build Results

Total packages built: 24
Total build time: 0:55:20

Package Build Times (click to expand)
Package Build Time
librdkit 49m 41s
libboost-python 4m 39s
numpy 3m 1s
rdkit 39s
libzlib 19s
regex 11s
pydoc_data 4s
MarkupSafe 3s
atomicwrites 2s
micropip 1s
exceptiongroup 1s
more-itertools 1s
pytest-asyncio 1s
Jinja2 1s
attrs 1s
setuptools 1s
py 1s
pytz 1s
tblib 1s
pytest 1s
iniconfig 0s
pyparsing 0s
pluggy 0s
six 0s

Longest build: librdkit (49m 41s)
Packages built in more than 10 minutes: 1

@fxcoudert fxcoudert mentioned this pull request Mar 18, 2026
@stefdoerr
Copy link
Copy Markdown
Author

Ok, it's good to go now

@ryanking13
Copy link
Copy Markdown
Member

@stefdoerr

image

Thanks for working on this! The PR looks good overall, but what I am concerned is the librdkit takes around 50mins to build. Regarding that this repository rebuild every package for each commit that goes to the main branch (at least for now), adding 50+ minutes of build time in our CI is a huge overhead.

Regarding you and @fxcoudert were discussing this in rdkit repository (rdkit/rdkit#7827), would you be possible to upstream this change to rdkit itself; i.e. building WASM version in rdkit CI, and only add the built wheel here?

For instance, we are doing the same thing for duckdb. It is built in a separate repository so that we don't need to rebuild it everytime.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants