System-provided Python 3 support now committed

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

System-provided Python 3 support now committed

Damjan Jovanovic
Hi

With Python 2 EOL as of 1 January 2020, we have little choice but to move
to Python 3.

After a lot of hard work by me and Pedro, both of us relatively unfamiliar
with Python, I am happy to report that using a system-provided Python 3 in
Apache OpenOffice now works.

The UNO/Python bridge and the Python script provider have been patched to
support both Python 2 and 3, and all 3 sample Python macros that ship with
AOO work with Python 3 too. More extensive testing (eg. main/pyuno/demo)
has not been performed, but isn't in the build anyway and might be broken
with Python 2 as well.

It certainly works on FreeBSD and probably on Linux, please test other
platforms.

As I said only system-provided Python 3 works as this stage. Building an
internal Python 3, as is required on Windows, does not work yet, and is
extremely difficult to implement, as Python 3 requires a new Windows
Platform SDK with MSVC >= 14 in order to build, which will probably lead to
numerous build-related changes to all modules. This does need to happen at
some stage anyway though.

Also as per https://bz.apache.org/ooo/show_bug.cgi?id=123975#c9
we also need to release AOO 5.0 (a new major release) for an incompatible
change of this nature.

Along the way, I also looked at what it would take to improve the Python
macro dialog, which never allowed creating, renaming, deleting or editing
Python scripts, only running them (and to add them to an .odt file, you
have to edit the ZIP file and add them manually). There are at least 3
separate implementations of scripting providers: the StarBasic one, the
Java one (used for Java, BeanShell and Rhino (Javascript)), and the Python
one. It's the Python one in main/scripting/source/pyprov/pythonscript.py
that is missing features. By comparing it against the Java provider I
managed to patch DirBrowseNode to implement XPropertySet and add a
getPropertyValue() method which checks for the "Creatable" property and
returns true, and this enables the (otherwise grayed out) "Create" button
in the dialog, but then to implement the "Creatable" action in invoke()
when the button is clicked seems rather difficult, and requires a low-level
understanding of script URLs and content brokers and various other
infrastructure.

Damjan
Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Matthias Seidel
Hi Damjan, Hi Pedro,

Thank you for your work and the helpful explanation.

BTW: I could make the "edit" button clickable for Python scripts by
setting ENABLE_EDIT_DIALOG to TRUE in [1], but it never brought up an
editor or something similar.

Regards,

   Matthias

[1]
https://github.com/apache/openoffice/blob/trunk/main/scripting/source/pyprov/pythonscript.py

Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:

> Hi
>
> With Python 2 EOL as of 1 January 2020, we have little choice but to move
> to Python 3.
>
> After a lot of hard work by me and Pedro, both of us relatively unfamiliar
> with Python, I am happy to report that using a system-provided Python 3 in
> Apache OpenOffice now works.
>
> The UNO/Python bridge and the Python script provider have been patched to
> support both Python 2 and 3, and all 3 sample Python macros that ship with
> AOO work with Python 3 too. More extensive testing (eg. main/pyuno/demo)
> has not been performed, but isn't in the build anyway and might be broken
> with Python 2 as well.
>
> It certainly works on FreeBSD and probably on Linux, please test other
> platforms.
>
> As I said only system-provided Python 3 works as this stage. Building an
> internal Python 3, as is required on Windows, does not work yet, and is
> extremely difficult to implement, as Python 3 requires a new Windows
> Platform SDK with MSVC >= 14 in order to build, which will probably lead to
> numerous build-related changes to all modules. This does need to happen at
> some stage anyway though.
>
> Also as per https://bz.apache.org/ooo/show_bug.cgi?id=123975#c9
> we also need to release AOO 5.0 (a new major release) for an incompatible
> change of this nature.
>
> Along the way, I also looked at what it would take to improve the Python
> macro dialog, which never allowed creating, renaming, deleting or editing
> Python scripts, only running them (and to add them to an .odt file, you
> have to edit the ZIP file and add them manually). There are at least 3
> separate implementations of scripting providers: the StarBasic one, the
> Java one (used for Java, BeanShell and Rhino (Javascript)), and the Python
> one. It's the Python one in main/scripting/source/pyprov/pythonscript.py
> that is missing features. By comparing it against the Java provider I
> managed to patch DirBrowseNode to implement XPropertySet and add a
> getPropertyValue() method which checks for the "Creatable" property and
> returns true, and this enables the (otherwise grayed out) "Create" button
> in the dialog, but then to implement the "Creatable" action in invoke()
> when the button is clicked seems rather difficult, and requires a low-level
> understanding of script URLs and content brokers and various other
> infrastructure.
>
> Damjan
>


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Damjan Jovanovic
On Sat, Jan 25, 2020 at 1:38 PM Matthias Seidel <[hidden email]>
wrote:

