From deee7ff03d1f882216150ddeeda8d53bf552659c506608018624c22282bdbffd Mon Sep 17 00:00:00 2001 From: Denisart Benjamin Date: Fri, 14 Nov 2014 15:27:07 +0000 Subject: [PATCH] Accepting request 261436 from home:aplanas:branches:devel:languages:python Use the system tz database. OBS-URL: https://build.opensuse.org/request/show/261436 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pytz?expand=0&rev=27 --- python-pytz.changes | 5 +++++ python-pytz.spec | 9 +++++++++ system_zoneinfo.patch | 44 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 system_zoneinfo.patch diff --git a/python-pytz.changes b/python-pytz.changes index d09a1b4..2f7aa73 100644 --- a/python-pytz.changes +++ b/python-pytz.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Nov 13 12:17:35 UTC 2014 - aplanas@suse.com + +- Use system tz database instead pytz one + ------------------------------------------------------------------- Tue Nov 11 11:47:38 UTC 2014 - idonmez@suse.com diff --git a/python-pytz.spec b/python-pytz.spec index c8d0004..d46a61a 100644 --- a/python-pytz.spec +++ b/python-pytz.spec @@ -26,9 +26,14 @@ Url: http://pytz.sourceforge.net Source: http://pypi.python.org/packages/source/p/pytz/pytz-%{version}.tar.bz2 # PATCH-FIX-UPSTREAM fix-tests.patch -- Remote tests which are known to be broken Patch0: fix-tests.patch +# PATCH-FEATURE-OPENSUSE -- Use system tz database (Olson database) +Patch1: system_zoneinfo.patch +Requires: timezone BuildRequires: fdupes BuildRequires: python-devel BuildRequires: python-nose +# Tests will use this package +BuildRequires: timezone BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} && 0%{?suse_version} <= 1110 %{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} @@ -53,6 +58,8 @@ Amost all of the Olson timezones are supported. %setup -q -n pytz-%{version} # Disable test which is not working (and documented so) %patch0 -p1 +# Use system tz database +%patch1 -p1 # For rpmlint warning: remove shebang from python library: sed -i '/^#!/d' ./pytz/tzfile.py @@ -61,6 +68,8 @@ python setup.py build %install python setup.py install --prefix=%{_prefix} --root=%{buildroot} +# Remove the pytz zoneinfo +rm -fr %{buildroot}%{python_sitelib}/pytz/zoneinfo %fdupes %{buildroot}%{python_sitelib} %check diff --git a/system_zoneinfo.patch b/system_zoneinfo.patch new file mode 100644 index 0000000..7048c67 --- /dev/null +++ b/system_zoneinfo.patch @@ -0,0 +1,44 @@ +Index: pytz-2014.9/pytz/__init__.py +=================================================================== +--- pytz-2014.9.orig/pytz/__init__.py ++++ pytz-2014.9/pytz/__init__.py +@@ -25,11 +25,6 @@ __all__ = [ + + import sys, datetime, os.path, gettext + +-try: +- from pkg_resources import resource_stream +-except ImportError: +- resource_stream = None +- + from pytz.exceptions import AmbiguousTimeError + from pytz.exceptions import InvalidTimeError + from pytz.exceptions import NonExistentTimeError +@@ -86,13 +81,7 @@ def open_resource(name): + 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(os.path.dirname(__file__), +- 'zoneinfo', *name_parts) +- if not os.path.exists(filename) and resource_stream is not None: +- # http://bugs.launchpad.net/bugs/383171 - we avoid using this +- # unless absolutely necessary to help when a broken version of +- # pkg_resources is installed. +- return resource_stream(__name__, 'zoneinfo/' + name) ++ filename = os.path.join('/usr/share/zoneinfo', *name_parts) + return open(filename, 'rb') + + +Index: pytz-2014.9/pytz/tzfile.py +=================================================================== +--- pytz-2014.9.orig/pytz/tzfile.py ++++ pytz-2014.9/pytz/tzfile.py +@@ -127,7 +127,7 @@ def build_tzinfo(zone, fp): + if __name__ == '__main__': + import os.path + from pprint import pprint +- base = os.path.join(os.path.dirname(__file__), 'zoneinfo') ++ base = '/usr/share/zoneinfo' + tz = build_tzinfo('Australia/Melbourne', + open(os.path.join(base,'Australia','Melbourne'), 'rb')) + tz = build_tzinfo('US/Eastern',