A Python library for defining and parsing C-style structs. Supports nested structs, arrays, strings, and variable-length fields. Version 6.2 works with Python 3.7+ and supports Python 3.14. Released under the MIT license, with active maintenance and periodic updates.
pip install cstructVerified import paths — ran on the pinned version, not inferred.
Defines a simple Point struct, packs values, and unpacks from bytes.
Ensure struct definitions use the __struct__ list format or check compatibility if using Python class attributes.
Update your build configuration to use pyproject.toml instead of setup.cfg.
Define string fields with explicit length, e.g., ('name', 'char[32]'), and ensure raw bytes are encoded/decoded correctly.Define __struct__ as a list of tuples, e.g., __struct__ = [('x', 'int'), ('y', 'int')].Ensure string fields are unpacked as strings (they are automatically decoded) and binary fields are handled as bytes.
Verify the buffer length matches the struct size (calculate using len(struct_instance)).
No dependency data recorded yet.