Patches for Python scripts

Thibaut Cuvelier tcuvelier at lyx.org
Mon Feb 1 02:42:43 UTC 2021


On Sun, 31 Jan 2021 at 12:39, Enrico Forestieri <forenr at lyx.org> wrote:

> On Sun, Jan 31, 2021 at 04:22:39AM +0100, Thibaut Cuvelier wrote:
> > On Sat, 30 Jan 2021 at 12:26, Enrico Forestieri <forenr at lyx.org> wrote:
> > > On Sat, Jan 30, 2021 at 05:31:05AM +0100, Thibaut Cuvelier wrote:
> > > > On Sat, 30 Jan 2021 at 02:31, Enrico Forestieri <forenr at lyx.org>
> wrote:
> > > > >
> > > > > So, it seems that you have to check also for the 32-bit version.
> > > > >
> > > > Indeed. Would the attached patch solve the problem? I first look for
> a
> > > > 64-bit version before a 32-bit, just to favour newer things, but
> there is
> > > > no other reason to do so.
> > >
> > > The patch does not apply neither to current master nor to current
> stable
> > > (most probably it depends on previous patches):
> > >
> > > $ patch --dry-run -p1 <
> > > 0013-Configure-look-for-Java-in-the-registry-on-Windows.patch
> > > checking file lib/configure.py
> > > Hunk #1 FAILED at 330.
> > > Hunk #2 succeeded at 403 (offset -14 lines).
> > > Hunk #3 succeeded at 1923 (offset -94 lines).
> > > 1 out of 3 hunks FAILED
> > >
> > > and I had to apply it manually. Before applying it, I took away java
> from
> > > PATH and reconfigured:
> > >
> > > ...
> > > checking for a java interpreter...
> > > +checking for "java"...  no
> > > ...
> > >
> > > Correctly, java was not found (it is found when it is in PATH).
> > > Then I applied the patch an reconfigured again:
> > >
> > > ...
> > > checking for a java interpreter...
> > > +checking for "java"...  no
> > > Traceback (most recent call last):
> > >   File "C:\cygwin\win\python\lib\logging\__init__.py", line 870, in
> emit
> > >     stream.write(ufs % msg)
> > > LookupError: unknown encoding: cp65001
> > > Logged from file configure.py, line 346
> > > ...
> > >
> > > I have a native Windows version of Python 2.7 installed in
> > > "C:\cygwin\win\python".
> > >
> > > So, it seems there is a problem with Python 2
> > >
> >
> > I just tried with Python 2.7.18 (64 bits), I cannot reproduce your
> problem.
> > What is exactly on your line 346? I guess it is something like
> logger.info,
> > a line that runs without problem on my side (Python 3.8 and 2.7).
>
> Yes, that's exactly "logger.info('+checking for java: ' + java_bin)".
> It seems a problem related to the locale. I was reconfiguring from a
> cygwin shell, whose locale is UTF-8, apparently something alien to
> Windows. I now tried reconfiguring from a cmd.exe window and the result is:
>
> ...
> checking for a java interpreter...
> +checking for "java"...  no
> +checking for java: C:\Program Files (x86)\Java\jre1.8.0_281\bin\java.exe
> ...
>
> So, it works. However, to avoid confusion, you should avoid logging the
> first negative result. Or, maybe, on Windows report something like this:
>
> ...
> checking for a java interpreter...
> +checking for "java" in PATH...  no
> +checking for "java" in registry... C:\Program Files
> (x86)\Java\jre1.8.0_281\bin\java.exe
> ...
>
> And, yes, I know making things work for everyone is exhausting...
>
> Thank you for your efforts.
>

Thank you for testing on your side :)! What's frustrating with your report
is that this bug can only appear on Python 2, and that it will very likely
be dropped for the next release (I remember seeing people wanting to keep
it for LyX 2.4). Nevertheless, I'm trying to do a few things about it.

What I've been doing: change the output when looking for programs, with a
more explicit "not in path" instead of "no", and the same for the registry
check; convert the result of winreg.QueryValueEx to a string (in Python 2,
it looks like it's a byte array, hence the error). If that doesn't work, I
really don't know what to do, apart from not telling the user what Java
binary was found.

I'm attaching a differential patch (unnamed8) for the latest changes, plus
a complete updated patch that should replace the original 0013 patch. Does
it work for you?



More generally, what about the other patches? Are formatting changes
considered risky? What about Joel's suggestions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210201/aaa35d1e/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: unnamed8.patch
Type: application/octet-stream
Size: 1266 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210201/aaa35d1e/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0013-Configure-look-for-Java-in-the-registry-on-Windows.patch
Type: application/octet-stream
Size: 3355 bytes
Desc: not available
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210201/aaa35d1e/attachment-0003.obj>


More information about the lyx-devel mailing list