pycomtypelib
A pure-Python, cross-platform decoder for the MSFT COM type library binary
format (.tlb files, and RT_TYPELIB resources embedded in .dll / .ocx /
.exe files). No Windows, no COM, no oleaut32.dll required.
This is a Python port of the type library reading logic in
Wine's dlls/oleaut32/typelib.c
and typelib.h, cross-checked against public documentation of the format
(notably Geoff Chappell's notes on ITypeLib).
Only the MSFT format is supported (the format produced by ICreateTypeLib2
/ MIDL and used by essentially all modern type libraries); the older SLTG
format (ICreateTypeLib, legacy VB5/VB6) is out of scope.
Wine's typelib.c is licensed LGPL-2.1-or-later; this project inherits that
license since its parsing logic is derived from it.
Install
pip install -e .
Library usage
from pycomtypelib import load_typelib_file
tlb = load_typelib_file("stdole2.tlb")
print(tlb.name, tlb.guid, tlb.version)
for ti in tlb.typeinfos:
print(ti.typekind.name, ti.name)
To pull a type library out of a compiled binary (DLL/OCX/EXE) instead of a
standalone .tlb file:
from pycomtypelib import load_typelib_from_pe
tlb = load_typelib_from_pe("MSCOMCTL.OCX")
CLI
pycomtypelib dump stdole2.tlb
pycomtypelib dump MSCOMCTL.OCX --json > mscomctl.json
Cross-library references (e.g. an interface inheriting from IUnknown or
IDispatch, which live in stdole2.tlb) can't be resolved to a full
TypeInfo without also parsing the imported library, so by default they're
shown by name via a small built-in table of well-known COM/OLE Automation
interface GUIDs (pycomtypelib.WELL_KNOWN_INTERFACES). Pass -n /
--no-wellknown-guids to disable that and show the raw GUID and import
library name instead:
pycomtypelib dump -n stdole2.tlb
This only affects display (--json's wellknown_name field, and the IDL-like
text renderer); it never affects decoding itself.
Scope
- Reads the MSFT binary layout: header, segment directory, GUID/name/string
tables, type descriptors, array descriptors, per-
TypeInfofunction/variable/ implemented-type records, imported type libraries, and custom data. - Resolves this into a friendly object model (
TypeLib,TypeInfo,FuncDesc,VarDesc,ParamDesc,TypeDesc, ...) analogous to whatITypeInfoexposes, including resolution ofVT_USERDEFINEDreferences to otherTypeInfoentries (in the same library or in imported libraries). - Read-only: this library decodes type libraries, it does not write/compile them.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycomtypelib-0.1.0.tar.gz.
File metadata
- Download URL: pycomtypelib-0.1.0.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cc3ce0680f984b89dca84bbb80f195ff9c75c9ec4eab8920a140ef192aa432c
|
|
| MD5 |
fe39e576ecc4e153dc748cb6617c7138
|
|
| BLAKE2b-256 |
3b440bcad64c32191250e8999164abf29f474148bc80db5fe2698aeb269e9c9e
|
File details
Details for the file pycomtypelib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pycomtypelib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c9ce70df4cc19c68d7df271f5cf051ef46fb3227eb5c37a9bbd5ed38149d9a4
|
|
| MD5 |
9a2f2c3ef1510d08d62289dc9104f2e0
|
|
| BLAKE2b-256 |
cf9606c8664ff78847155943d79bd62d08d4edc080d7ee0a57cc05ce4a3060e1
|