Skip to content

openmc with hard to merge extras - #145

Open
shimwell wants to merge 239 commits into
developfrom
openmc-with-hard-to-merge-extras
Open

shimwell wants to merge 239 commits into
developfrom
openmc-with-hard-to-merge-extras

Conversation

@shimwell

@shimwell shimwell commented Nov 5, 2026

Copy link
Copy Markdown
Owner

This includes these other branches for convenience:

shimwell and others added 28 commits August 5, 2026 17:52
Build Windows wheels and fix the DLL the loader picks
Add CI guard against C++ alternative operator tokens
The Windows wheel test only imported openmc and read openmc.lib symbols,
which passes even when the openmc executable can not be launched at all.
The Mac OS test ran openmc --version but no simulation, and the Linux
test ran openmc --version with a || echo that discarded the exit code.

Adds minimal_test_csg.py, a CSG only simulation that uses the nuclear
data already committed for minimal_test.py, so it can run on the vanilla
Windows wheel which has no DAGMC. It goes through model.run() so the
openmc executable and the console script that launches it are covered.

Windows and Mac OS now run the CLI check and the simulation, Mac OS also
runs the DAGMC minimal_test.py, and the Linux Dockerfile no longer
swallows the exit code of openmc --version.
The launcher was a plain script file generated by cmake/GenerateScript.cmake
that called os.execv on a path with no .exe suffix. On Windows the
packaging tools install a plain script file without any extension, which
Windows can not execute, so nothing named openmc was resolvable on the
PATH and both the command line and openmc.run() failed with WinError 2.
os.execv is also wrong on Windows as it does not replace the calling
process, so a caller waiting on it would carry on immediately.

Declaring openmc as a console script entry point gets an openmc.exe
launcher generated on Windows and an ordinary script elsewhere.
GenerateScript.cmake is removed as the entry point replaces it.

Also restores openmc --version to the Windows cibuildwheel test-command,
checks the output of openmc --version rather than only its exit status,
since the previous bash check passed while printing nothing, and adds
diagnostics that run the executable directly and list its DLL
dependencies to explain why it exits without any output.
quiet_dll called sys.stdout.fileno() to redirect the output of the
shared library. In a Jupyter notebook sys.stdout is an ipykernel
OutStream, which raises io.UnsupportedOperation from fileno() unless the
kernel is capturing output at the file descriptor level, so anything
going through quiet_dll raised. Model.plot() does, which made it fail in
a notebook on Mac OS while working on Linux.

Suppressing the output is only cosmetic so it is now skipped when there
is no file descriptor to redirect, rather than raising.
The only conflict was in include/openmc/settings.h, where develop gained
the same C linkage for run_mode and rel_max_lost_particles from openmc-dev#4050
that this branch added for the Windows DLL exports. Resolved by keeping
develop's linkage together with this branch's OPENMC_API annotations and
the openmc/export.h include, which develop does not have.
libopenmc.dll imports hdf5.dll and hdf5_hl.dll, which are bundled into
the wheel by delvewheel and placed in a folder beside the package. The
injected os.add_dll_directory calls only apply to the Python process, so
importing openmc.lib works while the executable, which runs as a
separate process, exits without writing anything at all. That is why the
error was an empty output and a non zero status rather than a message.

The console script now passes an environment with those folders on the
PATH, and tools/ci/check_windows_wheel.py reports the layout, the DLL
imports of each binary and where each one resolves to, so the next
failure of this kind is readable from the build log. It replaces the
Windows test-command so the diagnostics are printed even when the checks
fail, which matters because a failing test-command stops cibuildwheel
producing a wheel for the test job to look at.
The Windows wheel did not contain HDF5 at all. There was no
openmc.libs folder, because delvewheel only analyses the extension
modules in a wheel by default and openmc has none, it is pure Python
calling libopenmc.dll through ctypes, so delvewheel had nothing to look
at and vendored nothing. --analyze-existing makes it inspect the DLLs
already in the wheel.

This went unnoticed because h5py bundles its own copy of HDF5 and adds it
to the DLL search path of the process, so importing openmc.lib worked and
happened to bind libopenmc.dll against h5py's HDF5. The openmc executable
is a separate process that gets none of that and failed with 0xC0000135
STATUS_DLL_NOT_FOUND, writing nothing at all.

The check script now reports what was vendored and where h5py's HDF5 is,
so this is visible rather than inferred, and declares the return types of
the kernel32 calls it uses. Without them ctypes truncated the 64 bit
module handles to c_int and every DLL was reported at the same empty
path.
Brings in the wheel tests that run the command line interface and a
simulation on all three platforms, the openmc console script entry
point, the HDF5 bundling fix for the Windows wheel and the quiet_dll
fix for notebooks.
Upstream replaced the exported C API globals with accessor functions,
which supersedes most of the Windows symbol visibility work on this
branch. openmc/lib no longer reads a single global through ctypes
in_dll, so only functions cross the library boundary now.

Seven conflicts, resolved as follows.

CMakeLists.txt: keep develop's libopenmc_objects object library, but
build libopenmc SHARED on MSVC as well, because openmc.lib loads it with
ctypes.CDLL and cannot load a static library. WINDOWS_EXPORT_ALL_SYMBOLS
is enough now that no data symbol is exported. The branch's SKBUILD
install layout, RPATH handling and console script wiring are kept.

