cpython #14

Merged
elmau merged 2 commits from AmourSpirit/zaz-pip:cpython into develop 2023-11-03 11:23:41 -06:00
Contributor

This is the last update that I have at this time.

This update fixes an issue for Mac OS and Linux AppImage.

The issue is the same for both LibreOffice on Mac OS and Linux AppImage.

The issue is that any python package then contains binaries such as numpy or lxml can not be imported into LIbreOffice Python.
The reason for this has to do with the type of suffixes that python supports. Pip installs using the systems expected suffix whereas LibreOffice embedded python will alway use *.cpython-3.8.so.

For example when pip installs packages that contain binary .so file it's name might be named something like bit_generator.cpython-38-x86_64-linux-gnu.so. The issue is that the embedded python cannot import from this version of the binary file. For LibreOffice embedded python 3.8.10 the file would need to be named bit_generator.cpython-3.8.so. This is the reason that numpy cannot be imported when installed via pip into Mac OS and Linux AppImage versions of LibreOffice.

This solution corrects for this by creating symbolic links to all *.cpython*.so files to the name that LibreOffice embedded python expects. For example On Mac OS and Linxu AppImage, using this fix, bit_generator.cpython-3.8.so is automatically created as a symbolic link to bit_generator.cpython-38-x86_64-linux-gnu.so . The correct python version that is needed to create the links is automatically detected.

When a package is removed an unlink() method is run to remove any broken symbolic links after the uninstall is completed.

This is how I got some of my extensions such as Numpy for LibreOffice to work cross platform.

See also: Python bug 36716
See also sym_link_cpython of my Python LibreOffice Pip Extension Template project.

This is the last update that I have at this time. This update fixes an issue for Mac OS and Linux AppImage. The issue is the same for both LibreOffice on Mac OS and Linux AppImage. The issue is that any python package then contains binaries such as `numpy` or `lxml` can not be imported into LIbreOffice Python. The reason for this has to do with the type of suffixes that python supports. Pip installs using the systems expected suffix whereas LibreOffice embedded python will alway use `*.cpython-3.8.so`. For example when pip installs packages that contain binary `.so` file it's name might be named something like `bit_generator.cpython-38-x86_64-linux-gnu.so`. The issue is that the embedded python cannot import from this version of the binary file. For LibreOffice embedded python `3.8.10` the file would need to be named `bit_generator.cpython-3.8.so`. This is the reason that numpy cannot be imported when installed via pip into Mac OS and Linux AppImage versions of LibreOffice. This solution corrects for this by creating symbolic links to all `*.cpython*.so` files to the name that LibreOffice embedded python expects. For example On Mac OS and Linxu AppImage, using this fix, `bit_generator.cpython-3.8.so` is automatically created as a symbolic link to `bit_generator.cpython-38-x86_64-linux-gnu.so` . The correct python version that is needed to create the links is automatically detected. When a package is removed an `unlink()` method is run to remove any broken symbolic links after the uninstall is completed. This is how I got some of my extensions such as [Numpy for LibreOffice](https://extensions.libreoffice.org/en/extensions/show/41995) to work cross platform. See also: [Python bug 36716](https://bugs.python.org/issue36716) See also [sym_link_cpython](https://github.com/Amourspirit/python-libreoffice-pip/wiki/pyproject.toml#sym_link_cpython) of my Python LibreOffice Pip Extension Template project.
AmourSpirit added 2 commits 2023-11-03 10:07:25 -06:00
Author
Contributor

BTW: When might I expect an update for the extension? I would like to start updating my Pip & Virtual Environments guides.

BTW: When might I expect an update for the extension? I would like to start updating my [Pip & Virtual Environments](https://python-ooo-dev-tools.readthedocs.io/en/latest/guide/virtual_env/index.html) guides.
elmau merged commit 0e750c0af0 into develop 2023-11-03 11:23:41 -06:00
Owner

Great...

Great...
AmourSpirit deleted branch cpython 2023-11-03 12:46:53 -06:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: elmau/zaz-pip#14
No description provided.