[docs] [issue22021] shutil.make_archive() root_dir do not work
report at bugs.python.org
Tue May 29 18:39:30 EDT 2018
Tobias Kunze <r at rixx.de> added the comment:
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:
│ └── please_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:
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.
Python tracker <report at bugs.python.org>
More information about the docs