Repository navigation
Ship a C++ wrapper header and test consumers of the C ABI wheel - #219
Merged
Merged
Conversation
With add_c_abi, rust/capi/include/<module>.hpp wraps the C ABI in RAII handles and exceptions and is shipped next to the generated C header under <module>/include/<module>. The generated project's tests compile a C program against get_include()/get_library_dirs() and a C++ program against the wrapper, run them, and check their output, so a wheel that cannot be consumed fails its own tests. The checks skip without a compiler on PATH and under Pyodide. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
The DLL ships inside the wheel under <module>/lib, so delvewheel must not search PATH for it. Found on fsspec-rs, which hit the same failure. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
timkpaine
force-pushed
the
rust-c-abi-consumer
branch
from
November 11, 2026 23:54
d0e6bcf to
78d3436
Compare
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
timkpaine
force-pushed
the
rust-c-abi-consumer
branch
from
November 12, 2026 01:01
3e5a481 to
070dcfb
Compare
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.
Description
Stacked on #218. Two additions to the
rustvariant withadd_c_abi:rust/capi/include/<module>.hpp, a hand-written C++ wrapper over the generated C header (RAIIExample, exceptions from status/null returns,abi_version()), shipped beside the C header under<module>/include/<module>. It shows that any extra header inrust/capi/includecan be shipped by adding anoutputsentry on the library artifact.get_include()/get_library_dirs()/get_libraries()and a C++ program against the wrapper, runs them, and checks the output (1 consumer). On MSVC the import library shipped underlib/is linked and the DLL directory is put onPATHfor the run; elsewhere an rpath to the package'slib/is set. The tests skip when no compiler is onPATHand under Pyodide.Verified locally: the regenerated project passes
make lint,make checks, andmake test(4 Python tests including both consumers, 3 Rust tests), and the wheel contains the extension, the library, and both headers.Type of Change
Checklist
make lint)make test)