Commit 0782a2fc 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 62f248af
...@@ -3522,16 +3522,18 @@ def makeNewRelease(project, ws, dest, version='99.99'): ...@@ -3522,16 +3522,18 @@ def makeNewRelease(project, ws, dest, version='99.99'):
eggname, oldver, pyver = egg_parse(dist.egg_name()).groups() eggname, oldver, pyver = egg_parse(dist.egg_name()).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'
).replace(
"Version: %s" % oldver,
"Version: %s" % version
).encode('ISO-8859-1') ).encode('ISO-8859-1')
) new_zip.writestr(item, data)
zip.close()
elif dist.location.endswith('site-packages'): elif dist.location.endswith('site-packages'):
os.mkdir(dest) os.mkdir(dest)
shutil.copytree( 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