openzim / python-libzim

Libzim binding for Python: read/write ZIM files in Python
https://pypi.org/project/libzim/
GNU General Public License v3.0
62 stars 19 forks source link

Help installing python libzim in termux #130

Closed sobaee closed 2 years ago

sobaee commented 2 years ago

Hello dear developer

I failed to install python-libzim 1.0.0 in termux mobile

Termux use libzim library 7.0.0, python 3.9.0

Please help with any information could help

It gives me this error:

ERROR: Could not find a version that satisfies the requirement libzim==1.0 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.3.post0, 0.1, 1.0.0) ERROR: No matching distribution found for libzim==1.0

kelson42 commented 2 years ago

@sobaee This means that your libzim is not installed properly. What is your exact system/architecture? What is the exact command your rung with the bull log?

rgaudin commented 2 years ago

I think both the README and the PyPi listing are clear about what you can get from a pip install.

I suppose your termux mobile is not x86_64. For it to work, you'd need to build it (see README).

sobaee commented 2 years ago

I think both the README and the PyPi listing are clear about what you can get from a pip install.

I suppose your termux mobile is not x86_64. For it to work, you'd need to build it (see README).

I appreciate your quick answer

I really thought about building it

But I only need to build python libzim not libzim library itself (because termux has libzim library 7.0.0), and I couldn't find how to build python libzim!! Not in readme.md not in pypi

So please provide me the way how I build python libzim.

rgaudin commented 2 years ago

Just python setup.py build_ext -i (or the invoke build-ext shortcut mentioned in the README). Make sure to adjust you LD_LIBRARY_PATH env if the build script can't find your libzim so file.

Let us know how it goes

sobaee commented 2 years ago

Error:

Traceback (most recent call last): File "/storage/emulated/0/pyglossary-master/libzim/setup.py", line 39, in from ctypes.util import find_library File "/data/data/com.termux/files/usr/lib/python3.9/ctypes/init.py", line 8, in from _ctypes import Union, Structure, Array ImportError: dlopen failed: cannot locate symbol "ffi_closure_free" referenced by "/data/data/com.termux/files/usr/lib/python3.9/lib-dynload/_ctypes.cpython-39.so"...

rgaudin commented 2 years ago

You need to install Cython first, then build the extension, then either install or copy the libzim so into the right folder and build a wheel that you can re-install later.

I suggest you follow the linux-related steps from https://github.com/openzim/python-libzim/blob/master/.github/workflows/release.yml

sobaee commented 2 years ago

You need to install Cython first, then build the extension, then either install or copy the libzim so into the right folder and build a wheel that you can re-install later.

I suggest you follow the linux-related steps from https://github.com/openzim/python-libzim/blob/master/.github/workflows/release.yml

Cython already installed by pip install cython and wheel pip install wheel

Libzim so is in the the right place: /data/data/com.termux/files/usr/lib/libzim.so

And I already: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/data/data/com.termux/files/usr/lib/

Linux steps are so complicated steps for me, Iam just a beginner who want to install python libzim to use it in pyglossary

I also don't know how to setup "env"

Do I need root to install it?

sobaee commented 2 years ago

I also installed gcc for termux and it failed also to build and install python libzim

sobaee commented 2 years ago

Finally I managed this by using ubuntu amd64 in termux then install python-libzim 1.0.0 in python 3.9. build python 3.9 for ubuntu 18.04 by this:

https://www.makeuseof.com/install-python-ubuntu/

This is the tutorial video how to install ubuntu x86 but use it to install amd64 not i686 (x86): https://m.youtube.com/watch?v=Ucc1sNqIoc8

sobaee commented 2 years ago

Thanks to @xtkoba

I managed to install python-libzim 1.0.0 in termux.

Here is what I did:

apt install rust binutils libzim

pip install wheel cython

export CARGO_BUILD_TARGET=aarch64-linux-android && pip install cryptography

export PATH='/data/data/com.termux/files/usr/bin'

export LD_LIBRARY_PATH='/data/data/com.termux/files/usr/lib'

pip install libzim==1.0

rgaudin commented 2 years ago

Good to know ; thanks