configure.py assumes "python" command exists

José Abílio Matos jamatos at lyx.org
Mon Feb 15 10:56:11 UTC 2021


On Monday, February 15, 2021 4:27:40 AM WET Richard Kimberly Heck wrote:
> We have a Python detection routine, find_python_binary(), so it could be
> modified to check for those commands explicitly. I'm reluctant to touch
> that code myself though.

The detection code in LyX is working correctly, it works if the name is not 
python. The code searches for python39 or python3.9 or ...

The issue that Scott is raising is different. The problem is that configure.py 
always issue a "python" as the python name. When we get here the lyx detection 
code already worked correctly.

I had thought previously about this and I have an idea to fix this.

"""
import os, sys

print(os.path.basename(sys.executable))
"""

so the idea is to replace "python" by os.path.basename(sys.executable) in all 
the calls on configure.py.

This code is general, since it takes care of the directory separators, and it 
should work everywhere.


Funnily enough the function rescanTeXFiles (line 1920) already does that. :-)

For the next stable release if we assume a minimum of python 3.6 we can use 
the f-strings (formatted in case you wonder :-) ) and the code could be 
simply.

python = os.path.basename(sys.executable);
...

print (f"{python}")

so that the content of variable python is replaced inside the function...
-- 
José Abílio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210215/accd3adf/attachment-0001.html>


More information about the lyx-devel mailing list