> Hi Damjan, Hi Pedro,
>
> Thank you for your work and the helpful explanation.
>
>
Pleasure :)


> BTW: I could make the "edit" button clickable for Python scripts by
> setting ENABLE_EDIT_DIALOG to TRUE in [1], but it never brought up an
> editor or something similar.
>
>
Yes I saw that too.

If I wrap the contents of ScriptBrowseNode.invoke() in a try/except, and
log the contents, I get:

<class 'pythonscript.com.sun.star.lang.WrappedTargetRuntimeException'>:

/openoffice-git/main/instsetoo_native/unxfbsdx/Apache_OpenOffice/installed/install/en-US/openoffice4/program/pythonscript.py:520
in function invoke() ["vnd.sun.star.script:" +]

with the code involved being:

519            self.editor = dlgprov.createDialog(
520                "vnd.sun.star.script:" +
521                "ScriptBindingLibrary.MacroEditor?location=application")

and I am not sure what's making it unhappy there.




> Regards,
>
>    Matthias
>
> [1]
>
> https://github.com/apache/openoffice/blob/trunk/main/scripting/source/pyprov/pythonscript.py
>
> Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:
> > Hi
> >
> > With Python 2 EOL as of 1 January 2020, we have little choice but to move
> > to Python 3.
> >
> > After a lot of hard work by me and Pedro, both of us relatively
> unfamiliar
> > with Python, I am happy to report that using a system-provided Python 3
> in
> > Apache OpenOffice now works.
> >
> > The UNO/Python bridge and the Python script provider have been patched to
> > support both Python 2 and 3, and all 3 sample Python macros that ship
> with
> > AOO work with Python 3 too. More extensive testing (eg. main/pyuno/demo)
> > has not been performed, but isn't in the build anyway and might be broken
> > with Python 2 as well.
> >
> > It certainly works on FreeBSD and probably on Linux, please test other
> > platforms.
> >
> > As I said only system-provided Python 3 works as this stage. Building an
> > internal Python 3, as is required on Windows, does not work yet, and is
> > extremely difficult to implement, as Python 3 requires a new Windows
> > Platform SDK with MSVC >= 14 in order to build, which will probably lead
> to
> > numerous build-related changes to all modules. This does need to happen
> at
> > some stage anyway though.
> >
> > Also as per https://bz.apache.org/ooo/show_bug.cgi?id=123975#c9
> > we also need to release AOO 5.0 (a new major release) for an incompatible
> > change of this nature.
> >
> > Along the way, I also looked at what it would take to improve the Python
> > macro dialog, which never allowed creating, renaming, deleting or editing
> > Python scripts, only running them (and to add them to an .odt file, you
> > have to edit the ZIP file and add them manually). There are at least 3
> > separate implementations of scripting providers: the StarBasic one, the
> > Java one (used for Java, BeanShell and Rhino (Javascript)), and the
> Python
> > one. It's the Python one in main/scripting/source/pyprov/pythonscript.py
> > that is missing features. By comparing it against the Java provider I
> > managed to patch DirBrowseNode to implement XPropertySet and add a
> > getPropertyValue() method which checks for the "Creatable" property and
> > returns true, and this enables the (otherwise grayed out) "Create" button
> > in the dialog, but then to implement the "Creatable" action in invoke()
> > when the button is clicked seems rather difficult, and requires a
> low-level
> > understanding of script URLs and content brokers and various other
> > infrastructure.
> >
> > Damjan
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Pedro Giffuni
In reply to this post by Damjan Jovanovic
Hello;

