Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

Developers Guide

Checklists for developing new things in Magnum Python bindings themselves.

Checklist for adding / removing bindings for a library

  1. Add a corresponding Foo Magnum dependency to the find_package() call in src/python/magnum/CMakeLists.txt, create a magnum_foo_SRCS variable with its source file(s).
  2. Add a if(Magnum_Foo_FOUND) branch to the if(NOT MAGNUM_BUILD_STATIC) condition, adding a new magnum_foo module from magnum_foo_SRCS, linking to Magnum::Foo and setting OUTPUT_NAME to foo.
  3. Add a if(Magnum_Foo_FOUND) branch to the else() condition, APPENDing magnum_foo_SRCS to magnum_SRCS and Magnum::Foo to magnum_LIBS.
  4. Add void foo(py::module_& m); forward declaration to magnum/bootstrap.h, and #cmakdefeine Magnum_Foo_FOUND to magnum/staticconfigure.h.cmake.
  5. Implement void foo(py::module_& m) in src/python/magnum/foo.cpp, add a PYBIND11_MODULE() calling it.
  6. Add m.def_submodule("foo"); and a call to magnum:foo() wrapped in #ifdef Magnum_Foo_FOUND to the #ifdef MAGNUM_BUILD_STATIC section of PYBIND11_MODULE() in magnum/magnum.cpp.
  7. Add the new module name to the list in magnum/__init__.py.
  8. Add a line with magnum_foo to the foreach() in src/python/CMakeLists.txt, and then a corresponding 'magnum.foo' entry in src/python/setup.py.cmake
  9. Add a magnum/test/test_foo.py test file, and potentially also magnum/test/test_foo_gl.py where is from . import GLTestCase, setUpModule to skip the test if GL context doesn’t exist, and the test cases derive from GLTestCase instead of unittest.TestCase.
  10. Add the new module into the magnum.__all__ list in doc/python/conf.py.
  11. Add a doc/python/magnum.foo.rst documentation file for more detailed docs, if needed, and reference it from INPUT_DOCS.
  12. Add a doc/python/pages/changelog.rst entry.

For Corrade bindings it’s similar.