I have created a .7z archive using the usual basic Windows UI. It is my understanding this defaults to relative paths for any archives created. When looking in the archive post creation, all I see is a directory called ‘autocfg’. When I experimented with absolute paths this changed (as expected).
When unzipping on a Google Colab Linux machine using the below Python script:
import py7zr
inpath = '/usr/local/lib/python3.10/virtual-environments/autocfg/lib/python3.10/site-packages/autocfg/colorama.7z'
outpath = '/usr/local/lib/python3.10/virtual-environments/autocfg/lib/python3.10/site-packages'
with py7zr.SevenZipFile(inpath, mode='r') as szfile:
szfile.extractall(path=outpath)
szfile.close()
I get the following output:
site-packages
- Program Files
- My Sub Dir
- My Sub Dir 2
- autocfg
colorama
…this is the directory structure from Windows that has been preserved somehow. When I try using the Linux command line version of 7zip as per the below:
!7za e -y /usr/local/lib/python3.10/virtual-environments/autocfg/lib/python3.10/site-packages/autocfg/colorama.7z -o/usr/local/lib/python3.10/virtual-environments/autocfg/lib/python3.10/site-packages
…the .7z file ‘colorama’ unpacks correctly to:
site-packages
- colorama
…why is py7zr exhibiting this behaviour? What can I amend in my code to get my output as per how Linux command line is delivering it?
3