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 via email to