LZO decompressing with Python 2.5x on Windows for C dummies

Kim Hansen slaunger at gmail.com
Wed Sep 8 08:55:48 CEST 2010


Hi list,

I have some binary data files which contain embedded LZO compressed
payloads mixed with normal C-struct like headers.

I would like to have the ability to LZO decompress these payloads using a
python 2.5.x script.

I was hoping that there was an up-to-date plug-and-play LZO library
available for Windows somewhere. However, I have not managed to find such a
one.

The closest I have gotten is on the official LZO home page:

http://www.oberhumer.com/opensource/lzo/

There is a link to some old LZO 1.08 bindings for Python 2.2 there as a
tar.gz (released back in 2002!)

http://www.oberhumer.com/opensource/lzo/download/LZO-v1/python-lzo-1.08.tar.gz

I managed to unpack that using the python tarfile module (very handy for the
purpose)

In essence, the tarball contains a
setup.py
lzomodule.c
Makefile
and some documentation

It does not contain anything that appears to be binaries for Windows. The
instructions indicate that I am supposed to build it myself using the
Makefile. I do not have make nor a C-compiler installed, and I fear that if
I were to compile it, it would be a very tedious process for me, and I would
rather like to avoid it if at all possible.

Concerning the Windows LZO binaries I have previously struggled with
pytables and using LZO on Windows with HDF5 files, and in relation to that
Francesc Alted was so kind to build Windows LZO ver. 1.08 binaries as
discussed here

http://www.pytables.org/moin/FAQ#A.5BWindows.5DCan.27tfindLZObinariesforWindows

and available here as a zip file

http://www.pytables.org/download/lzo-win

Amongst others, this zip file has a

Gwin32\bin\lzo1.dll

file. By copying that to the ptables filder in my python25 installation I
have managed to get LZO working with pytables.

Getting back to the python bindings, the setup.py does contain a section,
which indicates that it adresses a Windows platform also:

...
if sys.platform == "win32":
    # Windows users have to configure the LZO_DIR path parameter to match
    # their LZO source installation.  The path set here is just an example
    # and thus unlikely to match your installation.
    LZO_DIR = r"c:\src\lzo-1.08"
    include_dirs.append(os.path.join(CURL_DIR, "include"))
    extra_objects.append(os.path.join(CURL_DIR, "lzo.lib"))
...

If I were clever enough I now guess I should be able to unpack the pytables
lzo Windows binaries to some suitable place (any recommendations?) and
modify the setup.py such that it
correctly "binds the dll" (this is black magic to me). One thing, which
concerns me, is that a file lzo.lib is mentioned in the current setup.py,
but there is not a file with that name in the GnuWin32 zip zip file from
Francesc in the lib folder of the zip I do find two lib files.:

liblzo.lib
liblzo-bcc.lib

but are any of these related to the lzo.lib mentioned in the setup.py?

It does not help that I have a very poor understanding of how Python binds
to native libraries, nor how things should be "installed" manually.

My next question, if somehow someone is able to guide me a little in the
process, then how do I use the library once available.

The README indicates that I should use the internal Python documentation- So
I guess i should just open an IPython shell do an

import lzo?
and then tab on lzo. and see what is available?

Sorry for the long post.

Kind regards,
Kim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100908/477fd52a/attachment.html>


More information about the Python-list mailing list