pypa/wheel

RECORD has incorrect file mode in generated archives

SpecLad opened this issue · 4 comments

Demonstrated on wheel itself:

$ tar -xf wheel-0.38.4.tar.gz
$ cd wheel-0.38.4/
$ python setup.py bdist_wheel
$ python
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import stat
>>> import zipfile
>>> zip = zipfile.ZipFile('dist/wheel-0.38.4-py3-none-any.whl')
>>> info = zip.getinfo('wheel-0.38.4.dist-info/RECORD')
>>> stat.S_ISREG(info.external_attr >> 16)
False

This should be True, since RECORD is a regular file. For files other than RECORD, this already works:

>>> info = zip.getinfo('wheel-0.38.4.dist-info/METADATA')
>>> stat.S_ISREG(info.external_attr >> 16)
True

Does this have any real-world impact?

Not much, as far as I can see. It does cause zipinfo to display the mode incorrectly, though:

$ zipinfo dist/wheel-0.38.4-py3-none-any.whl
Archive:  dist/wheel-0.38.4-py3-none-any.whl
Zip file size: 36070 bytes, number of entries: 23
...
-rw-r--r--  2.0 unx     1107 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/LICENSE.txt
-rw-r--r--  2.0 unx     2130 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/METADATA
-rw-r--r--  2.0 unx       92 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/WHEEL
-rw-r--r--  2.0 unx      108 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/entry_points.txt
-rw-r--r--  2.0 unx        6 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/top_level.txt
?rw-rw-r--  2.0 unx     1840 b- defN 23-Mar-04 15:58 wheel-0.38.4.dist-info/RECORD
23 files, 101193 bytes uncompressed, 33106 bytes compressed:  67.3%

FYI, you can't use this check on wheel itself anymore, as wheel no longer recursively builds itself. Flit-core actually forgets to set the "regular file" flag on all generated files. It took me several tries to realize that. 😆

I verified that this does fix the leading ? when building a wheel of a setuptools-based package, though.

@ofek, hatchling has this omission too (wheel only has this for RECORD, while flit-core and hatching have leading ?'s (no | stat.S_IFREG) on all generated files).