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
- Add a corresponding
FooMagnum dependency to thefind_package()call insrc/python/magnum/CMakeLists.txt, create amagnum_foo_SRCSvariable with its source file(s). - Add a
if(Magnum_Foo_FOUND)branch to theif(NOT MAGNUM_BUILD_STATIC)condition, adding a newmagnum_foomodule frommagnum_foo_SRCS, linking toMagnum::Fooand settingOUTPUT_NAMEtofoo. - Add a
if(Magnum_Foo_FOUND)branch to theelse()condition,APPENDingmagnum_foo_SRCStomagnum_SRCSandMagnum::Footomagnum_LIBS. - Add
void foo(py::module_& m);forward declaration tomagnum/bootstrap.h, and#cmakdefeine Magnum_Foo_FOUNDtomagnum/staticconfigure.h.cmake. - Implement
void foo(py::module_& m)insrc/python/magnum/foo.cpp, add aPYBIND11_MODULE()calling it. - Add
m.def_submodule("foo");and a call tomagnum:foo()wrapped in#ifdef Magnum_Foo_FOUNDto the#ifdef MAGNUM_BUILD_STATICsection ofPYBIND11_MODULE()inmagnum/magnum.cpp. - Add the new module name to the list in
magnum/__init__.py. - Add a line with
magnum_footo theforeach()insrc/python/CMakeLists.txt, and then a corresponding'magnum.foo'entry insrc/python/setup.py.cmake - Add a
magnum/test/test_foo.pytest file, and potentially alsomagnum/test/test_foo_gl.pywhere isfrom . import GLTestCase, setUpModuleto skip the test if GL context doesn’t exist, and the test cases derive fromGLTestCaseinstead ofunittest.TestCase. - Add the new module into the
magnum.__all__list indoc/python/conf.py. - Add a
doc/python/magnum.foo.rstdocumentation file for more detailed docs, if needed, and reference it fromINPUT_DOCS. - Add a
doc/python/pages/changelog.rstentry.
For Corrade bindings it’s similar.