Skip to content

Migrate PyCUDA C++ wrappers from Boost.Python to pybind11#501

Draft
Copilot wants to merge 3 commits intopybindfrom
copilot/sub-pr-393
Draft

Migrate PyCUDA C++ wrappers from Boost.Python to pybind11#501
Copilot wants to merge 3 commits intopybindfrom
copilot/sub-pr-393

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 21, 2026

Completes the migration of all PyCUDA C++ extension wrapper code from Boost.Python to pybind11.

API Replacements

Boost.Python pybind11
BOOST_PYTHON_MODULE PYBIND11_MODULE
py::extract<T> .cast<T>()
py::optional<T> constructor overloads / default args
py::stl_input_iterator<T> / PYTHON_FOREACH range-based for
py::wrapper<T> + py::pure_virtual PYBIND11_OVERRIDE_PURE trampoline
py::with_custodian_and_ward_postcall py::keep_alive
py::return_value_policy<manage_new_object> py::return_value_policy::take_ownership
py::return_self<>() py::return_value_policy::reference
py::bases<T> pybind11 template parameter
.staticmethod("name") .def_static("name", fn)
add_property(...) def_property_readonly(...)
py::no_init removed (pybind11 default)

Files Changed

  • wrap_cudadrv.cpp — main driver bindings, full migration
  • mempool.cppexpose_memory_pool template updated: replaced Wrapper::wrapped_type (Boost.Python-specific) with explicit PoolType template parameter
  • wrap_cudagl.cpp, wrap_curand.cpp — migrated to pybind11 py::module_ &m pattern
  • cuda.hpp, cuda_gl.hpp — replaced py::extract<>, py::handle<> with pybind11 equivalents
  • wrap_helpers.hpp, tools.hpp — global namespace py = pybind11, added numpy/npy_2_compat.h

Numpy 2.0 Compatibility

Updated deprecated numpy C API calls:

  • tp_descr->elsizePyDataType_ELSIZE(tp_descr)
  • PyArray_CORDER / PyArray_FORTRANORDERNPY_CORDER / NPY_FORTRANORDER
  • NPY_FARRAY / NPY_CARRAYNPY_ARRAY_FARRAY / NPY_ARRAY_CARRAY
  • PyArray_BASE()PyArray_SetBaseObject()

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 21, 2026 19:38
Copilot AI changed the title [WIP] Migrate to pybind11 Migrate PyCUDA C++ wrappers from Boost.Python to pybind11 Mar 21, 2026
Copilot AI requested a review from inducer March 21, 2026 19:49
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