Commit 2da14cc5 authored by Jérome Perrin's avatar Jérome Perrin Committed by Xavier Thompson

[fix] 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 30b0af16
......@@ -3444,16 +3444,18 @@ def makeNewRelease(project, ws, dest, version='99.99'):
eggname, oldver, pyver = egg_parse(dist.egg_name()).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)
elif dist.location.endswith('site-packages'):
os.mkdir(dest)
shutil.copytree(
......
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