Page 1 of 1
[Solved] Python 3 and Calc
Posted: Sat May 05, 2012 11:09 pm
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.
Re: Python 3 and Calc
Posted: Sun May 06, 2012 12:20 am
by Villeroy
Why do you want to write code that works on your system only?
The documentation of the Python bridge explains all this.
Re: Python 3 and Calc
Posted: Sun May 06, 2012 12:31 am
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.
Re: Python 3 and Calc
Posted: Sun May 06, 2012 12:33 am
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
Re: Python 3 and Calc
Posted: Sun May 06, 2012 12:44 am
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:)
Re: Python 3 and Calc
Posted: Sun May 06, 2012 3:46 am
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.
Re: Python 3 and Calc
Posted: Sun May 06, 2012 4:13 am
by vancouver
Thank you hanya.
What is pyuno? Is it the same as uno.py? If not what is the difference?
Re: Python 3 and Calc
Posted: Sun May 06, 2012 4:56 am
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/
Re: Python 3 and Calc
Posted: Sun May 06, 2012 7:19 am
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!

Re: Python 3 and Calc
Posted: Sun May 06, 2012 7:58 am
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).