[2.7] bpo-34738: Add directory entries in ZIP files created by distutils. (GH-9419). (GH-10950)
(cherry picked from commit 67a93b3a0b
)
This commit is contained in:
parent
abe74feb91
commit
b2742ba5f9
|
@ -162,7 +162,15 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
|
|||
zip = zipfile.ZipFile(zip_filename, "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
if base_dir != os.curdir:
|
||||
path = os.path.normpath(os.path.join(base_dir, ''))
|
||||
zip.write(path, path)
|
||||
log.info("adding '%s'", path)
|
||||
for dirpath, dirnames, filenames in os.walk(base_dir):
|
||||
for name in dirnames:
|
||||
path = os.path.normpath(os.path.join(dirpath, name, ''))
|
||||
zip.write(path, path)
|
||||
log.info("adding '%s'", path)
|
||||
for name in filenames:
|
||||
path = os.path.normpath(os.path.join(dirpath, name))
|
||||
if os.path.isfile(path):
|
||||
|
|
|
@ -98,7 +98,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
|
|||
try:
|
||||
names = tar.getnames()
|
||||
names.sort()
|
||||
return tuple(names)
|
||||
return names
|
||||
finally:
|
||||
tar.close()
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class BuildDumbTestCase(support.TempdirManager,
|
|||
finally:
|
||||
fp.close()
|
||||
|
||||
contents = sorted(os.path.basename(fn) for fn in contents)
|
||||
contents = sorted(filter(None, map(os.path.basename, contents)))
|
||||
wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2], 'foo.py']
|
||||
if not sys.dont_write_bytecode:
|
||||
wanted.append('foo.pyc')
|
||||
|
|
|
@ -130,7 +130,9 @@ class SDistTestCase(PyPIRCCommandTestCase):
|
|||
zip_file.close()
|
||||
|
||||
# making sure everything has been pruned correctly
|
||||
self.assertEqual(len(content), 4)
|
||||
expected = ['', 'PKG-INFO', 'README', 'setup.py',
|
||||
'somecode/', 'somecode/__init__.py']
|
||||
self.assertEqual(sorted(content), ['fake-1.0/' + x for x in expected])
|
||||
|
||||
@unittest.skipUnless(zlib, "requires zlib")
|
||||
def test_make_distribution(self):
|
||||
|
@ -246,7 +248,13 @@ class SDistTestCase(PyPIRCCommandTestCase):
|
|||
zip_file.close()
|
||||
|
||||
# making sure everything was added
|
||||
self.assertEqual(len(content), 12)
|
||||
expected = ['', 'PKG-INFO', 'README', 'buildout.cfg',
|
||||
'data/', 'data/data.dt', 'inroot.txt',
|
||||
'scripts/', 'scripts/script.py', 'setup.py',
|
||||
'some/', 'some/file.txt', 'some/other_file.txt',
|
||||
'somecode/', 'somecode/__init__.py', 'somecode/doc.dat',
|
||||
'somecode/doc.txt']
|
||||
self.assertEqual(sorted(content), ['fake-1.0/' + x for x in expected])
|
||||
|
||||
# checking the MANIFEST
|
||||
f = open(join(self.tmp_dir, 'MANIFEST'))
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
ZIP files created by :mod:`distutils` will now include entries for
|
||||
directories.
|
Loading…
Reference in New Issue