Format:PyOxidizer packed resources
| Developer | Gregory Szorc |
|---|---|
| Magic | 70 79 65 6D 62 65 64 03 (pyembed\x03) |
| Endianness | little |
| License | MIT OR Apache-2.0 (crate); PyOxidizer MPL-2.0 |
| Website | https://github.com/indygreg/PyOxidizer |
| On this wiki | Facts · Code · Notes · Topics |
Binary container that PyOxidizer (and the python-packed-resources crate) uses to embed Python modules, bytecode, extension modules and data files in an executable: the 8-byte header pyembed + 0x03, a little-endian counts header, a blob-section index, a per-resource field index and the concatenated blob data.
Identification
The data starts with the 8 bytes pyembed\x03 (version 3 of the format; any other header makes the reference parser answer 'unrecognized file format') (Fact:PyOxidizer packed resources/magic/pyembed header). The build mode decides where the blob lives: the PythonExecutable attribute packed_resources_load_mode is embedded:<filename> (default embedded:packed-resources: embedded in the binary, loaded from a memory address), binary-relative-memory-mapped:<filename> (a file next to the binary, memory mapped) or none (pyoxidizer docs, pyoxidizer_config_type_python_executable.rst; pyembed's PackedResourcesSource has the matching Memory and MemoryMappedPath variants). Search the binary and its folder for the 8-byte header.
PyOxidizer programs run an embedded interpreter whose importer reads this table instead of the file system, so modules are usually not separate files. The module data may be source, bytecode (three optimization levels), extension-module shared libraries loaded from memory, or file data.
Layout
All integers are little-endian. After the 8-byte header: u8 blob_section_count; u32 blob_index_length; u32 resources_count; u32 resources_index_length, then the blob index, the resources index and the blob data (Fact:PyOxidizer packed resources/struct/Header and indexes).
- Blob index: for every blob section a run of fields terminated by an end-of-entry byte, the whole index ended by 0x00. Fields: 0x01 start of entry, 0x02 resource field type (u8: which resource field this section stores), 0x03 raw payload length (u64), 0x04 interior padding (u8: 0x01 none, 0x02 a NUL byte after each entry), 0xFF end of entry.
- Resource index: for every resource, 0x01 start, then fields (u8 id followed by a field-specific length or value), then 0xFF; the index ends with 0x00. The name field (0x03) is a u16 length; most payload fields carry a u32 length (the bytes are taken from the matching blob section in order); flag fields (package, namespace package, module, builtin, frozen, extension, shared library, UTF-8 filename data) carry no value (Fact:PyOxidizer packed resources/enum/Resource field ids).
- Blob data: the sections follow each other in the order of the blob index; a resource's bytes for a field are consecutive slices of the section for that field, so you rebuild a module by walking the resources in order and advancing one cursor per field.
The reference parser's blob-section field enum lists ResourceFieldType = 0x03, but its conversion functions (which the parser and writer use) map 0x02 to it: follow the conversion functions (Fact:PyOxidizer packed resources/enum/Blob index fields).
Extraction
To recover Python code, parse the index, collect the bytecode fields (0x07-0x09 in memory, 0x10-0x12 relative to the file system), then add a Format:PYC (Python compiled bytecode) header (magic of the embedded interpreter) and decompile; the in-memory source field (0x06) may directly hold the program's source. The bytecode is stored without a pyc header: python-oxidized-importer resolve_bytecode wraps the stored bytes in a memoryview and importer.rs passes it straight to marshal.loads, which expects a bare marshalled code object, so the header must be added when writing a .pyc for a decompiler.
Related
Technique:Bundled-runtime applications, Format:PyInstaller archive (CArchive and PYZ), Tool:Nuitka, Format:Marshal (Python).
Code & repositories
See the repository list below.
- https://github.com/indygreg/PyOxidizer @
1ceca8664c71f39e849ce4873e00d821504b32bd· license: MPL-2.0 (declared by the contributor for the files used; GitHub reports MPL-2.0 (read from LICENSE; GitHub's API was busy) for the repository)
PyOxidizer: python-packed-resources crate (src/serialization.rs field ids, src/parser.rs reader, src/writer.rs writer).
Tested on: source read, not run · checked 2026-10-18