Bug 150654

Summary: wrong python config variable EXT_SUFFIX for macos
Product: LibreOffice Reporter: SK <saikee2009>
Component: LibreOfficeAssignee: Not Assigned <libreoffice-bugs>
Status: UNCONFIRMED ---    
Severity: normal CC: 79045_79045, LibreOfficiant, saikee2009
Priority: medium    
Version: 7.4.0.0 beta1+   
Hardware: All   
OS: macOS (All)   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 127593    

Description SK 2022-08-28 21:01:00 UTC
Description:
When I use uno to write a python program to communicate with a Libreoffice running session on Macos, I need to run the python shipped with Libreoffice in /Applications/LibreOffice.app/Contents/Resources/python

So, I need to install the required python module, e.g., the numpy.  It failed to import because the EXT_SUFFIX is wrong.

What I did was /Applications/LibreOffice.app/Contents/Resources/python -m pip install numpy
The library is installed, but the name of some C-extensions failed.

The problem is, those C-extensions are named with .cpython-37m-darwin.so suffix, e.g., /Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so
But if you run following within the Libreoffice shipped python:

import sysconfig
sysconfig.get_config_var("EXT_SUFFIX")

it says '.cpython-3.7m.so'

Therefore, it failed.  If I use python installed externally, this same command return '.cpython-37m-darwin.so' and the import succeeded.

But I can't change the config variable "EXT_SUFFIX", they are set in compile time, can you help to look at the error and see if my understanding is correct ?

I tested the same in both Intel and M1 CPU, both suffer from the same problem.

Steps to Reproduce:
1./Applications/LibreOffice.app/Contents/Resources/python -m pip install numpy
2./Applications/LibreOffice.app/Contents/Resources/python
3.import numpy

Actual Results:
Traceback (most recent call last):
  File "/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/__init__.py", line 150, in <module>
    from . import core
  File "/Applications/LibreOffice.app/Contents/Frameworks/LibreOfficePython.framework/lib/python3.7/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.7 from "/Applications/LibreOffice.app/Contents/Resources/../Frameworks/LibreOfficePython.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/LibreOfficePython"
  * The NumPy version is: "1.21.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy.core._multiarray_umath'

Expected Results:
Should be no error after import numpy


Reproducible: Always


User Profile Reset: No



Additional Info:
import sysconfig
sysconfig.get_config_var("EXT_SUFFIX")

Shows wrong extension for the C-extensions
Comment 1 Roman Kuznetsov 2022-09-28 16:17:09 UTC
Alain, is it a bug or not? Possibly we have this behavior by some security reasons?