gh-149163: Add PyInitConfig API (PEP 741) to the limited C API#149194
gh-149163: Add PyInitConfig API (PEP 741) to the limited C API#149194anujbharambe wants to merge 6 commits intopython:mainfrom
Conversation
The PyInitConfig API is the modern way for programs embedding Python to initialize the interpreter. However, it was excluded from the limited C API, forcing embedders to use deprecated legacy APIs or build against the full (unstable) C API. Create a new top-level `Include/initconfig.h` header (following the established `pylifecycle.h` / `longobject.h` pattern) that exposes the opaque `PyInitConfig` struct and all 14 associated functions to limited API consumers targeting Python 3.15+. The internal types (PyConfig, PyPreConfig, PyStatus, etc.) remain excluded from the limited API.
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
4475d41 to
4c0dd7c
Compare
There was a problem hiding this comment.
This is definitely wrong, there is no way this PR fixed all ~1000 issues. I assume something has broken, somewhere.
There was a problem hiding this comment.
Yeah you're right. The docs build was crashing before it could give any warnings. I have reverted the .nitignore changes and fixed the actual cause.
Documentation build overview
16 files changed ·
|
|
All checks are passing now, this should be good to go. cc @StanFromIreland |
|
Ah. I planned to write a PR once we will get an agreement on the adding PEP 741 to the limited C API, especially get an approval of the C API Working Group. IMO this PR was created too soon, and I suggest closing it. |
|
Got it, didn't realize this still needed the C API WG approval. Happy to close this for now. Let me know if this is useful as a reference once things are agreed on, happy to reopen or rework it then. |
Closes #149163 --> cc @vstinner
Summary
Add the PEP 741 PyInitConfig API to the limited C API / stable ABI, so programs embedding Python (GDB, Vim, PyInstaller, etc.) can use the modern initialization API without building against the full C API.
Include/initconfig.hfollowing thepylifecycle.h/longobject.hpatternPyInitConfigtypedef and 14 function declarations out ofInclude/cpython/initconfig.hinto the new header, guarded byPy_LIMITED_API >= 0x030f0000Misc/stable_abi.tomlPC/python3dll.c,Lib/test/test_stable_abi_ctypes.py,Doc/data/stable_abi.datversionchangednote toDoc/c-api/init_config.rstDoc/whatsnew/3.15.rstInternal types (PyConfig, PyPreConfig, PyStatus, PyWideStringList) remain excluded from the limited API.