PCCM - Python C++ Code Manager

raw JSON →
0.4.16 verified Mon Apr 27 auth: no python

PCCM is a Python library for generating C++ code from Python class definitions, enabling seamless interoperability between Python and C++. It is currently at version 0.4.16, with moderate release cadence targeting Python >=3.6.

pip install pccm
error ModuleNotFoundError: No module named 'pccm'
cause Library not installed or installed in wrong environment.
fix
Run 'pip install pccm' in the correct Python environment.
error AttributeError: module 'pccm' has no attribute 'ClassBuilder'
cause Incorrect import or older version of pccm (<0.4.0) does not have ClassBuilder.
fix
Update pccm to latest version: 'pip install --upgrade pccm' and use correct import: from pccm import ClassBuilder
error TypeError: add_public_method() missing 1 required positional argument: 'name'
cause Missing method name argument.
fix
Provide method name: self.add_public_method('method_name', arg_types)
breaking Version 0.4.x changed the API for method registration: use add_public_method instead of add_method.
fix Replace add_method with add_public_method (or add_private_method for private).
gotcha ClassBuilder.build() returns a string, not a file. Users often expect it to write to disk.
fix Write the returned string to a file manually if needed.
deprecated Deprecated method 'add_property' is removed in 0.4.x; use 'add_getter_setter' instead.
fix Replace add_property with add_getter_setter.

Define a PCCM class, add it to a builder, and generate C++ code.

from pccm import ClassBuilder, PccmClass

class MyClass(PccmClass):
    def __init__(self):
        super().__init__()
        self.add_public_method('hello', [])

builder = ClassBuilder()
builder.add_class(MyClass)
cpp_code = builder.build()
print(cpp_code)