Accepting request 729337 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/729337
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytz?expand=0&rev=34
This commit is contained in:
Dominique Leuenberger 2019-09-23 10:02:32 +00:00 committed by Git OBS Bridge
commit 853d2a1dcc
3 changed files with 25 additions and 49 deletions

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Tue Aug 27 17:49:06 UTC 2019 - John Vandenberg <jayvdb@gmail.com>
- Add versioned dependency on timezone database to ensure the
correct data is installed
- Remove system_zoneinfo.patch, and instead add a symlink to the
system timezone database
- Replace unnecessary pytest, adding a missing __init__.py in the
tests to allow the test suite to work on Python 2.7 without pytest
-------------------------------------------------------------------
Fri Aug 9 13:22:52 UTC 2019 - Ondřej Súkup <mimi.vx@gmail.com>

View File

@ -16,6 +16,10 @@
#
# Ensure you update the tzdata_version for any minor version increase
# otherwise the update python library has the incorrect timezone data.
%define tzdata_version 2019b
%define oldpython python
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pytz
@ -30,20 +34,14 @@ Source2: https://files.pythonhosted.org/packages/source/p/pytz/pytz-%{ver
Source90: %{name}.keyring
# 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
# PATCH-FIX-UPSTREAM 0001-Fix-tests-for-older-timezone-versions.patch -- https://code.launchpad.net/~toabctl/pytz/+git/pytz/+merge/326419
Patch2: 0001-Fix-tests-for-older-timezone-versions.patch
BuildRequires: %{python_module setuptools}
# pytest is required only because of 2.7 stdlib test runner, python3
# unittest runner is sufficient.
BuildRequires: %{python_module pytest}
# Test requirements
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: timezone
BuildRequires: timezone >= %{tzdata_version}
Requires: python-base
Requires: timezone
Requires: timezone >= %{tzdata_version}
BuildArch: noarch
%ifpython2
Provides: %{oldpython}-tz = %{version}
@ -68,16 +66,22 @@ Amost all of the Olson timezones are supported.
# For rpmlint warning: remove shebang from python library:
sed -i '/^#!/d' ./pytz/tzfile.py
# Help Python 2.7 unittest
touch pytz/tests/__init__.py
%build
%python_build
%install
%python_install
%python_expand rm -fr %{buildroot}%{$python_sitelib}/pytz/zoneinfo
%python_expand %fdupes %{buildroot}%{$python_sitelib}
# Replace custom data with symlink to /usr/share/zoneinfo
%{python_expand rm -r %{buildroot}%{$python_sitelib}/pytz/zoneinfo
ln -s /usr/share/zoneinfo %{buildroot}%{$python_sitelib}/pytz/zoneinfo
%fdupes %{buildroot}%{$python_sitelib}
}
%check
%python_expand PYTHONPATH=. py.test-%{$python_bin_suffix} -v pytz/tests
%python_exec setup.py test
%files %{python_files}
%license LICENSE.txt

View File

@ -1,38 +0,0 @@
--- a/pytz/__init__.py
+++ b/pytz/__init__.py
@@ -87,23 +87,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)
- 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('/usr/share/zoneinfo', *name_parts)
return open(filename, 'rb')
--- a/pytz/tzfile.py
+++ b/pytz/tzfile.py
@@ -126,7 +126,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',