https://bugs.documentfoundation.org/show_bug.cgi?id=170443
Bug ID: 170443
Summary: [Feature Request] Implement Python Stable ABI (Limited
API) for PyUNO to decouple LibreOffice from external
Python versions
Product: LibreOffice
Version: 24.2.0.0 alpha0+
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: enhancement
Priority: medium
Component: sdk
Assignee: [email protected]
Reporter: [email protected]
Description:
PROBLEM DESCRIPTION:
The pyuno bridge on Windows is currently compiled against a specific version of
Python (e.g., Python 3.11). This creates a hard binary dependency, preventing
external Python scripts running on any other version (e.g., 3.12, 3.13) from
importing "uno". This creates a "Version Lock" that hinders professional
automation and Data Science integration.
BENEFITS OF FIXING THIS:
1. Decoupling: Users can upgrade their external Python environment (e.g., to
use modern AI/ML libraries) without breaking LibreOffice automation.
2. Enterprise Deployment: IT departments can deploy standard Python versions
without conflict.
3. Longevity: Automation scripts won't break every time LibreOffice updates its
bundled Python version.
Steps to Reproduce:
1. Install LibreOffice (which currently bundles Python 3.11).
2. Install an external Python 3.12 (or newer) environment (e.g., via Anaconda
or python.org).
3. In the external Python 3.12 environment, append the LibreOffice "program"
directory to sys.path.
4. Attempt to run: "import uno"
Actual Results:
The import fails with a DLL conflict error:
"ImportError: Module use of python311.dll conflicts with this version of
Python."
Expected Results:
The "uno" module should import successfully.
If pyuno were compiled with the Python Stable ABI (Limited API), the bridge
would be able to load into Python 3.11, 3.12, or 3.13 processes seamlessly
without binary conflicts.
Reproducible: Always
User Profile Reset: No
Additional Info:
TECHNICAL IMPLEMENTATION PROPOSAL:
To support this, the Windows build process for the PyUNO bridge needs to be
updated to target the Python Stable ABI.
1. Compiler Flags: Define `Py_LIMITED_API` (e.g., 0x03080000 for Python 3.8+
compatibility) in the pyuno makefiles.
2. Linker: Link against `python3.lib` (the stable ABI library) instead of the
version-specific `python311.lib`.
3. Source Refactoring: Refactor `pyuno` C++ source files to replace direct
access to Python internal structures (e.g., ob_refcnt, ob_type) with the
equivalent Stable API macros/functions (Py_REFCNT, Py_TYPE), as direct
structure access is forbidden in the Limited API.
--
You are receiving this mail because:
You are the assignee for the bug.