Bug 159988 - LibreOffice 24.2.x can't import python binary
Summary: LibreOffice 24.2.x can't import python binary
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Extensions (show other bugs)
Version:
(earliest affected)
24.2.1.2 release
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-01 18:19 UTC by prrvchr
Modified: 2024-09-09 16:33 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description prrvchr 2024-03-01 18:19:09 UTC
Description:
I use Python packages providing binary files in my extensions:
- cffi
- ijson
- lxml

To package these 3 python libraries in the extension I just need to put a copy of the library in the pythonpath folder of the extension with all the binary files for all the different architectures.

It worked perfectly with LibreOffice 5.x, 6.x and 7.x on Windows and Linux, it works with LibreOffice 24.2.1.2 on Windows 10.

With LibreOffice 24.2.x under Linux this no longer seems possible.

Steps to Reproduce:
1.Try to install the OAuth2OOo extension [1] with 24.2.x on Linux
2.During installation an error occurs when importing the lxml module
3.Installation is interrupted

Actual Results:
Unable to install python packages with binaries under LibreOffice 24.2.x on Linux

Expected Results:
Be able to install python packages with binaries under LibreOffice 24.2.x on Linux



Reproducible: Always


User Profile Reset: No

Additional Info:
[1] https://prrvchr.github.io/OAuth2OOo/
Comment 1 prrvchr 2024-03-04 12:11:57 UTC
How to reproduce without using the OAuth2OOo extension:

The case where it works:
- Install LibreOffice 24.2.x on Windows 10 64bits. 
- download and decompress the lxml package[1] for Windows amd64 / Python 3.8 into a directory.
- Place the contents (ie: lxml-5.1.0.dist-info and lxml directory) of this archive in the LibreOffice Python lib directory (ie: C:\Program Files\LibreOffice\program\python-core-3.8.18\lib)
- Open a terminal and place this in the folder: C:\Program Files\LibreOffice\program.
- Load the Python console with the command: .\python
- In the Python console import the lxml and etree modules using the commands:
  - import lxml
  - from lxml import etree
- The 2 modules will be loaded correctly.

The case where it doesn't work:
- Install LibreOffice 24.2.x on Linux x86_64. 
- download and decompress the lxml package[2] for Linux x86_64 / Python 3.8 into a directory.
- Place the contents (ie: lxml-5.1.0.dist-info and lxml directory) of this archive in the LibreOffice Python lib directory (ie: /opt/libreoffice24.2/program/python-core-3.8.18/lib)
- Open a terminal and place this in the folder: /opt/libreoffice24.2/program.
- Load the Python console with the command: ./python
- In the Python console import the lxml and etree modules using the commands:
  - import lxml
  - from lxml import etree
- When you import etree you will get the error: ImportError: cannot import name 'etree' from 'lxml' (/opt/libreoffice24.2/program/python-core-3.8.18/lib/lxml/__init__.py)


[1] https://files.pythonhosted.org/packages/86/65/3d582b968b9b6c3efdc4e54f36878d0b79c51af10ec7c9d02d08dd72314b/lxml-5.1.0-cp38-cp38-win_amd64.whl

[2] https://files.pythonhosted.org/packages/ee/08/8cb09c9a0d77e7b615ace332a76e6460f4c3b0a50654c181755c619c383e/lxml-5.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Comment 2 prrvchr 2024-03-04 12:16:47 UTC
Last clarification: this is not necessarily linked to the python lxml package but to the fact that they have binary files since I have the same problem with the ijson, cffi and charser-normalizer packages.
Comment 3 prrvchr 2024-03-08 00:45:33 UTC
I think this additional information will be enough to resolve this problem.

- In LibreOffice 24.2.x python console for Windows 10, I get:
>>> import distutils.sysconfig as ds
>>> print(ds.get_config_var("EXT_SUFFIX"))
.cp38-win_amd64.pyd

- In LibreOffice 24.2.x python console for Linux, I get:
>>> import distutils.sysconfig as ds
>>> print(ds.get_config_var("EXT_SUFFIX"))
.cpython-3.8.so

It turns out that EXT_SUFFIX does not have the correct value which should be:
.cpython-38-x86_64-linux-gnu.so

Besides, if I rename the binary files under the wrong name I can import them...
Comment 4 prrvchr 2024-03-10 10:40:20 UTC
I do not have the possibility to test under MacOS what about LibreOffice version 24.2. x under OSX?
Comment 5 Roman Kuznetsov 2024-09-09 16:33:37 UTC
cloph, could you please take a look?