Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #104029

Re: creating zipfile with symlinks

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Larry Martell <larry.martell@gmail.com>
Newsgroups comp.lang.python
Subject Re: creating zipfile with symlinks
Date Fri, 4 Mar 2016 07:18:57 -0500
Lines 41
Message-ID <mailman.185.1457093980.20602.python-list@python.org> (permalink)
References <CACwCsY5CFNVnTw=xpPJXXmYEH6Qb70yA+-XoJ+waFUdKDd6a8w@mail.gmail.com> <CACwCsY6cBfO4Wf1SebirMkKVCtm_KaK3vF9OPOfeDF5povscuQ@mail.gmail.com> <56D8AEBB.6060102@mrabarnett.plus.com> <CAPTjJmrDGfTMDdNGH1MWf6dnx--7A+nFHWpYLMp0+pdYmYE_kw@mail.gmail.com> <CACwCsY6CjDhQn6stT=HgWUT1cePYeYKX44i_K00dBstNhOJBEA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 6AIcCbAnjHeGcfuvn7IQZwIocuytS6yOsPyxibFSheow==
Return-Path <larry.martell@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'broken': 0.03; '---------': 0.05; 'mrab': 0.05; '-------': 0.09; 'filename,': 0.09; 'symlink': 0.09; 'python': 0.10; 'thu,': 0.15; '"zip': 0.16; '(there': 0.16; '08:45': 0.16; '2016': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'zipfile': 0.16; 'wrote:': 0.16; 'thanks.': 0.18; '>>>': 0.20; 'handles': 0.20; 'to:name:python- list@python.org': 0.20; 'file.': 0.22; 'am,': 0.23; 'bit': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'module': 0.25; '----------': 0.25; "doesn't": 0.26; 'command': 0.26; 'chris': 0.26; 'external': 0.27; '----': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'module.': 0.27; "skip:' 10": 0.28; 'fine': 0.28; 'regular': 0.29; 'larry': 0.29; '-----': 0.29; "i'm": 0.30; 'system,': 0.30; 'that.': 0.30; 'seconds': 0.31; 'know.': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'dir': 0.35; 'set.': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'mode': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'drop': 0.38; 'files': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'some': 0.40; 'skip:u 10': 0.61; 'total': 0.62; 'minutes': 0.64; 'within': 0.64; 'mar': 0.65; 'special': 0.73; '10:32': 0.84; 'different.': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=sUToqJBAQaxsMoPjFFjN0E0dUJrXNktW6T86o9nE0CU=; b=fIPKdJGz125PoIvLVajW815aMzIuFjrwf3O5sC81XuZDJTjrVPW2Vq29uf1R+AUQL4 WwSnIzD4gCZVTa9L3ZKCqNeZOETXca9N2GH5/4VycMDkeZhCXPJgPF/i48Gd2yFxBmyj CdKzgPwrRcYsjj6JoLQ6k9H/OYkTiMqJC6pzOse3SQYPTsg9S81PO6tgI1lhJXK0XRF9 4tzefxexqk4Iiq45toV186zaJUjiw5feSsnhNN1UOMEftUOv7eifTgzKDwy3ULUoplz7 DaKKytjW0gn5XdR+PQLwgPpSYxHcfIj5Re6mz523gy8crHYADpdtJHen///ZwOPVC+gk 13Og==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=sUToqJBAQaxsMoPjFFjN0E0dUJrXNktW6T86o9nE0CU=; b=NnQGSj4uGE0CnpH87tTttSEMrJACBm0eTwt/whwOvWMGviEO3EMzvdd9ruPakxopjd ng6PgxeCcBRtyvPIHmOQRVnfmH+E85jiiXnXgFSNUFVX1crOCcr3LT6ar1xCIU3PAdgb ohNluZTASiKZhBo4sgbVuyAU9F3zxdPaofM87IfEn6EuHn+vjW0p4bxvFLh0yktNMJl9 cW+U/QRZ4BkGOf3ayU9pnlG0mPQBmoi+DxNsAda4dxL2MKuLdsPU3vUf7lUM0yGbms8P GKnuE5x2HMwZBYnIEQwBlj7iTlLnM9NYcwd6/yrGATXyNhyNka27msALjdPH6vof/t5r cx7w==
X-Gm-Message-State AD7BkJLIBgeSSrR7NnkhyI8PeyNYHUjxb3/smXm9jSPhq9OOYQxDxyc1+a/EIHCu/uppH2rLpdfQXvV3nQqQ1w==
X-Received by 10.50.43.161 with SMTP id x1mr4475690igl.47.1457093977488; Fri, 04 Mar 2016 04:19:37 -0800 (PST)
In-Reply-To <CACwCsY6CjDhQn6stT=HgWUT1cePYeYKX44i_K00dBstNhOJBEA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:104029

Show key headers only | View raw


On Thu, Mar 3, 2016 at 10:32 PM, Larry Martell <larry.martell@gmail.com> wrote:
> On Thu, Mar 3, 2016 at 4:58 PM, Chris Angelico <rosuav@gmail.com> wrote:
>> On Fri, Mar 4, 2016 at 8:38 AM, MRAB <python@mrabarnett.plus.com> wrote:
>>> Is it even possible to zip a link?
>>>
>>> A quick search came up with this:
>>>
>>> Are hard links possible within a zip archive?
>>> http://stackoverflow.com/questions/8859616/are-hard-links-possible-within-a-zip-archive
>>
>> Hard links are different. Symlinks are files containing the target
>> filename, with a special mode bit set. I'm not sure if it's a standard
>> feature of all zip archivers, but on my Debian system, I can use "zip
>> --symlinks" to create such a zip. How that will unzip on a system that
>> doesn't understand symlinks, I don't know.
>>
>> rosuav@sikorsky:~/tmp$ ls -l
>> total 4
>> -rw-r--r-- 1 rosuav rosuav 162 Mar  4 08:48 aaa.zip
>> lrwxrwxrwx 1 rosuav rosuav   4 Mar  4 08:49 qwer -> asdf
>> rosuav@sikorsky:~/tmp$ unzip -l aaa.zip
>> Archive:  aaa.zip
>>   Length      Date    Time    Name
>> ---------  ---------- -----   ----
>>         4  2016-03-04 08:45   qwer
>> ---------                     -------
>>         4                     1 file
>>
>>
>> That's a broken symlink (there is no "asdf" in the directory), and zip
>> and unzip are both fine with that.
>>
>> Now, how the Python zipfile module handles this, I don't know. The
>> ZipInfo shows a file mode of 'lrwxrwxrwx', but when I call extract(),
>> it comes out as a regular file. You might have to do some work
>> manually, or else just drop to an external command with --symlinks.
>
> Thanks. That's what I ended up doing.

Unfortunately very slow - around 8 minutes to zip a 7GB dir using the
command line zip vs. 13 seconds with the python zipfile module.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: creating zipfile with symlinks Larry Martell <larry.martell@gmail.com> - 2016-03-04 07:18 -0500

csiph-web