diff --git a/.gitignore b/.gitignore index 20adb8b..1f6317e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ pytz-2010h.tar.gz /pytz-2016.7.tar.gz /pytz-2016.10.tar.gz /pytz-2017.2.zip +/pytz-2018.5.tar.gz diff --git a/Makefile b/Makefile deleted file mode 100644 index 478d6ab..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: pytz -# $Id$ -NAME := pytz -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/pytz-zoneinfo.patch b/pytz-zoneinfo.patch index 9f17615..039083c 100644 --- a/pytz-zoneinfo.patch +++ b/pytz-zoneinfo.patch @@ -1,42 +1,47 @@ diff --git a/pytz/__init__.py b/pytz/__init__.py -index 13c83b1..e8a674f 100644 +index 120fab4..b0a3826 100644 --- a/pytz/__init__.py +++ b/pytz/__init__.py -@@ -70,6 +70,9 @@ else: # Python 2.x +@@ -73,6 +73,9 @@ else: # Python 2.x """ return s.encode('ASCII') -+_tzinfo_dir = os.getenv("TZDIR") or "/usr/share/zoneinfo" ++_tzinfo_dir = os.getenv('PYTZ_TZDATADIR') or '/usr/share/zoneinfo' +if _tzinfo_dir.endswith(os.sep): + _tzinfo_dir = _tzinfo_dir[:-1] def open_resource(name): """Open a resource from the zoneinfo subdir for reading. -@@ -81,19 +84,7 @@ def open_resource(name): +@@ -87,23 +90,8 @@ 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): -- # http://bugs.launchpad.net/bugs/383171 - we avoid using this -- # unless absolutely necessary to help when a broken version of -- # pkg_resources is installed. -- try: -- from pkg_resources import resource_stream -- except ImportError: -- resource_stream = None +- zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', None) +- if zoneinfo_dir is not None: +- filename = os.path.join(zoneinfo_dir, *name_parts) +- else: +- filename = os.path.join(os.path.dirname(__file__), +- 'zoneinfo', *name_parts) +- if not os.path.exists(filename): +- # http://bugs.launchpad.net/bugs/383171 - we avoid using this +- # unless absolutely necessary to help when a broken version of +- # pkg_resources is installed. +- try: +- from pkg_resources import resource_stream +- except ImportError: +- resource_stream = None - -- if resource_stream is not None: -- return resource_stream(__name__, 'zoneinfo/' + name) -+ filename = os.path.join(_tzinfo_dir, *name_parts) +- if resource_stream is not None: +- return resource_stream(__name__, 'zoneinfo/' + name) ++ zoneinfo_dir = os.environ.get('PYTZ_TZDATADIR', _tzinfo_dir) ++ filename = os.path.join(zoneinfo_dir, *name_parts) return open(filename, 'rb') -@@ -490,1044 +481,33 @@ def _test(): +@@ -484,1042 +472,37 @@ def _test(): + if __name__ == '__main__': _test() - -all_timezones = \ -['Africa/Abidjan', - 'Africa/Accra', @@ -412,7 +417,6 @@ index 13c83b1..e8a674f 100644 - 'CST6CDT', - 'Canada/Atlantic', - 'Canada/Central', -- 'Canada/East-Saskatchewan', - 'Canada/Eastern', - 'Canada/Mountain', - 'Canada/Newfoundland', @@ -624,13 +628,13 @@ index 13c83b1..e8a674f 100644 - 'US/Michigan', - 'US/Mountain', - 'US/Pacific', -- 'US/Pacific-New', - 'US/Samoa', - 'UTC', - 'Universal', - 'W-SU', - 'WET', - 'Zulu'] ++ +all_timezones = [] +for root, dirs, files in os.walk(_tzinfo_dir): + for exclude in 'posix', 'right': @@ -641,6 +645,7 @@ index 13c83b1..e8a674f 100644 + for tz_file in files + if tz_file != 'README' and tz_file != 'Theory' + and '.' not in tz_file) ++ all_timezones = LazyList( tz for tz in all_timezones if resource_exists(tz)) @@ -1085,6 +1090,7 @@ index 13c83b1..e8a674f 100644 - 'US/Mountain', - 'US/Pacific', - 'UTC'] ++ +common_timezones = [l.split()[2] + for l in open(os.path.join(_tzinfo_dir, 'zone.tab')) + if l != '' and l[0] != '#'] @@ -1098,6 +1104,7 @@ index 13c83b1..e8a674f 100644 + 'US/Mountain', + 'US/Pacific', + 'UTC']) ++ common_timezones = LazyList( tz for tz in common_timezones if tz in all_timezones) diff --git a/pytz.spec b/pytz.spec index 93c4d7d..cfdd7d9 100644 --- a/pytz.spec +++ b/pytz.spec @@ -1,26 +1,17 @@ -%if 0%{?fedora} || 0%{?rhel} >= 8 -%global with_python3 1 -%else -%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")} -%endif - Name: pytz -Version: 2017.2 -Release: 10%{?dist} +Version: 2018.5 +Release: 1%{?dist} Summary: World Timezone Definitions for Python -Group: Development/Languages License: MIT URL: http://pytz.sourceforge.net/ -Source0: https://pypi.io/packages/source/p/%{name}/%{name}-%{version}.zip +Source0: %pypi_source # Patch to use the system supplied zoneinfo files Patch0: pytz-zoneinfo.patch # https://bugzilla.redhat.com/1497572 Patch1: remove_tzinfo_test.patch BuildArch: noarch -BuildRequires: python2-devel -BuildRequires: pytest %global _description\ pytz brings the Olson tz database into Python. This library allows accurate\ @@ -33,84 +24,71 @@ Almost all (over 540) of the Olson timezones are supported. %description %_description + %package -n python2-%{name} -Summary: %summary -Requires: tzdata +Summary: %summary %{?python_provide:%python_provide python2-%{name}} +BuildRequires: python2-devel +BuildRequires: python2-pytest +Requires: tzdata # Remove before F30 Provides: pytz = %{version}-%{release} Obsoletes: pytz < %{version}-%{release} %description -n python2-%{name} %_description -%if 0%{?with_python3} + %package -n python3-%{name} -Summary: World Timezone Definitions for Python -Group: Development/Languages -BuildArch: noarch +Summary: %summary +%{?python_provide:%python_provide python3-%{name}} BuildRequires: python3-devel BuildRequires: python3-pytest Requires: tzdata -%description -n python3-%{name} -pytz brings the Olson tz database into Python. This library allows accurate -and cross platform timezone calculations using Python 2.3 or higher. It -also solves the issue of ambiguous times at the end of daylight savings, -which you can read more about in the Python Library Reference -(datetime.tzinfo). +%description -n python3-%{name} %_description -Almost all (over 540) of the Olson timezones are supported. -%endif %prep -%setup -q -%patch0 -p1 -b .zoneinfo -%patch1 -p1 -b .removeTest +%autosetup -p1 %build -%{__python2} setup.py build -%if 0%{?with_python3} -%{__python3} setup.py build -%endif # with_python3 +%py2_build +%py3_build %install -%{__python2} setup.py install --skip-build --root %{buildroot} -chmod +x %{buildroot}%{python2_sitelib}/pytz/*.py +%py2_install rm -r %{buildroot}%{python2_sitelib}/pytz/zoneinfo pathfix.py -pn -i %{__python2} %{buildroot}%{python2_sitelib} -%if 0%{?with_python3} -%{__python3} setup.py install --skip-build --root %{buildroot} +%py3_install rm -r %{buildroot}%{python3_sitelib}/pytz/zoneinfo pathfix.py -pn -i %{__python3} %{buildroot}%{python3_sitelib} -%endif # with_python3 %check -PYTHONPATH=%{buildroot}%{python2_sitelib} py.test-%{python2_version} -v -%if 0%{?with_python3} -PYTHONPATH=%{buildroot}%{python3_sitelib} py.test-%{python3_version} -v -%endif +PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} -m pytest -v +PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} -m pytest -v %files -n python2-%{name} %license LICENSE.txt -%doc CHANGES.txt README.txt +%doc README.txt %{python2_sitelib}/pytz/ %{python2_sitelib}/*.egg-info -%if 0%{?with_python3} %files -n python3-pytz %license LICENSE.txt -%doc CHANGES.txt README.txt +%doc README.txt %{python3_sitelib}/pytz/ %{python3_sitelib}/*.egg-info -%endif # with_python3 %changelog +* Thu Aug 23 2018 Miro HronĨok - 2018.5-1 +- Update to 2018.5 (#1508227) + * Sat Jul 14 2018 Fedora Release Engineering - 2017.2-10 - Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild diff --git a/remove_tzinfo_test.patch b/remove_tzinfo_test.patch index 6cae9be..226b97a 100644 --- a/remove_tzinfo_test.patch +++ b/remove_tzinfo_test.patch @@ -1,10 +1,12 @@ +diff --git a/pytz/tests/test_tzinfo.py b/pytz/tests/test_tzinfo.py +index b2640a8..4f5322b 100644 --- a/pytz/tests/test_tzinfo.py +++ b/pytz/tests/test_tzinfo.py -@@ -146,6 +146,7 @@ class PicklingTest(unittest.TestCase): +@@ -155,6 +155,7 @@ class PicklingTest(unittest.TestCase): self._roundtrip_tzinfo(localized_tz) self._roundtrip_datetime(dt.replace(tzinfo=localized_tz)) + @unittest.skip('Fails with system-wide timezone database') def testRoundtrip(self): - dt = datetime(2004, 2, 1, 0, 0, 0) for zone in pytz.all_timezones: + tz = pytz.timezone(zone) diff --git a/sources b/sources index 5e68458..150a15d 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (pytz-2017.2.zip) = d67d64a64b4c21e0bd41da56020fc7b016aec9da7f3243f79b65704119f70b8a9cd4f5f905631b6761e06ecef93830e5e479e16c7b1611ac70e0cd2b39d5b916 +SHA512 (pytz-2018.5.tar.gz) = 35b6bdd25b8e57c693da4379c2032401ef3cf290a57d8448c67dcaf1491a21d27ff25d932ef3ec3a51e31fbb7541e081073f292867a7d1ad47904b69dc7e4863