[Libreoffice] [PATCH] Make pyuno work with system python

Lionel Elie Mamane lionel at mamane.lu
Mon Aug 22 13:35:50 PDT 2011

On Mon, Aug 22, 2011 at 07:12:55PM +0200, Petr Mladek wrote:
> Caolán McNamara píše v Po 22. 08. 2011 v 11:00 +0100:
>> On Mon, 2011-08-22 at 11:36 +0200, Tomáš Chvátal wrote:
>>> Should apply to master, worth backporting to 3.4.

>> I've hacked around this with...

>> echo "import sys, os" > uno.py
>> echo "sys.path.append('%{basisinstdir}/program')" >> uno.py
>> echo "os.putenv('URE_BOOTSTRAP', 'vnd.sun.star.pathname: %{baseinstdir}/program/fundamentalrc')" >> uno.py
>> cat $RPM_BUILD_ROOT/%{basisinstdir}/program/uno.py >> uno.py

>> in our own spec for a while, so integrating the fix would be good.

>> However....

>> a) do we need the PYTHONPATH hack in soffice.sh, I seem to be able to
>> get away without it ?

> I guess that PYTHONPATH hack in soffice.sh is not needed when you
> install uno.py and unohelper.py into %{python_sitearch}. It might be
> needed when you keep it in libreoffice/basis dir.

See pyuno/source/loader/pyuno_loader.cxx, function
prependPythonPath and its caller CreateInstance; my guess is that it
adds the exact same entry to PYTHONPATH, but I can't immediately
follow all layers of indirection to see what it adds exactly.

And the added line of the patch to uno.py seems to do the _same_ thing
_again_. I don't quite understand the utility of doing it in uno.py:
if uno.py is being loaded (presumably from its place in
@libdir@/@OOOINSTALLDIRNAME@/basis-link/program), it means the python
load path already contains that. If the python load path does not
contain that directory, adding it from within uno.py does not help
because of chicken-and-egg problem of python finding uno.py in the
first place.

Unless we want to allow distributions to install uno.py in
%{python_sitearch}, but *not* the other things it needs, such as
pyuno.so; I'm not sure I get the rationale for wanting to do that.

Can someone show me something that does not work with this patch, but
works with it?


More information about the LibreOffice mailing list