Author rixx
Recipients DemoHT, bananaappletw, berker.peksag, docs@python, ezio.melotti, hynek, martin.panter, r.david.murray, rixx, serhiy.storchaka, tarek
Date 2018-05-29.22:39:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1527633570.01.0.682650639539.issue22021@psf.upfronthosting.co.za>
In-reply-to
Content
I'm similarly confused by this issue. If somebody can help me understand what's going on, I'll put my understanding into a documentation patch.

I have created this minimal example to demonstrate what I don't understand: I've created a directory structure within /tmp like this:

issue22021
└── root
    └── structure
        ├── content
        │   └── please_add.txt
        └── do_not_add.txt


Now I'd like to create a zip archive that contains the directories "structure" and "content", and the file "please_add.txt", but not the file "do_not_add.txt". My understanding of the documentation was that I'd have to do this:

>>> shutil.make_archive(base_name='/tmp/issue22021archive', format='zip', root_dir='/tmp/issue22021/root', base_dir='/tmp/issue22021/root/structure/content')

But on my system, the created file (/tmp/issue22021archive.zip) looks like this according to unzip -l:

Archive:  issue22021archive.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2018-05-30 00:26   tmp/issue22021/root/structure/content/
        0  2018-05-30 00:26   tmp/issue22021/root/structure/content/please_add.txt
---------                     -------
        0                     2 files

This is consistent with my experience that created archives will always contain directories from / on, which is unexpected to me.

It appears this happens whenever base_dir and root_dir is set, but to my understanding the documentation does not warn against this.

I've confirmed this behaviour with Python 3.6.5 and Python 3.5.3, but I suspect that doesn't really matter, as it seems to be a documentation issue.
History
Date User Action Args
2018-05-29 22:39:30rixxsetrecipients: + rixx, tarek, ezio.melotti, r.david.murray, docs@python, berker.peksag, hynek, martin.panter, serhiy.storchaka, DemoHT, bananaappletw
2018-05-29 22:39:30rixxsetmessageid: <1527633570.01.0.682650639539.issue22021@psf.upfronthosting.co.za>
2018-05-29 22:39:30rixxlinkissue22021 messages
2018-05-29 22:39:29rixxcreate