Skip to content

Conversation

@franzpoeschel
Copy link
Contributor

See also #1839
Updating toml11 and nlohmann_json is needed for CMake 4

@franzpoeschel franzpoeschel added this to the 0.17.1 milestone Jan 19, 2026
@franzpoeschel franzpoeschel added the dependencies Pull requests that update a dependency file label Jan 19, 2026
@franzpoeschel franzpoeschel force-pushed the version-bump-json-toml branch from cd56ff7 to 088c8c9 Compare January 19, 2026 10:08
This reverts commit bc1817d.
Pybind's variant handling explodes MSVC, so we do it instead.
@franzpoeschel
Copy link
Contributor Author

franzpoeschel commented Jan 19, 2026

Pybind11 3.0.1 seems to explode MSVC:

  Attributable.cpp
c:\projects\openpmd-api\build\_deps\fetchedpybind11-src\include\pybind11\detail/descr.h(50): fatal error C1202: recursive type or function dependency context too complex [C:\projects\openpmd-api\build\openPMD.py.vcxproj]

It looks like these troubles are caused by Attributable.get_attribute() since that returns a std::variant type of 30~40 options, which Pybind11 is then supposed to convert to a plausible Python value.

I think that the following workaround could fix it, by never exposing the std::variant type to Pybind11:

             "get_attribute",
             [](Attributable &attr, std::string const &key) {
                 auto v = attr.getAttribute(key);
-                return v.getVariant<attribute_types>();
+                return std::visit(
+                    [](auto const &val) { return py::cast(val); },
+                    v.getVariant<attribute_types>());
                 // TODO instead of returning lists, return all arrays (ndim > 0)
                 // as numpy arrays?
             })

@franzpoeschel franzpoeschel changed the title Bump toml11 to 4.4.0, nlohmann_json to 3.12.0, pybind11to 3.0.1 Bump toml11 to 4.4.0, nlohmann_json to 3.12.0 Jan 19, 2026
@franzpoeschel
Copy link
Contributor Author

Ok, the above workaround did help, however pybind11 still crashes MSVC:

c:\projects\openpmd-api\build\_deps\fetchedpybind11-src\include\pybind11\pybind11.h(3008): fatal error C1001: An internal error has occurred in the compiler. [C:\projects\openpmd-api\build\openPMD.py.vcxproj]
  (compiler file 'd:\agent\_work\8\s\src\vctools\compiler\utc\src\p2\main.c', line 187)
   To work around this problem, try simplifying or changing the program near the locations listed above.
  Please choose the Technical Support command on the Visual C++ 
   Help menu, or open the Technical Support help file for more information
  Internal Compiler Error in C:\Program Files (x86)\Microsoft Visual

Upgrading toml11 and nlohmann_json is more pressing due to the CMake issues, I will bother with the pybind stuff later.

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

Labels

dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant