<div style="color:#000; font-size: 14px;font-family: arial;"><div><span style="background-color: rgb(243, 243, 243); color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures;">The current behavior of</span><span style="background-color: rgb(243, 243, 243); color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures;"> </span><a href="https://docs.python.org/3/library/shutil.html#shutil.make_archive" style="font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; box-sizing: border-box; color: rgb(12, 147, 228);">shutil.make_archive</a><span style="background-color: rgb(243, 243, 243); color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures;"> </span><span style="background-color: rgb(243, 243, 243); color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures;">caused many issues , the problem is mainly on the extracted archive directory hierarchy. These are the proofs:</span></div><div class="cl-preview-section" style="box-sizing: border-box; color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; background-color: rgb(243, 243, 243);"><p style="box-sizing: border-box; margin: 1.2em 0px;"><a href="https://stackoverflow.com/questions/51914467/directory-hierarchy-issue-when-using-shutil-make-archive" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/51914467/directory-hierarchy-issue-when-using-shutil-make-archive</a></p></div><div class="cl-preview-section" style="box-sizing: border-box; color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; background-color: rgb(243, 243, 243);"><p style="box-sizing: border-box; margin: 1.2em 0px;"><a href="https://stackoverflow.com/questions/32640053/compressing-directory-using-shutil-make-archive-while-preserving-directory-str" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/32640053/compressing-directory-using-shutil-make-archive-while-preserving-directory-str</a></p></div><div class="cl-preview-section" style="box-sizing: border-box; color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; background-color: rgb(243, 243, 243);"><p style="box-sizing: border-box; margin: 1.2em 0px;"><a href="https://stackoverflow.com/questions/41624800/shutil-make-archive-issue-dont-want-directories-included-in-zip-file" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/41624800/shutil-make-archive-issue-dont-want-directories-included-in-zip-file</a></p></div><div class="cl-preview-section" style="box-sizing: border-box; color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; background-color: rgb(243, 243, 243);"><p style="box-sizing: border-box; margin: 1.2em 0px;"><a href="https://stackoverflow.com/questions/50156657/unexpected-file-using-shutil-make-archive-to-compress-file" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/50156657/unexpected-file-using-shutil-make-archive-to-compress-file</a><br style="box-sizing: border-box;">For example , if I want to create a zip archive of the <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">pip</code> package (path specified by <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">pip.__path__[0])</code>), and need a directory named <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">pip</code> to hold the  files and folders which originally reside in the pip package when unpacking the archive, then I need give <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">root_dir</code>parameter of <a href="https://docs.python.org/3/library/shutil.html#shutil.make_archive" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">shutil.make_archive</a> the parent directory of the <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">pip</code>package path (<code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">root_dir=Path(pip.__path__[0]).parent</code>), and then the <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">base_dir</code> parameter the final path component of the <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">pip</code> package path(<code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">base_dir=Path(pip.__path__[0]).name</code>) , so it is <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">os.path.join(root_dir, base_dir)</code> that specified the directory to archive , so weird !!!<br style="box-sizing: border-box;">I suggest to change <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">shutil.make_archive(base_name, format[, root_dir[, base_dir]])</code> to <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">shutil.make_archive(base_name, format[, archived_dir[, archive_prfix]])</code> where <code style="box-sizing: border-box; font-family: "Roboto Mono", "Lucida Sans Typewriter", "Lucida Console", monaco, Courrier, monospace; font-size: 0.85em; background-color: rgba(0, 0, 0, 0.05); border-radius: 2px; padding: 2px 4px;">archived_dir</code>denotes the path to be archived and archive_prfix denotes the common prefix of all files and directories in the archive (it is just a path component and we shouldn’t assume the existence of it on the file system).</p></div><div class="cl-preview-section" style="box-sizing: border-box; color: rgba(0, 0, 0, 0.75); font-family: Lato, "Helvetica Neue", Helvetica, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures; background-color: rgb(243, 243, 243);"><p style="box-sizing: border-box; margin: 1.2em 0px;">If the current behavior of <a href="https://docs.python.org/3/library/shutil.html#shutil.make_archive" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">shutil.make_archive</a> won’t be changed , I’d suggest improve its doc, because  so many people couldn’t grasp the use of <a href="https://docs.python.org/3/library/shutil.html#shutil.make_archive" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">shutil.make_archive</a> even consulting the doc , these are the proofs:<br style="box-sizing: border-box;"><a href="https://stackoverflow.com/questions/45245079/python-how-to-use-shutil-make-archive" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/45245079/python-how-to-use-shutil-make-archive</a><br style="box-sizing: border-box;"><a href="https://stackoverflow.com/questions/30049201/how-to-compress-a-file-with-shutil-make-archive-in-python" style="box-sizing: border-box; background-color: transparent; color: rgb(12, 147, 228);">https://stackoverflow.com/questions/30049201/how-to-compress-a-file-with-shutil-make-archive-in-python</a></p></div><div><br></div><div><br></div><div><br></div></div><!-- jy5ContentSuffix --><br><br><span title="neteasefooter"><p> </p></span>