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'): ...@@ -3462,16 +3462,18 @@ def makeNewRelease(project, ws, dest, version='99.99'):
).groups() ).groups()
dest = os.path.join(dest, "%s-%s-py%s.egg" % (eggname, version, pyver)) dest = os.path.join(dest, "%s-%s-py%s.egg" % (eggname, version, pyver))
if os.path.isfile(dist.location): if os.path.isfile(dist.location):
shutil.copy(dist.location, dest) with zipfile.ZipFile(dist.location, 'r') as old_zip:
zip = zipfile.ZipFile(dest, 'a') with zipfile.ZipFile(dest, 'w') as new_zip:
zip.writestr( for item in old_zip.infolist():
'EGG-INFO/PKG-INFO', data = old_zip.read(item.filename)
((zip.read('EGG-INFO/PKG-INFO').decode('ISO-8859-1') if item.filename == 'EGG-INFO/PKG-INFO':
).replace("Version: %s" % oldver, data = data.decode(
"Version: %s" % version) 'ISO-8859-1'
).encode('ISO-8859-1') ).replace(
) "Version: %s" % oldver,
zip.close() "Version: %s" % version
).encode('ISO-8859-1')
new_zip.writestr(item, data)
else: else:
shutil.copytree(dist.location, dest) shutil.copytree(dist.location, dest)
info_path = os.path.join(dest, 'EGG-INFO', 'PKG-INFO') 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