Library:CPython
Appearance
| Developer | Python Software Foundation |
|---|---|
| License | PSF-2.0 |
| Website | https://www.python.org |
| On this wiki | Facts · Code · Notes · Topics |
CPython (PSF license) is often embedded in games and applications as pythonXY.dll / libpythonX.Y.so with a zip of the standard library or frozen modules; the version is read from the DLL name, Py_GetVersion() or the PYC magic number.
Identification
- File names on Windows:
python3XY.dll(for examplepython311.dll= 3.11), plus the stable-ABI forwarderpython3.dllwhich re-exports the limited-API functions topython3XY.dll(PC/python3dll.c, generated from the stable ABI manifest). Linux:libpython3.X.so.1.0; embedded distributions:python3XY.ziporpythonXY.zipholding the standard library,python3XY._pthlimitingsys.path. - Version text:
PY_VERSION(Include/patchlevel.h, for example3.16.0a1+dev) is returned by the exportPy_GetVersion(); the banner string looks like3.11.4 (main, Jun 7 2023, 12:45:18) [MSC v.1934 64 bit (AMD64)]. - Exports that tell an embedding:
Py_Initialize,Py_InitializeEx,Py_InitializeFromConfig,Py_Finalize,PyRun_SimpleString,PyRun_SimpleFileExFlags,PyImport_ImportModule,PyImport_AppendInittab,PyImport_ExtendInittab,PyImport_FrozenModules,Py_FrozenMain,PyMarshal_ReadObjectFromString,PyEval_EvalCode. - Native extension modules are
.pydDLLs exportingPyInit_<name>.
Where the code is
- Plain
.py/.pycfiles, or a zip (.zip,library.zip) onsys.path; see Format:PYC (Python compiled bytecode): the 2-byte magic number identifies the exact minor version (3.11: 0xA7 0x0D plus CR LF). - Frozen modules:
PyImport_FrozenModulesis a table of_frozen {name, code, size, is_package}records; CPython freezesimportlib._bootstrapas_frozen_importlib,_frozen_importlib_external, and since 3.11 alsoos,codecs,io,siteand others (Python/frozen.c). Eachcodeis a Format:Marshal (Python) stream of a code object. Application freezers (PyInstaller, cx_Freeze, py2exe, Nuitka) are different containers with their own pages if present. - Decrypted/obfuscated variants: games sometimes patch the importer or the marshal loader; look at who calls
PyMarshal_ReadObjectFromStringandPyEval_EvalCode.
Reading the version quickly
- DLL file name, 2. export
Py_GetVersionor the string3.X.Y (in.rdata, 3. magic number of any .pyc in the archive.
Code & repositories
- https://github.com/python/cpython @
6af655301a19806a3f8ebe21b166f499cb431e70· license: PSF-2.0 (declared by the contributor; GitHub's detector did not recognize LICENSE)
CPython source. Useful without running: Include/patchlevel.h (version), PC/python3dll.c (stable ABI forwarder), Python/frozen.c (frozen modules), Lib/importlib/_bootstrap_external.py (pyc magic number).
Tested on: source read, not run: source read, not run · checked 2026-10-18
See also
Library:Lua, Library:Squirrel, Library:QuickJS for other embedded languages.