mxmlnkn / ratarmount

Access large archives as a filesystem efficiently, e.g., TAR, RAR, ZIP, GZ, BZ2, XZ, ZSTD archives
MIT License
915 stars 39 forks source link

libarchive throwing errors from ffi.py #137

Closed slo-sleuth closed 5 months ago

slo-sleuth commented 5 months ago

Ratarmount is a huge need and incredible idea, but unfortunately, it fails to run under WSL Ubuntu due to libarchive ffi.py errors.

I created a virtual environment for a clean install and ran pip3 install ratarmount.

$ pip3 list
Package        Version
-------------- -------
fusepy         3.0.1
indexed-gzip   1.8.7
indexed_zstd   1.6.1
libarchive-c   5.1
pip            22.0.2
python-xz      0.4.0
rapidgzip      0.14.2
rarfile        4.2
ratarmount     0.15.0
ratarmountcore 0.7.0
setuptools     59.6.0

Attempting to use the tool or list help results in this error:

$ ratarmount
Traceback (most recent call last):
  File "/home/jlehr/Projects/ratarmount/venv/bin/ratarmount", line 5, in <module>
    from ratarmount import cli
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/ratarmount.py", line 36, in <module>
    import ratarmountcore as core
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/ratarmountcore/__init__.py", line 47, in <module>
    from .compressions import (
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/ratarmountcore/compressions.py", line 65, in <module>
    import libarchive
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/libarchive/__init__.py", line 1, in <module>
    from .entry import ArchiveEntry
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/libarchive/entry.py", line 6, in <module>
    from . import ffi
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/libarchive/ffi.py", line 158, in <module>
    version_number = ffi('version_number', [], c_int, check_int)
  File "/home/jlehr/Projects/ratarmount/venv/lib/python3.10/site-packages/libarchive/ffi.py", line 102, in ffi
    f = getattr(libarchive, 'archive_'+name)
  File "/usr/lib/python3.10/ctypes/__init__.py", line 387, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.10/ctypes/__init__.py", line 392, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/jlehr/Projects/ratarmount/venv/bin/python3: undefined symbol: archive_version_number

I attempted to try/except around the calling ffi function, but that started me down a rabbit trail. I thought I'd post here in case the developer has a better suggestion or workaround.

Thanks

slo-sleuth commented 5 months ago

Solved by installing libarchive-dev.

mxmlnkn commented 5 months ago

I see that you solved the problem yourself, but it isn't the user experience I aim for. It would be really cool if python-libarchive-c offered platform-specific wheels with a statically built libarchive to avoid this issue. As an alternative, the AppImage is built with all dependencies. The AppImage can also be extracted and the contained script can be called directly, basically like a portable app installation, to avoid the ~1s startup time. Installed like this it is as good as the installation via pip. Maybe, I'll also add this installation method to the ReadMe as an alternative.

Secondly, I'm pretty sure that a try-except should work. I'll try to add that to ratarmount so that it works without error with file formats that work without libarchive.

slo-sleuth commented 5 months ago

I tried the appimage before positing the issue, but it failed with the same error. Try/Except just led me to another variable setting in ffi.py whose function failed to find an attribute, and not being familiar with libarchive, I decided to post and try to find another solution that would be more sustainable.