-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distutils: ZIP files don't include directory entries #78919
Comments
ZIP files created by distutils don't include entries for directories. For example, if the directory structure is
the ZIP file will contain entries 'dist/file1.py' and 'dist/sub/file2.py', but not 'dist/' and 'dist/sub/'. This only when use the zipfile module. If it is not available for some reasons, the zip command is used. In that case directory entries are created. The are created also in TAR files. All other methods of packing a tree to a ZIP in the stdlib (shutil.make_archive(), zipfile CLI, zipapp, Tools/msi/make_zip.py) create directory entries too. zipimport doesn't support implicit namespace packages if directory entries are not added (bpo-14905). The proposed PR makes distutils adding directory entries in a ZIP file. |
I don't see a problem with this. If the zip file has 'dist/file1.py' then you know to create a directory when unzipping. If you want to indicate that there's an empty directory 'foo', then put 'foo/' in the zip file. |
There are two problems:
|
IMO inconsistency with tarfile is not very relevant. About the zip utility: are you saying that the unix unzip command is not able to inspect or extract distutils sdists? About zipimport, the question is: are sdists meant to be directly importable (IMO no). That said, if it is a minor change with no downsides, I wouldn’t oppose it. I just wanted to be clear on the reasons / benefits. |
The inconsistency is not just with the tarfile module, but with other method of creating ZIP archives. The unix unzip command creates directories if needed, but I am not sure about other third-party utilities. Since all know ZIP creators creates entries for directories, I would not be surprised if there are ZIP readers that doesn't work without explicit entries for directories. Zipimport is an example of this. Matthew mentioned other case. Empty directories currently are added to the TAR archive, but are omitted in the ZIP archive (unless you use an external zip tool). TAR archives are common on Unix, ZIP archives are common on Windows, and we can get different source distributions for Unix and Windows. You need to add a fake empty file to be sure that the directory will be added in the distribution. Some old DOS archives needed this trick, but the ZIP format supports empty directories. The downside of adding entries for directories is that this increases the size of the archive. But the difference is pretty small. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: