[Solved] Python 3 and Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
vancouver
Posts: 26
Joined: Thu Jan 26, 2012 10:55 am

[Solved] Python 3 and Calc

Post by vancouver »

The default version in LibreOffice seems to be Python 2.6, is there a way to use Python 3 interpreter located in another place on my hard drive instead?
I've checked Danny's OpenOffice.org library, I was wondering if this library will work fine under Python 3. Has anybody tried this before? Thanks.
Last edited by vancouver on Sun May 06, 2012 8:49 am, edited 1 time in total.
LibreOffice 3.4.5/Windows XP
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Python 3 and Calc

Post by Villeroy »

Why do you want to write code that works on your system only?
The documentation of the Python bridge explains all this.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
vancouver
Posts: 26
Joined: Thu Jan 26, 2012 10:55 am

Re: Python 3 and Calc

Post by vancouver »

Hi there!
Thanks for replying. But I just want to know a bit more about your suggestion. Is using Python 3 that would make the code only usable in my system or is trying to use my local interpreter that would cause that problem?
I don't intend to limit its use to my own computer. The thing is I'd really like to centralize all my codes into one folder, and I really want to use Python 3 instead of Python 2, if possible.
By the way, could you please provide a link to Python bridge documentation? I've just searched both Google and Libreoffice official website but didn't find that. Thanks.
LibreOffice 3.4.5/Windows XP
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Python 3 and Calc

Post by Villeroy »

If you use language features from Python 3, older Python versions can not understand your code. If you don't, then there is no reason to use Python 3.
http://lmgtfy.com/?q=openoffice.org+python+bridge
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
vancouver
Posts: 26
Joined: Thu Jan 26, 2012 10:55 am

Re: Python 3 and Calc

Post by vancouver »

Well..... I think your suggestion makes sense, but I still want to try Python 3, if possible. So I will leave this thread unsolved for the moment.
Thanks for lmgtfy, that's pretty cool:)
LibreOffice 3.4.5/Windows XP
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python 3 and Calc

Post by hanya »

Try to build the pyuno of LibreOffice with Python 3. It seems recent pyuno trying to support python 3. But I do not know its state.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
vancouver
Posts: 26
Joined: Thu Jan 26, 2012 10:55 am

Re: Python 3 and Calc

Post by vancouver »

Thank you hanya.
What is pyuno? Is it the same as uno.py? If not what is the difference?
LibreOffice 3.4.5/Windows XP
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python 3 and Calc

Post by hanya »

What is pyuno?
pyuno is the bridge between python and the office written in C. uno.py imports pyuno in itself. You can find the source under pyuno module of the source tree: http://opengrok.libreoffice.org/xref/co ... ce/module/
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
vancouver
Posts: 26
Joined: Thu Jan 26, 2012 10:55 am

Re: Python 3 and Calc

Post by vancouver »

Hi hanya, thanks for the tip, which is very informative. I've got two additional questions following your last post.

1) I don't have a C language background, does this mean I can't contribute to the pyuno development? Is there a python component in that module that I can work on?
2) I've checked out http://opengrok.libreoffice.org/xref/co ... ce/module/ that you gave me and I also did a files search under Windows XP to locate the equivalent files on my computer for each of those pyuno files. To my surprise I couldn't find any pyuno files under my "C:\Program Files\LibreOffice 3.5\program" folder except for pyuno.pyd and pyuno.xcd.

In this case, even if Python 3 version of pyuno had been developed, how can I possibly replace the new ones if I can't find the older versions on my computer?

Thanks a lot! :super:
LibreOffice 3.4.5/Windows XP
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Python 3 and Calc

Post by hanya »

About a year ago, I read the following message in the mailing list: http://lists.freedesktop.org/archives/l ... 10671.html
The post says it has been completed, so just try to build against python 3.
1) I don't have a C language background, does this mean I can't contribute to the pyuno development? Is there a python component in that module that I can work on?
If you want to write or understand the extension for CPython, you have to learn about C, C API of the CPython, and C++ for the office. And also, translating from python 2 to 3 requires knowledge on both 2 and 3 on the python level and their C API level differences. It must be hard work for you.

How to build? If you want to build it without hole source tree, you have to write make file to build it as standalone code from the office. It can be compiled with only SDK (and the office installation).
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Post Reply