Forum Archive

Support LZMA

cvp

@omz I want to unzip .7z files and I've found the lzma.py module in the Sandard Library, and I hoped until I got the message "lzma is currently not supported on iOS"...😭
Why is this source code there?

JonB

Although apparantly this was not included in pythonista,

https://gist.github.com/nmcspadden/5fd60c21a44e74df6a78

looks like it should work.

Turns out ios does come with /usr/lib/liblzma.dylib, and we can load it.
I have not tried this, but it looks like you could copy the existing lzma.py, remove the importerror lines, remove the import _lzma, and instead import all from the above file, which provides the LZMADecompressor class. Not sure if it is a drop in replacement, but seems like should be enough to get started

cvp

Thanks, I'll try today

omz

The reason lzma is currently not supported is that liblzma is automatically flagged as a private API for some reason, even when I build it from source instead of linking the system's (undocumented) version. It did actually work in Pythonista 3.0, but I had to remove it for 3.1 to avoid getting auto-rejected.

cvp

I can't do it work, I think that the line

c_liblzma = CDLL('/usr/lib/liblzma.dylib')

makes my script to crash

Correction: usage of c_liblzma functions crash, I will abandon, too complex for me, sorry and still thanks for your efforts

cvp

For info: if you want to convert any local or shared file (ex: 7z->zip or rar->zip) and if you agree to do it on-line, thus a non confidential file, try which offers a free user, for 25 conversions per day, and a Python API...and it works 🙂