Comment 7 for bug 711084

Revision history for this message
GEM (nimp3) wrote :

Hi,
Warning, same missing folder zoneinfo with server in server\library.zip, but I don't know if zoneinfo is necessary for the server. But more than missing folder zoneinfo, the file reference.py is missing also.
If necessary, to add reference.py, add pytz in the list of required package in server\setup.py line 196 :
- "uuid",
+ "uuid", "pytz"
If necessary zoneinfo in server, add the code after in server\setup.py as in client

to add complete pytz library (with folder zoneinfo), like in client\setup.nsi in branch 5.0, add at the end of the script client\setup.py :

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
    import tempfile
    import shutil
    # Make sure the layout of pytz hasn't changed
    assert (pytz.__file__.endswith('__init__.pyc') or
          pytz.__file__.endswith('__init__.py')), pytz.__file__

    temp_dir = None
    pytz_dir = os.path.dirname(pytz.__file__)
    zoneinfo_dir = os.path.join(pytz_dir, 'zoneinfo')
    if not os.path.exists(zoneinfo_dir):
        egg = os.path.dirname(pytz_dir)

        if zipfile.is_zipfile(egg):
            temp_dir = tempfile.mkdtemp()
            zoneinfo_dir = os.path.join(temp_dir, 'pytz', 'zoneinfo')
            os.makedirs(zoneinfo_dir)

            archive = zipfile.ZipFile(egg)
            for filename in archive.namelist():
                if filename.startswith('pytz/zoneinfo/'):
                    file_path = os.path.join(temp_dir, filename)
                    destination = file_path.replace('/', os.sep)
                    if not file_path.endswith('/'):
                        try:
                            os.makedirs(os.path.dirname(destination))
                        except os.error:
                            pass
                        fp = file(destination, 'w')
                        fp.write(archive.read(filename))
                        fp.close()
            archive.close()

    # '..\\Lib\\pytz\\__init__.py' -> '..\\Lib'
    disk_basedir = os.path.dirname(os.path.dirname(zoneinfo_dir))
    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):
        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 temp_dir is not None:
        shutil.rmtree(temp_dir)

Bye