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: sys.executable does not return python3 executable when using uwsgi
Type: behavior Stage: resolved
Components: Documentation Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Joris VAN HOUTVEN, docs@python, methane, xtreak
Priority: normal Keywords:

Created on 2019-03-05 14:31 by Joris VAN HOUTVEN, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg337190 - (view) Author: Joris VAN HOUTVEN (Joris VAN HOUTVEN) Date: 2019-03-05 14:31
when serving a Flask app with uwsgi, using
`sys.executable`
will provide you the path to your uwsgi executable, not your python executable.
However, the docs specify that it should always return the python interpreter: https://docs.python.org/3/library/sys.html#sys.executable
msg337209 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019-03-05 15:33
related uwsgi issue : https://github.com/unbit/uwsgi/issues/670
msg337215 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-03-05 15:58
I don't think this is a documentation bug.  They insert "uwsgi" to "sys.executable" manually.

https://github.com/unbit/uwsgi/blob/3149df02ed443131c54ea6afb29fcbb0ed4d1139/plugins/python/pyutils.c#L398-402

#ifdef PYTHREE
	PyDict_SetItemString(sys_dict, "executable", PyUnicode_FromString(uwsgi.binary_path));
#else
	PyDict_SetItemString(sys_dict, "executable", PyString_FromString(uwsgi.binary_path));
#endif
msg337286 - (view) Author: Joris VAN HOUTVEN (Joris VAN HOUTVEN) Date: 2019-03-06 09:47
OK, so it is indeed uwsgi interfering with the sys.executable value.
In the github pst Inada Naoki refers to:

  "uwsgi is your current python interpreter, as it links the libpython.so. Getting sys.executable is not possibile as there is no binary path hard-encoded in library by itself"

So I suppose this issue can be closed here. I will comment on the uwsgi github.
History
Date User Action Args
2022-04-11 14:59:12adminsetgithub: 80377
2019-03-06 10:02:51methanesetresolution: fixed -> not a bug
2019-03-06 10:02:42methanesetstatus: open -> closed
resolution: fixed
stage: resolved
2019-03-06 09:47:28Joris VAN HOUTVENsetmessages: + msg337286
2019-03-05 15:58:02methanesetnosy: + methane
messages: + msg337215
2019-03-05 15:33:58xtreaksetnosy: + xtreak
messages: + msg337209
2019-03-05 14:31:26Joris VAN HOUTVENcreate