For the record, I only did a small "scotch tape" fix, the heavy lifting
was done by Damjan. My public thanks to him as this is likely to save
AOO from deprecation (at least in FreeBSD).

I think in the future we may move to tauthon, as an interim step before
Python 3:

https://github.com/naftaliharris/tauthon

Cheers,

Pedro.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Marcus (OOo)
In reply to this post by Damjan Jovanovic
Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:
> After a lot of hard work by me and Pedro, both of us relatively unfamiliar
> with Python, I am happy to report that using a system-provided Python 3 in
> Apache OpenOffice now works.
>
> [...]

thanks a lot for this step and hard work on your side. It's very much
appreciated.

Marcus


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Matthias Seidel
Hi all,

After all buildbots built trunk without problem I tested the Windows
version.
All python demo scripts worked nice (mailmerge.py is still broken but
that's another issue).

Should we cherry-pick these commits for AOO42X?

Regards,

   Matthias

Am 26.01.20 um 16:22 schrieb Marcus:

> Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:
>> After a lot of hard work by me and Pedro, both of us relatively
>> unfamiliar
>> with Python, I am happy to report that using a system-provided Python
>> 3 in
>> Apache OpenOffice now works.
>>
>> [...]
>
> thanks a lot for this step and hard work on your side. It's very much
> appreciated.
>
> Marcus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Marcus (OOo)
Am 26.01.20 um 17:39 schrieb Matthias Seidel:
> After all buildbots built trunk without problem I tested the Windows
> version.
> All python demo scripts worked nice (mailmerge.py is still broken but
> that's another issue).
>
> Should we cherry-pick these commits for AOO42X?

+1

As Python 2 is no longer supported, we should backport these changes
into AOO42X as this will be the branch for the next bigger release.

Marcus



> Am 26.01.20 um 16:22 schrieb Marcus:
>> Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:
>>> After a lot of hard work by me and Pedro, both of us relatively
>>> unfamiliar
>>> with Python, I am happy to report that using a system-provided Python
>>> 3 in
>>> Apache OpenOffice now works.
>>>
>>> [...]
>>
>> thanks a lot for this step and hard work on your side. It's very much
>> appreciated.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: System-provided Python 3 support now committed

Matthias Seidel
Hi Marcus,

Am 26.01.20 um 19:00 schrieb Marcus:

> Am 26.01.20 um 17:39 schrieb Matthias Seidel:
>> After all buildbots built trunk without problem I tested the Windows
>> version.
>> All python demo scripts worked nice (mailmerge.py is still broken but
>> that's another issue).
>>
>> Should we cherry-pick these commits for AOO42X?
>
> +1
>
> As Python 2 is no longer supported, we should backport these changes
> into AOO42X as this will be the branch for the next bigger release.
Thanks for you answer! Since there were no other opinions against it I
will cherry-pick the python related changes for AOO42X.

Regards,

   Matthias

>
> Marcus
>
>
>
>> Am 26.01.20 um 16:22 schrieb Marcus:
>>> Am 25.01.20 um 10:56 schrieb Damjan Jovanovic:
>>>> After a lot of hard work by me and Pedro, both of us relatively
>>>> unfamiliar
>>>> with Python, I am happy to report that using a system-provided Python
>>>> 3 in
>>>> Apache OpenOffice now works.
>>>>
>>>> [...]
>>>
>>> thanks a lot for this step and hard work on your side. It's very much
>>> appreciated.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


smime.p7s (5K) Download Attachment