Bug 150654 - wrong python config variable EXT_SUFFIX for macos
Summary: wrong python config variable EXT_SUFFIX for macos
Status: RESOLVED DUPLICATE of bug 143980
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.4.0.0 beta1+
Hardware: All macOS (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2022-08-28 21:01 UTC by SK
Modified: 2024-08-29 06:13 UTC (History)
5 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 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?
Comment 2 Alec K 2024-07-08 21:12:17 UTC
Thank you for reporting the bug. I can confirm that this behavior is reproducible in:

Version: 25.2.0.0.alpha0+ (AARCH64) / LibreOffice Community
Build ID: ab5d79c90fc33b0a32604e3cbbbc686d01d85d39
CPU threads: 10; OS: macOS 13.6.6; UI render: Skia/Metal; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

I received the same traceback as was included in the bug report.

When I run the following in LibreOffice shipped python:

import sysconfig
sysconfig.get_config_var("EXT_SUFFIX")

I get the output:

'.cpython-3.8.so'

Leaving this bug as 'UNCONFIRMED' because its unclear if this use case is intended to be supported.
Comment 3 Buovjaga 2024-08-29 06:13:50 UTC

*** This bug has been marked as a duplicate of bug 143980 ***