Skip to content

Commit 7ea5f01

Browse files
committed
Mark regular files in wheelbuilder
1 parent 00e9b77 commit 7ea5f01

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

setuptools/_wheelbuilder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def new_file(self, arcname: str, contents: _StrOrIter, permissions: int = 0o664)
125125
the UTF-8 text specified by ``contents``.
126126
"""
127127
zipinfo = ZipInfo(arcname, self._timestamp)
128-
zipinfo.external_attr = permissions << 16
128+
zipinfo.external_attr = (permissions | stat.S_IFREG) << 16
129129
zipinfo.compress_type = _COMPRESSION
130130
hashsum = hashlib.new(_HASH_ALG)
131131
file_size = 0
@@ -141,7 +141,7 @@ def new_file(self, arcname: str, contents: _StrOrIter, permissions: int = 0o664)
141141
def _save_record(self):
142142
arcname = f"{self._dist_info}/RECORD"
143143
zipinfo = ZipInfo(arcname, self._timestamp)
144-
zipinfo.external_attr = 0o664 << 16
144+
zipinfo.external_attr = (0o664 | stat.S_IFREG) << 16
145145
zipinfo.compress_type = _COMPRESSION
146146
out = self._zip.open(zipinfo, "w")
147147
buf = io.TextIOWrapper(out, encoding="utf-8")

setuptools/tests/test_wheelbuilder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This test is based on the `test_wheelfile.py` from pypa/wheel,
22
# which was initially distributed under the MIT License:
33
# Copyright (c) 2012 Daniel Holth <[email protected]> and contributors
4+
import stat
45
import sys
56
import textwrap
67
from zipfile import ZipFile, ZIP_DEFLATED
@@ -73,9 +74,8 @@ def test_attributes(tmp_path_factory, tmp_path):
7374
with ZipFile(wheel_path, "r") as zf:
7475
for filename, mode in files:
7576
info = zf.getinfo(filename)
76-
assert info.external_attr == (mode | 0o100000) << 16
77+
assert info.external_attr == (mode | stat.S_IFREG) << 16
7778
assert info.compress_type == ZIP_DEFLATED
7879

7980
info = zf.getinfo("test-1.0.dist-info/RECORD")
80-
permissions = (info.external_attr >> 16) & 0o777
81-
assert permissions == 0o664
81+
assert info.external_attr == (0o664 | stat.S_IFREG) << 16

0 commit comments

Comments
 (0)