[New-bugs-announce] [issue17274] distutils silently omits relative symlinks

Florian Berger report at bugs.python.org
Fri Feb 22 10:34:13 CET 2013

New submission from Florian Berger:

This issue is related to #12585, #15205 and #8876.

In `distutils/archive_util.py`, in `make_zipfile()`, the code

    for dirpath, dirnames, filenames in os.walk(base_dir):
        for name in filenames:
            path = os.path.normpath(os.path.join(dirpath, name))
            if os.path.isfile(path):
                zip.write(path, path)
                log.info("adding '%s'" % path)

will silently omit relative symlinks from the archive.

Relative symlinks (`file.dat -> ../../../real_file.dat`) will become invalid when copied as-is into the package directory before compressing.
`os.path.isfile(path)` will evaluate to `False` in this case.

That is a critical condition, as the file has explicitly been specified for inclusion, but the package author is never warned about the fact, rendering the distributed package defunct in worst case.

Actual behaviour: relative symlinks are silently ignored.

Expected behaviour: any file that, for whatever reason, can not be included in the distribution archive should be warned about.

As hinted at in #15205, this might be fixed in `distutils2` / `packaging` in case it always dereferences and copies files.

This issue could be fixed without breaking behaviour if no Exception is raised, but a warning is printed.

With `packaging` available in Python 3.3, this report also serves as documentation of the problem for legacy Python programmers searching the web.

Thanks for considering.

assignee: eric.araujo
components: Distutils
messages: 182658
nosy: eric.araujo, fberger, tarek
priority: normal
severity: normal
status: open
title: distutils silently omits relative symlinks
versions: Python 2.6, Python 3.1, Python 3.2, Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list