Commit 121b182f authored by Jérome Perrin's avatar Jérome Perrin Committed by Julien Muchembled

tests: Fix makeNewRelease when installed as a zipped egg

python ZipFile module does not support updating an entry in place, instead make
a new zip file and copy all entries.
parent 64ac43b1
......@@ -3462,16 +3462,18 @@ def makeNewRelease(project, ws, dest, version='99.99'):
).groups()
dest = os.path.join(dest, "%s-%s-py%s.egg" % (eggname, version, pyver))
if os.path.isfile(dist.location):
shutil.copy(dist.location, dest)
zip = zipfile.ZipFile(dest, 'a')
zip.writestr(
'EGG-INFO/PKG-INFO',
((zip.read('EGG-INFO/PKG-INFO').decode('ISO-8859-1')
).replace("Version: %s" % oldver,
"Version: %s" % version)
).encode('ISO-8859-1')
)
zip.close()
with zipfile.ZipFile(dist.location, 'r') as old_zip:
with zipfile.ZipFile(dest, 'w') as new_zip:
for item in old_zip.infolist():
data = old_zip.read(item.filename)
if item.filename == 'EGG-INFO/PKG-INFO':
data = data.decode(
'ISO-8859-1'
).replace(
"Version: %s" % oldver,
"Version: %s" % version
).encode('ISO-8859-1')
new_zip.writestr(item, data)
else:
shutil.copytree(dist.location, dest)
info_path = os.path.join(dest, 'EGG-INFO', 'PKG-INFO')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment