I think this is a good idea and the API looks generally well thought.
I would suggest a few changes:
- Instead of
PyInitConfig_SetStrtaking a locale-encoded string, I would suggestPyInitConfig_SetUtf8taking a UTF8 string (probably the preferred choice for most people?) andPyInitConfig_SetLocaleStrtaking a locale-encoded string; PyInitConfig_Exceptionwould probably be less confusingly namedPyInitConfig_HasError(we aren’t talking about proper Python exceptions, are we?);PyInitConfig_GetErrorcould probably return aconst char*directly, rather than have a separateintreturn code that only duplicates the information.
Also, I do not understand what a config exit code is.
I’m not sure the allow_custom_options special config entry is really useful. Instead, you could arrange that values starting with some well-known prefix such as X- or vendor. are freely accepted.
Finally, it seems that PyConfig_Get and PyConfig_GetInt will only work if interpreter initialization was successful, since they set an exception on error? This means it’s not possible to inspect the current configuration while building it.