include/openmc/capi.h: take develop. openmc_err_msg is gone and
openmc_get_err_msg replaces it.

include/openmc/settings.h: take develop. run_mode and solver_type are
reached through openmc_setting_get_int32 rather than read directly.

include/openmc/dagmc.h, mesh.h and output.h: take develop. DAGMC_ENABLED,
UWUW_ENABLED, LIBMESH_ENABLED and STRICT_FP_ENABLED are replaced by
openmc_get_feature_enabled.

openmc/lib/__init__.py: develop's ctypes imports and feature_enabled,
with the branch's openmc.lib[0] loader kept, because the wheel installs
the library under openmc/core rather than openmc/lib.
include/openmc/export.h existed because openmc.lib read 24 globals across
the library boundary with ctypes in_dll, and WINDOWS_EXPORT_ALL_SYMBOLS
emits functions and mutable data but not read-only data, so the const
flags were silently absent from the export table.

Upstream removed the reason for it. openmc_get_feature_enabled replaced
the four const bool flags, openmc_get_err_msg replaced the openmc_err_msg
buffer, and openmc_setting_get_* and set_* replaced everything
openmc/lib/settings.py reached through the _DLLGlobal descriptor. There
is no in_dll call left anywhere in openmc/, and src/main.cpp is now a
single call to openmc_main, so no data symbol crosses the boundary at
all. The C++ unit tests link libopenmc_test, a static library over the
same objects, so they do not cross it either.

With every annotated declaration reverted to its upstream form by the
merge, export.h had no users left. Keeping it wired would have been worse
than deleting it: libopenmc has no sources of its own now, so
OPENMC_BUILDING_LIBOPENMC on that target compiles nothing, and moving it
to libopenmc_objects would propagate a PUBLIC OPENMC_DLL through
libopenmc_test into every Catch2 test unit and make statically linked
test code see __declspec(dllimport).

Also updates the two Windows CI checks that tested the old contract. The
wheel diagnostics called openmc.lib._dagmc_enabled and friends, which no
longer exist and would have raised AttributeError under a step that
GitHub runs with -e. The probe checked 24 data symbols by name, ten of
which are gone and the rest of which are name mangled C++ globals; it now
checks that the C API functions openmc.lib depends on are exported, which
is the contract that actually has to hold. The pyproject rationale for
OPENMC_BUILD_TESTS=OFF described an LNK2019 failure that upstream openmc-dev#4062
made impossible.
The pin was still 0.15.3 while this branch sits 247 commits past the
v0.16.0 tag, so every wheel built here was stamped with a released
version number it did not contain. pip compares version strings, not
file contents, so a rebuilt 0.15.3 wheel published to an index looks
like no upgrade at all to anyone who already installed one.

0.16.1.dev0 is what setuptools_scm guess-next-dev would produce after
v0.16.0. It sorts above 0.16.0 and below a future 0.16.1.
The develop merge moved the package version to 0.16.1.dev0, so the COPY of the 0.15.3 wheel failed. Glob the version instead.
Resolve gha-install.sh conflict by keeping the branch's removal of the
editable install. Restore the Python package install in gha-install.py,
which the previous develop merge dropped, adding the desc extra and XDG
options.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
The nickel moves during cooling and is then removed from both the
geometry and the source map, leaving the activated iron slab as the
only emitter. The photon animation contrasts strong attenuation by the
iron with negligible attenuation by the H1 slab.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
…ernel index

Replay now drops births below the destination photon energy cutoff and
excludes them from the photon source rate. External source sites are
only checked against the cutoff at their first collision, so these
photons could otherwise score a first flight. The production bank keeps
every birth.

Target instance checks use only as many lattice indices as the lattice
has dimensions, so 2-D hexagonal lattices resolve to their instance.

Nonzero observations restore DistribcellFilter paths from the target
geometry, matching the zero-source branch, so DataFrames work.

kernel_index now indexes the returned provenance kernels list, which
omits kernels with no surviving births.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
…arrow

The CAD example builds the same solids with CadQuery and meshes them to
DAGMC with cad_to_dagmc using the cad-to-dagmc-mesher backend. It shares
the schedule, mesh and plotting with the CSG example. The neutron source
marker is now an arrow along the beam direction.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
D1S writes a statepoint only at the final batch. A caller sourcepoint
schedule such as batches [1, 3] stored in the statepoint was then no
longer a subset of the statepoint batches, and the backend rejected the
input. Drop the sourcepoint batches so the backend follows the
statepoint, keeping the other sourcepoint options.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
The import name stays openmc. Wheel filenames and the version lookup
follow the new distribution name.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
Packages that require openmc must still be satisfied by this build, so
the distribution name goes back to openmc. A local version label
separates these wheels from plain openmc wheels of the same version.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
A local version label separates these wheels from plain openmc wheels
of the same version, while the openmc distribution name still satisfies
packages that require openmc.

Co-authored-by: jon-proximafusion <174589458+jon-proximafusion@users.noreply.github.com>
shimwell added a commit to shimwell/wheels that referenced this pull request Nov 5, 2026
The wheels are built from shimwell/openmc#145, which combines the wheel
packaging branch with staged multi-model D1S. They keep the openmc name
so packages that require openmc are satisfied, and carry a +extras
version label. A separate index root keeps them out of the main openmc
index.

update_indexs.py and the index check now handle nested index roots.

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.

3 participants