Directory Hierarchy Issue When Using Shutil.make_archive
I want to create a zip archive of the pip package , code as following import shutil import os import pip shutil.make_archive(os.path.join(os.getcwd(), 'pipzip'), 'zip', root_dir=p
Solution 1:
You were half way there. Basically you were specifying the root_dir and not the base_dir. You can do it by using the following snippet.
import shutil
import os
import pip
from pathlib import Path
shutil.make_archive(base_name=os.path.join(os.getcwd(), 'pipzip'), format='zip', root_dir=Path(pip.__path__[0]).parent, base_dir=Path(pip.__path__[0]).name)
shutil.unpack_archive(os.path.join(os.getcwd(), 'pipzip.zip'))
Post a Comment for "Directory Hierarchy Issue When Using Shutil.make_archive"