configure.py assumes "python" command exists

Richard Kimberly Heck rikiheck at lyx.org
Mon Feb 15 14:50:04 UTC 2021


On 2/15/21 5:56 AM, José Abílio Matos wrote:
>
> 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...
>
Well, José, you are the expert on this, so please go ahead. It probably
would be good to have this for the next release (probably beta 1).

Riki


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210215/2b176927/attachment.html>


More information about the lyx-devel mailing list