How to save symbolic links when unpacking an archive using Python?

Many zip archives (especially those that include OS X applications) contain symbolic links. Using the method, zipfile.extractallsymbolic links turn into regular files. Does anyone know how to save them as links?

+4
source share
2 answers

There seems to be no way to do this using the zipfile module. I solved this using the subprocess module:

from subprocess import check_output, CalledProcessError, STDOUT

try:
   check_output(['unzip', '-q', my_zipfile, '-d', destination], stderr=STDOUT)

...

except CalledProcessError as err:
   (use err.cmd, err.returncode and err.output to take action)
+2
source

Do not use extractall method . You will need to do this manually, possibly ending up with something like something like this (except that what you extract is not compressing).

+1
source

All Articles