Add zoneinfo in library.zip of py2exe

(transplanted from 896a03549264a263d9e9a010e69953701006bcba)
This commit is contained in:
Cédric Krier
2009-11-06 20:27:51 +01:00
parent b616d6c992
commit d5fca752fb
+19 -1
View File
@@ -55,7 +55,7 @@ if os.name == 'nt':
],
}
}
args['zipfile'] = None
args['zipfile'] = 'library.zip'
elif os.name == 'mac' \
or (hasattr(os, 'uname') and os.uname()[0] == 'Darwin'):
import py2app
@@ -144,10 +144,28 @@ if os.name == 'nt':
if 'py2exe' in dist.commands:
import shutil
import pytz
import zipfile
gtk_dir = find_gtk_dir()
dist_dir = dist.command_obj['py2exe'].dist_dir
# pytz installs the zoneinfo directory tree in the same directory
# Make sure the layout of pytz hasn't changed
assert (pytz.__file__.endswith('__init__.pyc') or
pytz.__file__.endswith('__init__.py')), pytz.__file__
zoneinfo_dir = os.path.join(os.path.dirname(pytz.__file__), 'zoneinfo')
disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
zipfile_path = os.path.join(dist_dir, 'library.zip')
z = zipfile.ZipFile(zipfile_path, 'a')
for absdir, directories, filenames in os.walk(zoneinfo_dir):
assert absdir.startswith(disk_basedir), (absdir, disk_basedir)
zip_dir = absdir[len(disk_basedir):]
for f in filenames:
z.write(os.path.join(absdir, f), os.path.join(zip_dir, f))
z.close()
if os.path.isdir(os.path.join(dist_dir, 'plugins')):
shutil.rmtree(os.path.join(dist_dir, 'plugins'))
shutil.copytree(os.path.join(os.path.dirname(__file__), 'tryton', 'plugins'),