Skip to content

Allow openbabel 3.2 so rdkit can be current, importing CoolProp first - #3033

Open
rwest wants to merge 1 commit into
mainfrom
unblock-rdkit-openbabel
Open

rwest wants to merge 1 commit into
mainfrom
unblock-rdkit-openbabel

Conversation

@rwest

@rwest rwest commented Nov 7, 2026

Copy link
Copy Markdown
Member

Summary

On linux-64, environment.yml currently resolves to rdkit 2025.03.6, while conda-forge has 2026.09.2. The cause is the openbabel <3.2 cap. This PR lifts it to openbabel >=3.2.1 and works around the hang that led to the cap in the first place. That hang turned out to be a CoolProp import hang, not a pybel one.

Why rdkit was held back

Every openbabel 3.1.1 build requires libxml2 <2.14, and libxml2 2.13 builds need icu 75 or older. That blocks newer rdkit in two ways:

  • rdkit 2026.x needs cairo >=1.18.6 and libpq >=18.3. Every build of those needs icu 78.
  • rdkit 2025.09.x needs libpq >=18. Full matplotlib (ours, and the one rmg::pysidt-rmg depends on) pulls in pyside6/qt6-main, and every qt6-main build linked against libpq 18 needs libxml2 >=2.14.

The "openbabel 3.2.1 hangs pytest" bug is a CoolProp import hang

  • py-spy showed collection had already passed conftest.py. It was stuck in import CoolProp (reached via arkane → rmgpy.data.solvation), spinning at 100% CPU in CoolProp's static initializer, inside rapidjson's Grisu2.
  • openbabel 3.2.1's JSON format plugins (ket, chemdoodlejson, chemicaljson, pubchemjson) bundle a newer rapidjson than CoolProp 6.7.0 does.
  • rapidjson's function-local static lookup tables are STB_GNU_UNIQUE symbols, so the copy from whichever library loads first is used process-wide, even for plugins opened RTLD_LOCAL.
  • DigitGen()::kPow10 is 40 bytes in CoolProp and 160 bytes in openbabel 3.2.1. openbabel 3.1.1 exports the same symbols with the 40-byte layout, which is why it never hung.
  • pybel dlopens every plugin when it is imported. So from openbabel import pybel; import CoolProp hangs, while import CoolProp; from openbabel import pybel works, and openbabel's JSON writers still work after that.
  • Upgrading CoolProp isn't possible here: 7.x needs fmt 10 and 8.0 needs fmt 12.2, but cantera 3.2.0 pins fmt 12.0.
  • This affects real use, not only tests: arkane/encorr/data.py imports pybel before arkane/pdep imports CoolProp.

Changes

  • import CoolProp before openbabel in rmgpy/molecule/converter.py (full explanation in a comment), rmgpy/molecule/translator.py, arkane/encorr/data.py and test/conftest.py.
  • openbabel >=3.2.1 in both environment.yml and .conda/meta.yaml. Every supported Python has a 3.2.1 build now that 3.9 is dropped. On main, meta.yaml had no upper cap, so this also puts the two files back in sync.

Effect on the solve

mamba 2.9 dry runs:

Target rdkit
linux-64, py3.11 2026.09.2
linux-64, py3.10 2026.03.6 (newest py310 build)
osx-64 2026.09.2
osx-arm64 2026.09.2
  • Other packages that move on linux-64: icu 75→78, libxml2 2.13→2.15, libboost 1.86→1.90, libpq 17→18, cairo 1.18.4→1.18.6, ffmpeg 8→9, graphviz 13→14, qt6-main/pyside6 6.9→6.11, matplotlib 3.10→3.11.
  • Unchanged: numpy, scipy, cantera and h5py.
  • Solve time: the linux-64 solve took about 2 min, compared with about 20 min for the current file under the same machine load.
  • macOS: rdkit 2026.09 needs macOS ≥13.3 (because of libpq 18.6). Older macOS falls back to rdkit 2026.03.5.

Testing

Tested on Linux (Apptainer miniforge3) for py3.10 and py3.11, from fresh environments, against an unpatched main control (openbabel 3.1.1, rdkit 2025.03.6):

  • make install, the rmg.py superminimal example and the Arkane.py n-butanol_msc example all work.
  • pytest --collect-only collects 2324 tests in about 50 s. Without the CoolProp import first, it hangs.
  • make test-all: 2284 passed, 40 skipped, 0 failed on both Pythons.
  • The only errors were 2 restart-test teardowns failing with "Directory not empty" on an NFS home directory. The control run hit them too.
  • macOS was only checked by dry-run solves; CI will be the first macOS test run.

