Distributing a Python script to unpack .tar.xz
Question: Is there a way to distribute a Python script that can unpack a .tar.xz file?

Specifically:

  * This needs to run on other people's machines, not mine, so I can't require any extra modules to have been installed.

  * I can get away with assuming the presence of Python 2.7, but not 3.x.

So that seems to amount to asking whether out-of-the-box Python 2.7 has such a
feature, and as far as I can tell the answer is no, but is there anything I'm
missing?


Answer: First decompress the `xz` file into `tar` data and then extract the `tar`
data:

    
    
    import lzma
    import tarfile
    from contextlib import closing
    with lzma.open("file.tar.xz") as f:
        with tarfile.open(fileobj=f) as tar:
            content = tar.extractall('/path/to/extract')
    

(not tested but it should be pretty much it)

