This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Overloading "Py_GetPath" does not work
Type: behavior Stage: resolved
Components: Build Versions: Python 3.8
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kayhayen, vstinner
Priority: normal Keywords:

Created on 2017-10-10 14:08 by kayhayen, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg304045 - (view) Author: Kay Hayen (kayhayen) Date: 2017-10-10 14:08
Hello,

for my Python compiler Nuitka, I want to make sure that compiled binaries in standalone mode do not access the original installation, but solely the distribution folder created.

I am using the new API Py_SetPath on Python3 and it works fine. The Python2.7 documentation of the C-API however says: 

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).

My attempts at overloading this have badly failed, because of conflicting "declspec" (dllimport vs dllexport). And when defining Py_GetPath away before making the include, so the conflict is not seen by the MSVC compiler, the result is that the function is not called. 
Is this known to work? Can you point me to a working example, because my searches didn't reveal anything. Not normal web search, nor global code search for Py_GetPath code.

I did not try on Linux yet. I am assuming it might work, I just wanted to tap on knowledge on your side. Is it feasible. For Linux? For Windows?

Thanks,
Kay Hayen
msg343643 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-05-27 15:17
If I understood correctly, this issue has been fixed by the PEP 587 "Python Initialization Configuration" in bpo-36763 which now provides a more reliable way to configure the "Path Configuration". I close the issue.

If I misunderstood the issue, please reopen it.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75926
2019-05-27 15:17:12vstinnersetstatus: open -> closed

versions: + Python 3.8, - Python 2.7
nosy: + vstinner

messages: + msg343643
resolution: fixed
stage: resolved
2017-10-10 14:08:15kayhayencreate