Update to 2.4

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-01-21 12:12:23 -05:00
parent b612e52404
commit 58e0ca4060
5 changed files with 75 additions and 121 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
python-dateutil-1.4.1.tar.gz
/python-dateutil-1.5.tar.gz
/python-dateutil-2.2.tar.gz
/2.4.0.tar.gz

View File

@ -1,103 +0,0 @@
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
)

View File

@ -0,0 +1,50 @@
--- dateutil/zoneinfo/__init__.py
+++ dateutil/zoneinfo/__init__.py
@@ -14,9 +14,10 @@
__all__ = ["setcachesize", "gettz", "rebuild"]
-_ZONEFILENAME = "dateutil-zoneinfo.tar.gz"
+_LOCAL_ZONEINFO_FILE = "dateutil-zoneinfo.tar.gz"
+_SYSTEM_ZONEINFO_DIR = "/usr/share/zoneinfo"
-# python2.6 compatability. Note that TarFile.__exit__ != TarFile.close, but
+# python2.6 compatibility. Note that TarFile.__exit__ != TarFile.close, but
# it's close enough for python2.6
_tar_open = TarFile.open
if not hasattr(TarFile, '__exit__'):
@@ -31,9 +32,8 @@
def getzoneinfofile_stream():
try:
- return BytesIO(get_data(__name__, _ZONEFILENAME))
+ return BytesIO(get_data(__name__, _LOCAL_ZONEINFO_FILE))
except IOError as e: # TODO switch to FileNotFoundError?
- warnings.warn("I/O error({0}): {1}".format(e.errno, e.strerror))
return None
@@ -59,6 +59,14 @@
self.zones.update(links)
else:
self.zones = dict()
+ if os.path.isdir(_SYSTEM_ZONEINFO_DIR):
+ for root, dirnames, filenames in os.walk(_SYSTEM_ZONEINFO_DIR):
+ for filename in filenames:
+ absolute_filename = os.path.join(root, filename)
+ relative_filename = absolute_filename[len(_SYSTEM_ZONEINFO_DIR)+1:]
+ with open(absolute_filename, "rb") as file:
+ if file.read(4) == b"TZif":
+ self.zones[relative_filename] = tzfile(absolute_filename, relative_filename)
# The current API has gettz as a module function, although in fact it taps into
@@ -99,7 +107,7 @@
"libc-bin or some other package that provides it, "
"or it's not in your PATH?")
raise
- target = os.path.join(moduledir, _ZONEFILENAME)
+ target = os.path.join(moduledir, _LOCAL_ZONEINFO_FILE)
with _tar_open(target, "w:%s" % format) as tf:
for entry in os.listdir(zonedir):
entrypath = os.path.join(zonedir, entry)

View File

@ -1,42 +1,48 @@
Name: python-dateutil
Version: 1.5
Release: 0%{?dist}
Version: 2.4.0
Release: 1%{?dist}
Epoch: 1
Summary: Powerful extensions to the standard datetime module
Group: Development/Languages
License: Python
URL: http://labix.org/python-dateutil
Source0: http://labix.org/download/%{name}/%{name}-%{version}.tar.gz
Patch0: python-dateutil-1.5-system-zoneinfo.patch
URL: https://github.com/dateutil/dateutil
Source0: https://github.com/dateutil/dateutil/archive/2.4.0.tar.gz
# https://github.com/dateutil/dateutil/issues/11
Patch0: python-dateutil-system-zoneinfo.patch
BuildArch: noarch
BuildRequires: python-devel,python-setuptools
Requires: tzdata
BuildRequires: python2-devel
BuildRequires: python-setuptools
Requires: tzdata
Requires: python-six
%description
The dateutil module provides powerful extensions to the standard datetime
module available in Python 2.3+.
%prep
%setup -q
%patch0 -p1
%setup -q -n dateutil-%{version}
%patch0 -p0
iconv --from=ISO-8859-1 --to=UTF-8 NEWS > NEWS.new
mv NEWS.new NEWS
%build
%{__python} setup.py build
%{__python2} setup.py build
%install
%{__python} setup.py install --skip-build --root $RPM_BUILD_ROOT
%{__python2} setup.py install --skip-build --root $RPM_BUILD_ROOT
%files
%doc example.py LICENSE NEWS README
%{python_sitelib}/dateutil/
%exclude %{python_sitelib}/dateutil/zoneinfo/zoneinfo-2010g.tar.gz
%{python_sitelib}/*.egg-info
%license LICENSE
%doc NEWS README.rst
%{python2_sitelib}/dateutil/
%{python2_sitelib}/*.egg-info
%changelog
* Wed Jan 21 2015 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1:2.4.0-1
- Change to new upstream, update to 2.4 (#1126521)
* Tue Aug 05 2014 Jon Ciesla <limburgher@gmail.com> - 1:1.5-9
- Reverting to 1.5 pre user feedback and upstream.
@ -95,7 +101,7 @@ mv NEWS.new NEWS
- fix license tag
* Tue Jul 01 2008 Jef Spaleta <jspaleta AT fedoraproject DOT org> 1.4-1
- Latest upstream release
- Latest upstream release
* Fri Jan 04 2008 Jef Spaleta <jspaleta@fedoraproject.org> 1.2-2
- Fix for egg-info file creation

View File

@ -1 +1 @@
35f3732db3f2cc4afdc68a8533b60a52 python-dateutil-1.5.tar.gz
ac22c66e2dfe25f45d80e4b9d60e19af 2.4.0.tar.gz