[Distutils] pypi and easy_install
Phillip J. Eby
pje at telecommunity.com
Sat Jan 19 20:14:18 CET 2008
At 02:08 PM 1/19/2008 -0500, Phillip J. Eby wrote:
>Oh, and if tarfile is present, you can open a tarfile for writing
>with 'w:gz' or 'w:bz2' to have it apply the compression while
>building, which is probably more efficient. However, if the
>appropriate module isn't available, it'll raise a
>tarfile.CompressionError at creation time. So the code could be
>something like:
>
> try:
> import tarfile
> except ImportError:
> tarfile = None
>
> if tarfile is not None:
> ext = compress_ext.get(compress, '')
> try:
> tar = tarfile.open(archive_name+ext, "w"+ext.replace('.',':'))
> except tarfile.CompressionError:
> tar = tarfile.open(archive_name, "w")
> tar.add(base_dir)
> tar.close()
> if tar.name == archive_name+ext:
> return tar.name # we're done
Actually, this bit above is wrong, as it turns out tar.name will
never include the extra extension. :( So, a flag is needed in place
of using tar.name.
More information about the Distutils-SIG
mailing list