]> git.pld-linux.org Git - packages/python-dateutil.git/commitdiff
system tzdata patch from fedora. just in case auto/th/python-dateutil-1.5-3
authorElan Ruusamäe <glen@delfi.ee>
Thu, 24 Jan 2013 19:16:44 +0000 (21:16 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Thu, 24 Jan 2013 19:16:59 +0000 (21:16 +0200)
python-dateutil.spec
system-zoneinfo.patch [new file with mode: 0644]

index 37de86911dbdb9517fe1bb7cd1ed25ed5a5d3009..0c0ea5d21390d4eb479674fe8d805514342241b4 100644 (file)
@@ -3,14 +3,16 @@ Summary:      Extensions to the standard datetime module
 Summary(pl.UTF-8):     Rozszerzenia modułu datetime języka Python
 Name:          python-dateutil
 Version:       1.5
-Release:       2
+Release:       3
 License:       BSD
 Group:         Libraries/Python
 Source0:       http://niemeyer.net/download/python-dateutil/python-%{module}-%{version}.tar.gz
 # Source0-md5: 35f3732db3f2cc4afdc68a8533b60a52
+Patch0:                system-zoneinfo.patch
 URL:           http://niemeyer.net/python-dateutil
 BuildRequires: rpm-pythonprov
 BuildRequires: rpmbuild(macros) >= 0.219
+Requires:      tzdata
 BuildArch:     noarch
 BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -36,6 +38,7 @@ datetime, dostępnego w Pythonie 2.3+. Pozwala na:
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__python} setup.py build
diff --git a/system-zoneinfo.patch b/system-zoneinfo.patch
new file mode 100644 (file)
index 0000000..2f909dc
--- /dev/null
@@ -0,0 +1,103 @@
+diff -up python-dateutil-1.5/dateutil/zoneinfo/__init__.py\~ python-dateutil-1.5/dateutil/zoneinfo/__init__.py
+--- python-dateutil-1.5/dateutil/zoneinfo/__init__.py~ 2005-12-22 19:13:50.000000000 +0100
++++ python-dateutil-1.5/dateutil/zoneinfo/__init__.py  2011-08-17 15:24:29.019214748 +0200
+@@ -15,6 +15,7 @@ __all__ = ["setcachesize", "gettz", "reb
+ CACHE = []
+ CACHESIZE = 10
++USE_SYSTEM_ZONEINFO = True # XXX configure at build time
+ class tzfile(tzfile):
+     def __reduce__(self):
+@@ -29,7 +30,8 @@ def getzoneinfofile():
+             return os.path.join(os.path.dirname(__file__), entry)
+     return None
+-ZONEINFOFILE = getzoneinfofile()
++ZONEINFOFILE = getzoneinfofile() if USE_SYSTEM_ZONEINFO else None
++ZONEINFODIR = (os.getenv("TZDIR") or "/usr/share/zoneinfo").rstrip(os.sep)
+ del getzoneinfofile
+@@ -39,22 +40,37 @@ def setcachesize(size):
+     del CACHE[size:]
+ def gettz(name):
+-    tzinfo = None
+-    if ZONEINFOFILE:
+-        for cachedname, tzinfo in CACHE:
+-            if cachedname == name:
+-                break
++    for cachedname, tzinfo in CACHE:
++        if cachedname == name:
++            return tzinfo
++
++    name_parts = name.lstrip('/').split('/')
++    for part in name_parts:
++        if part == os.path.pardir or os.path.sep in part:
++            raise ValueError('Bad path segment: %r' % part)
++    filename = os.path.join(ZONEINFODIR, *name_parts)
++    try:
++        zonefile = open(filename, "rb")
++    except:
++        tzinfo = None
++    else:
++        tzinfo = tzfile(zonefile)
++        zonefile.close()
++
++    if tzinfo is None and ZONEINFOFILE:
++        tf = TarFile.open(ZONEINFOFILE)
++        try:
++            zonefile = tf.extractfile(name)
++        except KeyError:
++            tzinfo = None
+         else:
+-            tf = TarFile.open(ZONEINFOFILE)
+-            try:
+-                zonefile = tf.extractfile(name)
+-            except KeyError:
+-                tzinfo = None
+-            else:
+-                tzinfo = tzfile(zonefile)
+-            tf.close()
+-            CACHE.insert(0, (name, tzinfo))
+-            del CACHE[CACHESIZE:]
++            tzinfo = tzfile(zonefile)
++        tf.close()
++
++    if tzinfo is not None:
++        CACHE.insert(0, (name, tzinfo))
++        del CACHE[CACHESIZE:]
++
+     return tzinfo
+ def rebuild(filename, tag=None, format="gz"):
+diff -up python-dateutil-1.5/setup.py\~ python-dateutil-1.5/setup.py
+--- python-dateutil-1.5/setup.py~      2010-01-11 10:43:22.000000000 +0100
++++ python-dateutil-1.5/setup.py       2011-08-17 15:38:13.206304651 +0200
+@@ -15,6 +15,16 @@ TOPDIR = os.path.dirname(__file__) or ".
+ VERSION = re.search('__version__ = "([^"]+)"',
+                     open(TOPDIR + "/dateutil/__init__.py").read()).group(1)
++# XXX We would like to bind this to something like
++# --system-zoneinfo=/path/to/zoneinfo.  Any way of doing this short of
++# overriding build and install commands?
++if False:
++    extra_options = dict(
++        package_data={"": ["*.tar.gz"]},
++        )
++else:
++    extra_options = {}
++
+ setup(name="python-dateutil",
+       version = VERSION,
+@@ -29,7 +39,7 @@ The dateutil module provides powerful ex
+ datetime module, available in Python 2.3+.
+ """,
+       packages = ["dateutil", "dateutil.zoneinfo"],
+-      package_data={"": ["*.tar.gz"]},
+       include_package_data=True,
+       zip_safe=False,
++      **extra_options
+       )
This page took 0.066529 seconds and 4 git commands to generate.