cpython icon indicating copy to clipboard operation
cpython copied to clipboard

"Embedding Python in Another Application" documentation examples use deprecated functions

Open vstinner opened this issue 3 years ago • 3 comments

Examples of the C API documentation should be updated to use the new PyConfig API, rather than deprecated functions like Py_SetProgramName():

  • https://docs.python.org/dev/c-api/intro.html#embedding-python
  • https://docs.python.org/dev/extending/extending.html
  • https://docs.python.org/dev/extending/embedding.html

In the intro, this paragraph is outdated:

The embedding application can steer the search by calling Py_SetProgramName(file) before calling Py_Initialize(). Note that PYTHONHOME still overrides this and PYTHONPATH is still inserted in front of the standard path. An application that requires total control has to provide its own implementation of Py_GetPath(), Py_GetPrefix(), Py_GetExecPrefix(), and Py_GetProgramFullPath() (all defined in Modules/getpath.c).

vstinner avatar Aug 05 '22 11:08 vstinner

See also:

  • gh-88052
  • gh-93358
  • gh-70702
  • gh-68840
  • gh-63352
  • gh-42771

Perhaps we should mark those as superseded by this and actually update the docs :)

erlend-aasland avatar Aug 05 '22 16:08 erlend-aasland

There are also slightly related issues:

  • gh-83463
  • gh-64423

erlend-aasland avatar Aug 05 '22 16:08 erlend-aasland

When updating the embedding docs, the changes should be clear that the simple Py_Initialize and Py_InitializeEx configuration APIs are not deprecated: what's deprecated are the pre-init configuration API functions that rely on global variables to pass settings to the initialization functions. If embedders want non-default interpreter behaviour, they should switch over to the config struct based Py_InitializeFromConfig API.

ncoghlan avatar Oct 16 '22 05:10 ncoghlan

Sadly, I failed to find the bandwidth to update the doc. I created this issue as a TODO item, but my TODO list is full of more important stuff as usual, so I prefer to close it. If someone is volunteer, please go ahead, the old API is now deprecated!

vstinner avatar Dec 13 '22 15:12 vstinner