A proper upstream fix (hiding the symbols in the openbabel or coolprop feedstock) has not been filed yet.

🤖 Generated with Claude Code

openbabel was capped below 3.2 because 3.2.1 hung pytest collection on
Linux. That cap is also what held rdkit at 2025.03.6 on linux-64 when
conda-forge has 2026.09.2. Every openbabel 3.1.1 build depends on
libxml2 <2.14, and libxml2 2.13 needs icu <=75. That rules out:
- rdkit 2026.x, which needs cairo >=1.18.6 and libpq >=18.3, all of whose
  builds need icu 78;
- rdkit 2025.09.x, which needs libpq >=18. The full matplotlib package
  (ours, and the one rmg::pysidt-rmg depends on) pulls in pyside6/qt6-main,
  and every qt6-main build linked against libpq 18 needs libxml2 >=2.14.

The hang was never in pybel itself. Collection stopped at
`import CoolProp` (via arkane -> rmgpy.data.solvation), spinning at 100%
CPU in CoolProp's static initializer, inside rapidjson's Grisu2 number
formatting. openbabel 3.2.1's JSON format plugins (ketformat,
chemdoodlejson, chemicaljson, pubchemjson) bundle a newer rapidjson than
CoolProp 6.7.0. The function-local static lookup tables in rapidjson are
STB_GNU_UNIQUE symbols, so the copy from whichever library loads first is
used by the whole process, even for plugins opened RTLD_LOCAL. In CoolProp
`DigitGen()::kPow10` is 10 x uint32 (40 bytes); in openbabel 3.2.1 it is
20 x uint64 (160 bytes). pybel loads every plugin when imported, so when
pybel comes first, CoolProp formats numbers with the wrong table and never
terminates. openbabel 3.1.1's plugins export the same symbols, but with
the old 40-byte layout, which is why it was harmless. Reversing the order
works: `import CoolProp; from openbabel import pybel` is fine, and
openbabel's JSON writers still work afterwards. CoolProp cannot simply be
upgraded: 7.x needs fmt 10 and 8.0 needs fmt 12.2, while cantera 3.2.0
pins fmt 12.0.

So import CoolProp before openbabel in each module that imports openbabel
(rmgpy/molecule/converter.py has the full explanation; also translator.py,
arkane/encorr/data.py and test/conftest.py). Then require openbabel
>=3.2.1 in environment.yml and .conda/meta.yaml. Now that Python 3.9 is
dropped, every supported Python has a 3.2.1 build. A floor, rather than no
bound, keeps the solver from considering the old libxml2/icu 75 stack at
all. meta.yaml previously had no cap at all, so this also puts the two
files back in sync.

Effect on the solve (mamba 2.9 dry runs): linux-64 py3.11 gets rdkit
2026.09.2, py3.10 gets 2026.03.6 (the newest py310 build), and osx-64 and
osx-arm64 get 2026.09.2. Other packages that move on linux-64: icu 75 ->
78, libxml2 2.13 -> 2.15, libboost 1.86 -> 1.90, cairo 1.18.4 -> 1.18.6,
libpq 17 -> 18, ffmpeg 8 -> 9, graphviz 13 -> 14, qt6-main/pyside6 6.9 ->
6.11, matplotlib 3.10 -> 3.11. numpy, scipy, cantera and h5py are
unchanged. The linux-64 solve was also much faster in these runs (about 2
minutes vs. about 20 for the old file, under the same machine load),
because the solver no longer searches for an rdkit that cannot fit.

Tested on Linux (Explorer, Apptainer miniforge3) for py3.10 and py3.11:
fresh env build, `make install`, the rmg.py superminimal and Arkane.py
n-butanol_msc examples, `pytest --collect-only` (2324 tests in about 50 s;
before this change it hung) and `make test-all`, compared against an
unpatched official/main control (openbabel 3.1.1, rdkit 2025.03.6). Both
patched runs: 2284 passed, 40 skipped, 0 failed. The only errors were 2
restart-test teardowns failing with "Directory not empty" on the NFS home
directory, which the control hit too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant