summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorolt <olt@tinyerp.com>2009-07-24 03:01:14 -0400
committerolt <olt@tinyerp.com>2009-07-24 03:01:14 -0400
commit3472508614e7ee985d8f87faf4e6a658d5bdca56 (patch)
tree636011495a69e251e6bca14a9bfc41937696ad99 /setup.py
parent9b8f222fd9abebc127e30660003c15cf072d2b81 (diff)
[FIX] py2exe: pytz on win32: 'zoneinfo' directory now included in library.zip
bzr revid: olt@tinyerp.com-20090724070114-2dpxddpg2cabt15b
Diffstat (limited to 'setup.py')
-rwxr-xr-xsetup.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/setup.py b/setup.py
index be696bcf927..54df42afdc7 100755
--- a/setup.py
+++ b/setup.py
@@ -35,8 +35,10 @@ import glob
from distutils.core import setup, Command
from distutils.command.install import install
+has_py2exe = False
if os.name == 'nt':
import py2exe
+ has_py2exe = True
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "bin"))
@@ -142,6 +144,7 @@ options = {
"py2exe": {
"compressed": 1,
"optimize": 2,
+ "dist_dir": 'dist',
"packages": ["lxml", "lxml.builder", "lxml._elementpath", "lxml.etree",
"lxml.objectify", "decimal", "xml", "xml.dom", "xml.xpath",
"encodings","mx.DateTime","wizard","pychart","PIL", "pyparsing",
@@ -187,6 +190,30 @@ setup(name = name,
options = options,
)
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+if has_py2exe:
+ # Sometime between pytz-2008a and pytz-2008i common_timezones started to
+ # include only names of zones with a corresponding data file in zoneinfo.
+ # pytz installs the zoneinfo directory tree in the same directory
+ # as the pytz/__init__.py file. These data files are loaded using
+ # pkg_resources.resource_stream. py2exe does not copy this to library.zip so
+ # resource_stream can't find the files and common_timezones is empty when
+ # read in the py2exe executable.
+ # This manually copies zoneinfo into the zip. See also
+ # http://code.google.com/p/googletransitdatafeed/issues/detail?id=121
+ import pytz
+ import zipfile
+ # 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')
+ # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
+ disk_basedir = os.path.dirname(os.path.dirname(pytz.__file__))
+ zipfile_path = os.path.join(options['py2exe']['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()