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
Foo
Magnum dependency to thefind_package()
call insrc/python/magnum/CMakeLists.txt
, create amagnum_foo_SRCS
variable with its source file(s). - Add a
if(Magnum_Foo_FOUND)
branch to theif(NOT MAGNUM_BUILD_STATIC)
condition, adding a newmagnum_foo
module frommagnum_foo_SRCS
, linking toMagnum::Foo
and settingOUTPUT_NAME
tofoo
. - Add a
if(Magnum_Foo_FOUND)
branch to theelse()
condition,APPEND
ingmagnum_foo_SRCS
tomagnum_SRCS
andMagnum::Foo
tomagnum_LIBS
. - Add
void foo(py::module_& m);
forward declaration tomagnum/bootstrap.h
, and#cmakdefeine Magnum_Foo_FOUND
tomagnum/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_FOUND
to the#ifdef MAGNUM_BUILD_STATIC
section ofPYBIND11_MODULE()
inmagnum/magnum.cpp
. - Add the new module name to the list in
magnum/__init__.py
. - Add a line with
magnum_foo
to theforeach()
insrc/python/CMakeLists.txt
, and then a corresponding'magnum.foo'
entry insrc/python/setup.py.cmake
- Add a
magnum/test/test_foo.py
test file, and potentially alsomagnum/test/test_foo_gl.py
where isfrom . import GLTestCase, setUpModule
to skip the test if GL context doesn’t exist, and the test cases derive fromGLTestCase
instead ofunittest.TestCase
. - Add the new module into the
magnum.__all__
list indoc/python/conf.py
. - Add a
doc/python/magnum.foo.rst
documentation file for more detailed docs, if needed, and reference it fromINPUT_DOCS
. - Add a
doc/python/pages/changelog.rst
entry.
For Corrade bindings it’s similar.