summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Coraor <nate@bx.psu.edu>2016-02-05 16:12:11 -0500
committerNate Coraor <nate@bx.psu.edu>2016-02-05 16:12:11 -0500
commit696481ce84055fe8b408365ba0768f89a73229c0 (patch)
tree6053fcce4a3fa60f69532aa974c97fb92ffe966c
parent617852682fe51fad649890b0ae8fe9d2197b7be3 (diff)
downloadwheel-696481ce84055fe8b408365ba0768f89a73229c0.tar.gz
Create archive files with the same modes as their sources, change test
accordingly.
-rw-r--r--wheel/archive.py4
-rw-r--r--wheel/test/test_wheelfile.py17
2 files changed, 12 insertions, 9 deletions
diff --git a/wheel/archive.py b/wheel/archive.py
index f4dd617..81943a1 100644
--- a/wheel/archive.py
+++ b/wheel/archive.py
@@ -50,12 +50,12 @@ def make_wheelfile_inner(base_name, base_dir='.'):
deferred = []
def writefile(path, date_time):
+ st = os.stat(path)
if date_time is None:
- st = os.stat(path)
mtime = time.gmtime(st.st_mtime)
date_time = mtime[0:6]
zinfo = zipfile.ZipInfo(path, date_time)
- zinfo.external_attr = 0o100644 << 16
+ zinfo.external_attr = st.st_mode << 16
with open(path, 'rb') as fp:
zip.writestr(zinfo, fp.read())
log.info("adding '%s'" % path)
diff --git a/wheel/test/test_wheelfile.py b/wheel/test/test_wheelfile.py
index 59bbb4c..9d724b8 100644
--- a/wheel/test/test_wheelfile.py
+++ b/wheel/test/test_wheelfile.py
@@ -124,15 +124,18 @@ def test_zipfile_timestamp():
def test_zipfile_attributes():
# With the change from ZipFile.write() to .writestr(), we need to manually
- # set member attributes. Per existing tradition file permissions are forced
- # to 0o644, although in the future we may want to preserve executable bits.
+ # set member attributes.
with temporary_directory() as tempdir:
- path = os.path.join(tempdir, 'foo')
- with codecs.open(path, 'w', encoding='utf-8') as fp:
- fp.write('foo\n')
+ files = (('foo', 0o644), ('bar', 0o755))
+ for filename, mode in files:
+ path = os.path.join(tempdir, filename)
+ with codecs.open(path, 'w', encoding='utf-8') as fp:
+ fp.write(filename + '\n')
+ os.chmod(path, mode)
zip_base_name = os.path.join(tempdir, 'dummy')
zip_filename = wheel.archive.make_wheelfile_inner(
zip_base_name, tempdir)
with readable_zipfile(zip_filename) as zf:
- for info in zf.infolist():
- assert info.external_attr == 0o100644 << 16
+ for filename, mode in files:
+ info = zf.getinfo(os.path.join(tempdir, filename))
+ assert info.external_attr == (mode | 0o100000) << 16